Plot netcdf datas through time
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm currently working on an Antarctica project and I have 40go of netcdf data. I need to plot those datas in differents graphs but i can't share the datas as the project is still running and anyway the files are too important in size to be shared. I will try my best to explain.
In my netcdf file I have a variable named 'sisali' representing the salinity evolution in Amundsen Sea every month of 1973. This variable is defined as :
"sisali
Size: 231x190x12
Dimensions: x,y,time_counter
Datatype: single
Attributes:
long_name = 'Mean ice salinity'
units = '1e-3'
online_operation = 'average'
interval_operation = '1800 s'
interval_write = '1 month'
cell_methods = 'time: mean (interval: 1800 s)'
_FillValue = 1.000000020040877e+20
missing_value = 1.000000020040877e+20
coordinates = 'time_centered nav_lon nav_lat' "
The problem is that, my coordinates are in 2 dimensions, and the salinity datas are in 3 dimension because of the time scale. When I try to plot it the first problem occuring is the size difference and then nothing happen.
Do you guys have any idea how to plot this salinity evolution during this year in the Amundsen Sea. Or how to separate the coordinates datas so I can plot just the salinity through time ?
Thanks for your help!
0 comentarios
Respuestas (1)
Chad Greene
el 25 de Sept. de 2020
The answer depends on exactly what you want to display. Do you want 12 different maps, to show salinity distribution for each month? If so, this would do it:
for k = 1:12
subplot(3,4,k)
imagesc(x,y,sisali(:,:,k))
axis xy
title(['Month ',num2str(k)])
caxis([lowerlimit upperlimit]) % for consistency across all plots
cmocean haline % optional colormap
end
Or do you simply want a single map showing average salinity for the year? If so,
imagesc(x,y,mean(sisali,3))
axis xy
cmocean haline
You could similarly subtract mean salinity from each month to show monthly anomalies, like this.
for k = 1:12
subplot(3,4,k)
imagesc(x,y,sisali(:,:,k)-mean(sisali,3))
axis xy
title(['Month ',num2str(k)])
caxis([-1 1]*limit) % for consistency across all plots
cmocean balance % divergent colormap
end
h = imagesc(x,y,sisali(:,:,k));
axis xy
caxis([lowerlimit upperlimit])
cmocean haline
title('Month 1')
gif('amundsen_sea_salinity.gif')
for k = 2:12
h.CData = sisali(:,:,k);
gif
end
Or if you simply want to plot a time series of the average salinity in a given region, you could create a mask for that region that is true for any grid cells you're interested in. An easy way to do that might be to grid up your 1D arrays of coordinates and then use my isopenocean function to determine which of those grid cells correspond to ocean:
[X,Y] = meshgrid(x,y);
mask = isopenocean(X,Y);
Then use my local function to average all the grid cells in that region, for each month. Then you'll end up with a time series of 12 values, containing the mean salinity within the masked region for each month of the year:
sal = local(sisali,mask);
plot(1:12,sal)
xlabel 'month of year'
ylabel 'average salinity within region of interest'
0 comentarios
Ver también
Categorías
Más información sobre NetCDF 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!