这次,加强版本,需要处理数据,看温度盐度等三维特征- Zhixuan Wang et al.Pacific Ocean–originated anthropogenic carbon and its long-term variations in the South China Sea.
DOI:10.1126/sciadv.adn9171.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
% meshgrid:网格化坐标轴
[X1,Y1,Z1]=meshgrid(lx,ly,-depth);% depth是深度;
salt1 = permute(salt1,[2 1 3]);
temp1 = permute(temp1,[2 1 3]);
函数:函数:
% add_coast
function add_coast(zlevel)
% zlevel to control % conctrol the altitude of land.
% load coast data , you can find it in m_map, if you download it, you can
% use search for to find it.
load('coast_data.mat') ;
% Get nan's
idx = all(isnan(ncst),2);% split according the nan of data.
idr = diff(find([1;diff(idx);1]));
coast_data = mat2cell(ncst,idr(:),size(ncst,2));
for i = 1:length(coast_data)
if any(isnan(coast_data{i}(:,1)))
continue
end
lon = coast_data{i}(:,1);
lat = coast_data{i}(:,2);
fill3(lon,lat,ones(length(coast_data{i}(:,1)),1)*zlevel,[.8 .8 .8]);
hold on
% this function adapt from Forest;
end
.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
clear;close all;clc;
file='SODA_2.2.4_201012.cdf';
lon=ncread(file,'lon'); %%% 读取lon变量,读取经度;
lat=ncread(file,'lat'); %%% 读取lat变量,读取纬度;
u=ncread(file,'u'); %%% 读取u变量,读取速度;
v=ncread(file,'v');%%% 读取v变量,读取速度;
temp=ncread(file,'temp');%%% 读取v变量,读取速度;
salt=ncread(file,'salt');%%% 读取v变量,读取速度;
ssh=ncread(file,'ssh'); %%% 读取lon变量,读取经度;
depth=double(ncread(file,'depth'));
lon=double(lon); %%% 利用double将经度单精度转成双精度
lat=double(lat); %%% 利用double将纬度单精度转成双精度
u=double(u); %%% 利用double将深度单精度转成双精度
v=double(v); %%% 利用double将深度单精度转成双精度
temp=double(temp); %%% 利用double将深度单精度转成双精度
salt=double(salt); %%% 利用double将深度单精度转成双精度
ssh=double(ssh); %%% 利用double将深度单精度转成双精度
min(lon)
max(lon)
min(lat)
max(lat)
%% plot
aim_area=[100 130;0 30];
lat1=0; %%% 纬度范围
lat2=30; %%% 纬度范围
lon1=100; %%% 经度范围
lon2=130; %%% 经度范围
%%%% 根据实际经纬度范围;确定起始和结束位置;
ln1=find(lon>lon1,1,'first'); %%找到第一个lon1大的第一个数在lon中的位置;
ln2=find(lon<lon2,1,'last');
la1=find(lat>lat1,1,'first');
la2=find(lat<lat2,1,'last');
%%%% 从lon,lat,topo中提取所需要范围的数据;
lx=lon(ln1:ln2);%%把位置转换为需要的经纬度范围
ly=lat(la1:la2);
u1=u(ln1:ln2,la1:la2,:);
v1=v(ln1:ln2,la1:la2,:);
temp1=temp(ln1:ln2,la1:la2,:);
salt1=salt(ln1:ln2,la1:la2,:);
ssh1=ssh(ln1:ln2,la1:la2,:);
%% 四维网格化
% meshgrid:网格化坐标轴
[X1,Y1,Z1]=meshgrid(lx,ly,-depth);% depth是深度;
salt1 = permute(salt1,[2 1 3]);
temp1 = permute(temp1,[2 1 3]);
% 颜色包
cmap = colormore_4(400);
%% plot
close all
figure
set(gcf,'position',[50 50 1250 850],'color','w')
hold on
slice(X1,Y1,Z1,temp1,115,[],[],'nearest')%(1:5)画5层的盐度图;
hold on
slice(X1,Y1,Z1,temp1,[],10,[],'nearest')%(1:5)画5层的盐度图;
hold on
slice(X1,Y1,Z1,temp1,[],20,[],'nearest')%(1:5)画5层的盐度图;
shading flat%(去网格)
hold on
% alt=0;% conctrol the altitude of land.
% add_coast(alt)% add corse coast
axis([aim_area(1,1) aim_area(1,2) aim_area(2,1) aim_area(2,2) -1500 0])
caxis([0 30])
colormap(cmap)
colorbar
box on
ax = gca;
ax.BoxStyle = 'full';
xlabel('Longitute(°E)','FontSize',14)
ylabel('Latitute(°E)','FontSize',14,'Rotation',65)
zlabel('Depth(m)','FontSize',14)
view(10,55)
export_fig('three_temp2.jpg')
%% plot
close all
figure
set(gcf,'position',[50 50 1250 850],'color','w')
slice(X1,Y1,Z1,temp1,[],[],-1*depth([20]),'nearest')%(1:5)画5层的盐度图;
hold on
slice(X1,Y1,Z1,temp1,115,[],[],'nearest')%(1:5)画5层的盐度图;
hold on
slice(X1,Y1,Z1,temp1,[],10,[],'nearest')%(1:5)画5层的盐度图;
hold on
slice(X1,Y1,Z1,temp1,[],20,[],'nearest')%(1:5)画5层的盐度图;
shading flat%(去网格)
hold on
alt=0;% conctrol the altitude of land.
add_coast(alt)% add corse coast
axis([aim_area(1,1) aim_area(1,2) aim_area(2,1) aim_area(2,2) -1500 0])
caxis([0 30])
colormap(cmap)
colorbar
box on
ax = gca;
ax.BoxStyle = 'full';
xlabel('Longitute(°E)','FontSize',14)
ylabel('Latitute(°E)','FontSize',14,'Rotation',65)
zlabel('Depth(m)','FontSize',14)
view(10,55)
export_fig('three_temp1.jpg')