Matlab plot -- vertical temperature distribution

clc;clear;close;

yr=2019;
start_date='2019-01-01 00:00:00';

%% obs vertical temperature distribution
% load observation data
ncload('/Users/chuyanzhao/Desktop/gls_observation_data/obs_glerl_mooring/glerl_lake_superior_temperature_mooring_2018_2020.nc');

% adjust time to target time period
tmp_time_obs=datetime(datestr(time/86400+datenum(1970,1,1)));
time_obs_start=datenum(start_date-tmp_time_obs(1))*24;
time_obs_end=time_obs_start+365*24;
tmp_year=time(time_obs_start:time_obs_end);
time_obs=(tmp_year-tmp_year(1))/3600/24;

% read observation depth
depth_obs=-z;

% read observation temperature
temp_obs=sea_water_temperature(time_obs_start:time_obs_end,:);
tmp_ind=temp_obs<-1000;
temp_obs(tmp_ind)=NaN;
lat_obs=[lat;lat];
lon_obs=[lon;lon];

% set colorbar
cmin=0;cinc=1;cmax=20;
ncc=round([cmax-cmin]/cinc);
ccmap=flipud(spectral(ncc));

% plot obs vertical temperature
figure(101);clf;hold on;box on;
    set(gca,'tickdir','out');
    contourf(time_obs,depth_obs,temp_obs',[cmin:cinc:cmax],'LineColor','none');
    caxis([cmin cmax]);
    colormap(ccmap);
    colorbar('location','eastoutside');
    axis([0 366 -190 -5]);
    lcb=colorbar('location','eastoutside');
    ylabel(lcb,'LST (\circC)');
    text(10,-180,['Vertical temp profile by mooring'],'background','w');
    xlabel(['Julian day ' num2str(yr)]);
    ylabel(['Depth (m)'])

    saveas(gcf,['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/figure/HighRes/fig_vertical_temp_obs_' num2str(yr) '.png'],'png'); 

%% find the nearest node in fvcom to the mooring location

% read fvcom grids
ncload(['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/HighRes/gls_lst_2019_HighRes.nc'],'lon','lat');
lat_mod=lat;
lon_mod=lon-360;

% find the nearest node of the mooring location
xy_node=[lat_mod lon_mod];
xy_obs=[lat_obs lon_obs];

loc=find_nearest_group(xy_node,xy_obs);

pos=loc(1,1)

%% fvcom vertical temperature distribution

% generate the raw data by linux command and load
ncload(['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/raw_data/HighRes/gls_ver_temp_2019_HighRes.nc']);
temp_mod=temp;

[nt,nn]=size(temp_mod);

tmp_time_mod=[1:nt];
time_mod=tmp_time_mod/24;
depth_mod=h.*siglay(:);

cmin=0;cinc=1;cmax=20.0;
ncc=round([cmax-cmin]/cinc);
ccmap=flipud(spectral(ncc));

figure(201);clf;hold on;box on;
    set(gca,'tickdir','out');
    contourf(time_mod,depth_mod,temp_mod',[cmin:cinc:cmax],'LineColor','none');
    caxis([cmin cmax]);
    colormap(ccmap);
    axis([0 366 -190 -5]);
    lcb=colorbar('location','eastoutside');
    ylabel(lcb,'LST (\circC)');
    text(10,-180,['Vertical temp profile by fvcom'],'background','w');
    xlabel(['Julian day ' num2str(yr)]);
    ylabel(['Depth (m)'])

    saveas(gcf,['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/figure/HighRes/fig_vertical_temp_mod_' num2str(yr) '.png'],'png'); 

%%  Difference between fvcom and observation -- interpolate fvcom temp to mooring location
temp_mod2obs= interp1(depth_mod,temp_mod',depth_obs);

% calculate the difference
temp_diff=temp_mod2obs-temp_obs';

% set colorbar
color_scale1=[
178,24,43
214,96,77
244,165,130
253,219,199
247,247,247
247,247,247
209,229,240
146,197,222
67,147,195
33,102,172]/255;

cmin=-5;cinc=2;cmax=5.0;
ccmap=flipud(color_scale1);

% plot
figure(301);clf;hold on;box on;
    set(gca,'tickdir','out');
    contourf(time_obs,depth_obs,temp_diff,[cmin:cinc:cmax],'LineColor','none');
    caxis([cmin cmax]);
    colormap(ccmap);
    colorbar('location','eastoutside');
    axis([0 366 -180 -5]);
    lcb=colorbar('location','eastoutside');
    ylabel(lcb,'LST (\circC)');
    text(10,-170,['Vertical temp difference profile (fvcom2obs)'],'background','w');
    xlabel(['Julian day ' num2str(yr)]);
    ylabel(['Depth (m)'])

saveas(gcf,['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/figure/fig_vertical_temp_diff_fvcom2obs' num2str(yr) '.png'],'png'); 

%%  Difference between fvcom and observation -- interpolate mooring temp to fvcom layer
temp_obs2mod= interp1(depth_obs,temp_obs',depth_mod);

% calculate the difference
temp_diff=temp_mod'-temp_obs2mod;

% set colorbar
cmin=-5;cinc=2;cmax=5.0;
ccmap=flipud(color_scale1);

% plot
figure(401);clf;hold on;box on;
    set(gca,'tickdir','out');
    contourf(time_mod,depth_mod,temp_diff,[cmin:cinc:cmax],'LineColor','none');
    caxis([cmin cmax]);
    colormap(ccmap);
    colorbar('location','eastoutside');
    axis([0 366 -180 -5]);
    lcb=colorbar('location','eastoutside');
    ylabel(lcb,'LST (\circC)');
    text(10,-170,['Vertical temp difference profile (obs2fvcom)'],'background','w');
    xlabel(['Julian day ' num2str(yr)]);
    ylabel(['Depth (m)'])

saveas(gcf,['/Users/chuyanzhao/Desktop/FVCOM_output/Lake_Superior/2019/figure/fig_vertical_temp_mod_obs2fvcom' num2str(yr) '.png'],'png'); 

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值