How to plot an ocean depth profile colormap for a angled coast?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to plot a colormap depth profile of a section of the ocean that runs along an angle (along the coast of Nova Scotia). I am able to use a single latitude to plot along several longitudes (or vice versa), but I don't know how to use several latitudes/longitudes to plot a section on a 60 degree angle. Basically I can plot profiles with depth on the y axis and lat/long on the x-axis, and then my variable (temperature/oxygen/salinity) as the color, but I can't figure out how to do it on an angle along the coast.
This is the code required to plot a horizontal section at 43.25 degrees latitude:
nt=31; %number of days
varname='oxygen'; % which tracer to plot
name='D:\ModelResults\simulation_20220119\L3_model_results\ControlRun_realistic\ControlRun201808\ocean_avg.nc'; %dataset
lon=ncread(name,'lon_rho',[1 1],[Inf 1]); %longitude
lat=ncread(name,'lat_rho',[1 1],[1 Inf]); %latitude
king1=find(lat>=43.25-1/216&lat<=43.25+1/216); %specific latitude to plot at
LatP=lat(king1);
topography=depths(name,'E:\oxygen_model_201801_scratch\ROMS_TRUNK\Data\ROMS\Grid\grid_L3.nc',1,0,1); %grid for depths/topography
TopographyP=topography(:,king1,:);
dim=size(TopographyP);
sum=zeros(dim);
Tracer=ncread(name,varname);
for days=1:1:nt
sum=sum+Tracer(:,king1,:,days);
end
TracerAvg=sum/nt; %find the average
for i=1:1:size(lon)
for j=1:1:dim(3)
LonP(i,1,j)=lon(i,1);
end
end
subplot(1,1,1)
pcolor(squeeze(LonP-360),squeeze(TopographyP),squeeze(TracerAvg));shading flat
hold on
[C,f]=contour(squeeze(LonP-360),squeeze(TopographyP),squeeze(TracerAvg),8:2:26,'color','k');
clabel(C,f,8:2:26)
0 comentarios
Respuestas (1)
MJFcoNaN
el 26 de Jun. de 2022
Hello,
The 2D or 3D interpolation may help.
The method of reading lon and lat suggests your ROMS's grid in a form of "ndgrid", right? Then griddedInterpolant is a good choice. For example:
[x,y,~]=ndgrid(lon,lat,1:size(topography,3));
% in the loop
f=griddedInterpolant(x,y,topography,Tracer(:,:,:,days));
% target lon, lat, depth
[LonP,LatP,TopographyP]=ndgrid([80 87],[40 50 55],[0:10:1000]);
t=f(LonP, LatP, TopographyP);
3 comentarios
MJFcoNaN
el 2 de Jul. de 2022
Editada: MJFcoNaN
el 2 de Jul. de 2022
- Please make sure your ROMS's grid is indeed in a form of "ndgrid". (I guess it because there are lines like this: lon=ncread(name,'lon_rho',[1 1],[Inf 1]); %longitude )
- Pay attention to "topography". I can't find whether it a ndgrid format or not... If not, Tracer will not be ndgrid neither. Then you may interpolate on every vertical layer to avoid the 3rd dimension of depth, like this one:
[x,y]=ndgrid(lon,lat);
f=griddedInterpolant(x,y,Tracer(:,:,layer,days));
[LonP,LatP]=ndgrid([80 87],[40 50 55]);
t=f(LonP, LatP);
PS: Another option is "scatteredInterpolant"
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!