matlab全球气候态月平均海表温度处理过程

文摘   2024-10-11 04:38   德国  

matlab全球气候态月平均海表温度处理过程


读取数据:

ncdisp 'sst.mnmean.nc'% 查看变量方便读取file_sst='sst.mnmean.nc';lat=double(ncread(file_sst,'lat'));lon=double(ncread(file_sst,'lon'));sst=double(ncread(file_sst,'sst'));sst=sst(:,:,1:480);%取40年;[x,y]=meshgrid(lon,lat);x=x';y=y';



求平均:原理,把所有相同的月份相加求平均。直接使用mean即可。

for month_i=1:12

   aim_variable_month(:,:,month_i)=squeeze(nanmean(sst(:,:,month_i:12:end),3));% 求月平均


end


画图:

clear;clc;close all% 想12个月的温度数据,%画出12个子图% 12个子图共用1个colorbarncdisp 'sst.mnmean.nc'% 查看变量方便读取file_sst='sst.mnmean.nc';lat=double(ncread(file_sst,'lat'));lon=double(ncread(file_sst,'lon'));sst=double(ncread(file_sst,'sst'));sst=sst(:,:,1:480);%取40年;[x,y]=meshgrid(lon,lat);x=x';y=y';%%%-----plot-----startcolorbar_text_min=0;colorbar_text_max=30;hh=figure ;set(gcf,'Position',[100,50,1250,980],'color','w');m_proj('miller','lon',180,'lat',[-75 75]);height=0.265;for month_i=1:12    aim_variable_month=squeeze(nanmean(sst(:,:,month_i:12:end),3));% 求月平均    hhh=subplot(4,3,month_i);    m_contourf(x,y,aim_variable_month,200,'linestyle','none');    hold on    [c,h]=m_contour(x,y,aim_variable_month,15,'linecolor','white','LineWidth',1);    caxis([0 30])    m_coast('patch',[.85 .85 .85 ],'edgecolor',[0.6 0.6 0.6]);    hold on    if month_i==1        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(hhh,'position',[0.04,0.74,0.305,height]);        set(gca,'xticklabel',[],'fontsize',12);    elseif month_i==2        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(hhh,'position',[0.35,0.74,0.305,height]);        set(gca,'xticklabel',[],'yticklabel',[]);    elseif month_i==3        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xticklabel',[],'yticklabel',[]);        set(hhh,'position',[0.66,0.74,0.305,height]);    elseif month_i==4        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(hhh,'position',[0.04,0.52,0.305,height]);        set(gca,'xticklabel',[],'fontsize',12);    elseif month_i==5        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xticklabel',[],'yticklabel',[]);        set(hhh,'position',[0.35,0.52,0.305,height]);    elseif month_i==6        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xticklabel',[],'yticklabel',[]);        set(hhh,'position',[0.66,0.52,0.305,height]);    elseif month_i==7        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xticklabel',[]);        set(hhh,'position',[0.04,0.3,0.305,height]);    elseif month_i==8        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xtick',[],'xticklabel',[],'ytick',[],'yticklabel',[]);        set(hhh,'position',[0.35,0.3,0.305,height]);    elseif month_i==9        m_grid('linest','-.','xtick',7,'xticklabel',[],'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'xtick',[],'xticklabel',[],'ytick',[],'yticklabel',[]);        set(hhh,'position',[0.66,0.3,0.305,height]);    elseif month_i==10        m_grid('linest','-.','xtick',7,'ytick',6,'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(hhh,'position',[0.04,0.080,0.305,height]);    elseif month_i==11        m_grid('linest','-.','xtick',7,'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'ytick',[],'yticklabel',[]);        set(hhh,'position',[0.35,0.080,0.305,height]);    elseif month_i==12        m_grid('linest','-.','xtick',7,'ytick',6,'yticklabel',[],'tickdir','in','FontName','Times new roman','FontSize',15,'color','k','box','fancy','fontweight','bold');        set(gca,'ytick',[],'yticklabel',[]);        set(hhh,'position',[0.66,0.08,0.305,height]);    end    hold on    m_text(60,50,[num2str(month_i),'月'] ,'fontsize',16,'color','k','fontweight','bold')endcolaxis=[colorbar_text_min,colorbar_text_max];left=0.1;bottom=0.035;width=0.8;height=0.03;colpos=[left, bottom, width, height];%% 建立colorbar位置和颜色load('D:\matlab_work\十六进制和RGB互转\morecolor1_500.mat');subplot('position',colpos);x1=0:1;y1=colaxis(1):(colaxis(2)-colaxis(1))/1000:colaxis(2);[X,Y]=meshgrid(x1,y1);pcolor(Y,X,Y)shading flatcolormap(hh,morecolor11_500)% 改变填充颜色set(gca,'YTick',[],'YTickLabel',[' '])ylabel('°C')set(gca,'XAxisLocation','bottom','fontsize',12,'fontweight','bold')% print(hh,'全球气候态月平均海表温度分布','-dpng','-r600')export_fig('全球气候态月平均海表温度分布1.jpg','-r300')

matlab画极坐标下的散点密度图

matlab画极坐标下的散点密度图

matlab画双重柱状图,并上移另外一组

matlab对柱状图的平移保持y刻度不变,给出精细修改和实例

matlab画厄尔尼诺年份的海洋表面温度异常分布

matlab如何给海洋添加纯色的底色像python那样

【matlab】多坐标轴的纵坐标刻度颜色的更改

【MATLAB海洋专题】历史汇总

海洋与大气科学
海洋与大气科学数据分析,数据可视化分享,可教学。
 最新文章