我对水下滑翔机的数据进行了大量编辑,测量温度,电导率和压力。由此我们获得盐度,密度和西格玛(西格玛=密度 - 1000)。仪器没有很好地采样,因此编辑很重。我需要为海报制作“漂亮”的等高线图。这不适用于出版物,所以我不担心过滤或平滑的数量。
我遇到sigma(密度)等高线的问题,请看下面。
黑色轮廓线应该跟踪西格玛的填充轮廓,但它们看起来非常糟糕。在完成任何网格化之前,数据被分组1米。这是用于生成图的代码。
以下是用于生成此图片的代码
% load data
load Matlab_data
maxy = 50;
t = 1;
Tstep = t./24./60; % Grid data on t minute time intervals
X1 = time(1)-Tstep:Tstep:time(end)+Tstep;
Y1 = 0:1:maxy; % Grid data on 1 meter depth intervals
ygrid = [' Depth grid: ' num2str(diff(Y1(1:2)))];
xgrid = [' Time grid: ' num2str(diff(X1(1:2)))];
[X,Y]= meshgrid(X1,Y1);
bad_vals = isnan(sal) .* ~isfinite(sal) .* isnan(press); % don't include NaNs or funky imaginary salinities in the contours
vals = find(bad_vals == 0);
Zd = griddata(time(vals),depth(vals),density(vals),X,Y);
Zt = griddata(time(vals),depth(vals),temp(vals),X,Y);
Zs = griddata(time(vals),depth(vals),sal(vals),X,Y);
Zst = griddata(time(vals),depth(vals),sigmat(vals),X,Y);
% Interpolate over gaps
vst = interp1gap(sigmat);
vs = interp1gap(sal);
% Grid interpolated salinity and sigma data
Zst_interp = griddata(time(vals),depth(vals),vst(vals),X,Y);
Zs_interp = griddata(time(vals),depth(vals),vs(vals),X,Y);
%% Contour Plot
% Set up the figure
figure3=figure('Position', [2000, 50, 1500, 500]);
clf
colormap(jet);
% Temperature
ax1 = subplot(2, 1,1);
[c,h] = contourf(X,Y,Zst,50,'linestyle','none'); %,[4:.5:9],'linestyle','none');
cRange = caxis;
hold on
[c2,h2] = contour(X,Y,Zst,[24 24.5 25],'color','k'); %,[22:.5:26.5],'linewidth',1.5,'color','k');
clabel(c2,h2,'fontsize',10,'labelspacing',150);
set(h2,'linewidth',1)
hc = colorbar;
colormap(jet);
datetick('x','mm/dd','keeplimits','keepticks');
grid on;
box on
pos = get(gca,'position');
set(gca,'YDir','reverse')%,'position',[pos(1) pos(2) pos(3)-.06 pos(4)]);
set(gca,'xlim',[time(1)+.5./24 time(end)-.5./24],...
'ylim',[0 maxy],'fontsize',8,'xminortick','on','yminortick','on');
set(get(hc,'ylabel'),'string','Sigma-Theta (kg m^-^3)','rotation',270,'verticalalignment','bottom');
ylabel('Ocean Depth (m)');
xlabel('Date');
%title(['Sigma Theta (kg m^-^3) -' strrep(tag,'_','\_')], 'fontweight', 'bold','FontSize',12)
title(['Sigma Theta (kg m^-^3) :' ygrid xgrid ], 'fontweight', 'bold','FontSize',12)
ax2 = subplot(2, 1,2);
%h=pcolor(X,Y,Zst);
[c,h] = contourf(X,Y,Zst_interp,50,'linestyle','none'); %,[4:.5:9],'linestyle','none');
shading interp
hc = colorbar;
cRange = caxis;
hold on
[c2,h2] = contour(X,Y,Zst_interp,[24 24.5 25],'color','k'); %,[22:.5:26.5],'linewidth',1.5,'color','k');
clabel(c2,h2,'fontsize',10,'labelspacing',150);
set(h2,'linewidth',1)
hc = colorbar;
colormap(jet);
caxis(cRange);
datetick('x','mm/dd','keeplimits','keepticks');
grid on;
box on
pos = get(gca,'position');
set(gca,'YDir','reverse')%,'position',[pos(1) pos(2) pos(3)-.06 pos(4)]);
set(gca,'xlim',[time(1)+.5./24 time(end)-.5./24],...
'ylim',[0 maxy],'fontsize',8,'xminortick','on','yminortick','on');
set(get(hc,'ylabel'),'string','Sigma-Theta (kg m^-^3)','rotation',270,'verticalalignment','bottom');
ylabel('Ocean Depth (m)');
xlabel('Date');
% title(['Sigma Theta (kg m^-^3) -' strrep(tag,'_','\_')], 'fontweight', 'bold','FontSize',12)
title(['Sigma Theta interp1gap (kg m^-^3) :' ygrid xgrid ], 'fontweight', 'bold','FontSize',12)
请帮忙!我有两个问题......第一个也是最明显的是丑陋的黑色轮廓线,它们应该很好地“流动”在填充的轮廓周围。如果有人有经验或建议如何平滑这些,请尽可能通过代码。
第二个问题在于底部情节,我需要填补数据空白(由于编辑原始的坏数据)。我使用了文件交换机上提供的函数interp1gap,但它也将数据插入到更深的深度,这是我不想要的。我只想填补空白,例如选择他们的横向邻居并填写。
如果您有任何解决此问题的建议,请与我们联系!我附加了数据(Matlab_data.mat),它包括时间,深度,sal(盐度),sigmat,按压,温度和密度。
这是网格问题吗?请尽可能具体,如果您有时间研究,我们将非常感谢任何代码和数据。
数据可用下拉框https://www.dropbox.com/s/mjd8f9bzdvwddk5/Matlab_data.mat?dl=0
非常感谢你!