matlab画厄尔尼诺年份的海洋表面温度异常分布
数据:海洋表面温度 sst.nc
确定研究范围:本次南海;
从文献找到以往厄尔尼诺现象发生的年份:这里使用强厄尔尼诺年份(82-83,97-98,15-16)
step01: 读取数据;
clear;clc;close all;
% 超强厄尔尼诺冬季-普通厄尔尼诺冬季
% 经度100-120E,纬度0-25N,
% 超强厄尔尼诺年份(82-83,97-98,15-16)
file = 'sst.nc';
% 读取数据
lon = double(ncread(file,'LON401_481'));
lat = double(ncread(file,'LAT361_461'));
time = double(ncread(file,'TIME'));
SST = double(ncread(file,'SST'));
time = time + datenum(1,1,1);
time = datevec(time);
step02: 找到冬季的海表面温度;
%提取冬季温度;
lc = find(time(:,2)==12|time(:,2)==1|time(:,2)==2);
lc = lc(3:end-1);% 选取完整的冬季序列:1-2为不完整,因此从3开始。12-1-2为完整
% 冬季温度;
temp_1970_2022=SST(:,:,lc);
[m,n,t]=size(temp_1970_2022);
year = 1970:2022;
temp= reshape(temp_1970_2022,[m,n,3,t/3]);
temp_winter_mean = squeeze(nanmean(temp,3));% 冬季平均的温度
step03: 找到强厄尔尼诺年份冬季的海表面温度;
% 厄尔尼诺年份的冬季温度;8283,9798,1516
ln = find(year==1982|year==1997|year==2015);
temp_erninuo=temp_winter_mean(:,:,ln);
temp_erninuo_mean = squeeze(nanmean(temp_erninuo,3));
step04: 求距平;
% 超强厄尔尼诺-普通年份的冬季温度
temp_ano = temp_erninuo_mean-temp_1970_2022_mean;
step05: 画图
%% 坐标网格化
[ ]=meshgrid(lon,lat);
x=x';y=y';
%% 颜色包
cmap = load('MALTLAB_YlOrRd9.txt');
cmap = load('colormore_7.txt');
%% 画图
close all
figure
set(gcf,'position',[50 50 1250 850],'color','w')
m_proj('miller','lon',[100 120],'lat',[0 25])
m_contourf(x,y,temp_ano,50,'linestyle','none')
m_gshhs_f('patch',[0.85 0.85 0.85],'edgecolor','k');
m_grid('xtick',[100:5:120],'ytick',[0:5:25],'fontsize',12,'fontname','time news roman');
colormap(cmap)
caxis([-1 1])
c=colorbar;
set(c,'tickdir','out') % 朝外
set(c,'YTick',-1:0.1:1,'YTickLabel',-1:0.1:1); %色标值范围及显示间隔
title('厄尔尼诺年份的温度异常分布图')
export_fig('冬季强厄尔尼诺温度异常.jpg','-r600')
出图:
代码汇总:
clear;clc;close all;
% 超强厄尔尼诺冬季-普通厄尔尼诺冬季
% 经度100-120E,纬度0-25N,
% 超强厄尔尼诺年份(82-83,97-98,15-16)
file = 'sst.nc';
% 读取数据
lon = double(ncread(file,'LON401_481'));
lat = double(ncread(file,'LAT361_461'));
time = double(ncread(file,'TIME'));
SST = double(ncread(file,'SST'));
time = time + datenum(1,1,1);
time = datevec(time);
%提取冬季温度;
lc = find(time(:,2)==12|time(:,2)==1|time(:,2)==2);
lc = lc(3:end-1);% 选取完整的冬季序列:1-2为不完整,因此从3开始。12-1-2为完整
% 冬季温度;
temp_1970_2022=SST(:,:,lc);
[m,n,t]=size(temp_1970_2022);
year = 1970:2022;
temp= reshape(temp_1970_2022,[m,n,3,t/3]);
temp_winter_mean = squeeze(nanmean(temp,3));% 冬季平均的温度
% 1970_2022的冬季温度
temp_1970_2022_mean = squeeze(nanmean(temp_winter_mean,3));
% 厄尔尼诺年份的冬季温度;8283,9798,1516
ln = find(year==1982|year==1997|year==2015);
temp_erninuo=temp_winter_mean(:,:,ln);
temp_erninuo_mean = squeeze(nanmean(temp_erninuo,3));
% 超强厄尔尼诺-普通年份的冬季温度
temp_ano = temp_erninuo_mean-temp_1970_2022_mean;
%% 坐标网格化
[x,y]=meshgrid(lon,lat);
x=x';y=y';
%% 颜色包
cmap = load('MALTLAB_YlOrRd9.txt');
%% 画图
close all
figure
set(gcf,'position',[50 50 1250 850],'color','w')
m_proj('miller','lon',[100 120],'lat',[0 25])
m_contourf(x,y,temp_ano,50,'linestyle','none')
m_gshhs_f('patch',[0.85 0.85 0.85],'edgecolor','k');
m_grid('xtick',[100:5:120],'ytick',[0:5:25],'fontsize',12,'fontname','time news roman');
colormap(cmap)
caxis([0 1])
c=colorbar;
set(c,'tickdir','out') % 朝外
set(c,'YTick',0:0.1:1,'YTickLabel',0:0.1:1); %色标值范围及显示间隔
title('厄尔尼诺年份的温度异常分布图')
export_fig('冬季强厄尔尼诺温度异常.jpg','-r600')