我对测量温度、电导率和压力的水下滑翔机的数据进行了大量编辑。从中我们得到盐度、密度和西格玛(西格玛 = 密度 - 1000)。该乐器的采样效果不是很好,因此需要进行大量编辑。我需要为海报制作“漂亮”的等高线图。这不适用于出版物,所以我不担心过滤或平滑的数量。
我在使用 sigma(密度)的等高线时遇到问题,请参见下文。
黑色轮廓线应该描绘 sigma 的填充轮廓,但它们看起来很糟糕。在完成任何网格化之前,数据被分箱了 1 m。这是用于生成图的代码。
这是用于生成此图像的代码
% 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
非常感谢您!