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: 您可以在以下网址上下载Violinplot-Matlab: https://www.mathworks.com/matlabcentral/fileexchange/45134-violin-plot 在该页面上,您可以找到一个绿色的按钮“Download”,单击该按钮即可下载。您需要有MathWorks账户才能下载该文件。如果您没有MathWorks账户,您需要首先注册一个账户。下载后,您可以将其解压缩到您需要使用的任何位置。 ### 回答2: 要下载Violinplot-Matlab,您需要按照以下步骤进行操作: 1. 打开Matlab官方网站,并登录您的MathWorks账户。如果您没有账户,那么您需要先注册一个。 2. 在网站的搜索栏中,输入"Violinplot-Matlab"并点击搜索。 3. 在搜索结果中找到匹配的内容,通常它会是一个MATLAB文件或者一个开源项目。 4. 单击该文件或项目的链接,进入相关页面。 5. 在页面上,您可以找到下载按钮或者命令。单击按钮或者复制命令以下载Violinplot-Matlab。 6. 保存下载文件到您希望的目录中。 7. 解压下载的文件(如果它是一个压缩文件)。 8. 打开MATLAB软件。 9. 在MATLAB的命令窗口中,导航到您保存Violinplot-Matlab的目录。 10. 运行相关的MATLAB脚本或者函数,以加载Violinplot-Matlab工具包。 这样,您就成功下载了Violinplot-Matlab工具包,并可以在MATLAB中使用它进行相关的数据分析和可视化任务。请注意,下载过程可能会因版本不同而有所不同,因此在实际操作时请参考具体的下载指南。 ### 回答3: 要下载Violinplot-Matlab,您可以按照以下步骤进行操作: 1. 打开Matlab软件,并确保您有一个有效的Matlab许可证。 2. 在Matlab的命令窗口中输入 `addpath(genpath('https://github.com/bastibe/Violinplot-Matlab'))`,然后按下回车。这将自动下载并添加Violinplot-MatlabMatlab的搜索路径中。 3. 在您的Matlab脚本或命令窗口中,输入 `help violinplot`以查看Violinplot-Matlab的文档和使用方法。 4. 您现在可以使用Violinplot-Matlab来创建您要的小提琴图了。根据您的数据和需求,调用合适的函数来绘制小提琴图,并根据需要进行自定义设置。 请注意,下载和使用第三方工具箱可能需要一些额外的步骤和配置。如果您在下载或使用过程中遇到问题,建议查阅相关的Matlab和Violinplot-Matlab文档,或者联系Matlab社区或工具包的开发者获取帮助和支持。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值