Plotting a map by extracting data in time intervals from a netcdf file

3 visualizaciones (últimos 30 días)
My netcdf file has longitude, latitude, month, and monthly mean temperature. Data are for 10 years. I have to get the average for each month (ie mean for all January months over 10 years, mean for all February months over 10 years, etc). Data file sizes are 180 for latitude, 360 for longitude, 120 for month and monthly mean temperatures. Size of the final answer should be 360 x 180 x12.
Then I need to get the standard deviation and make a plot of it.
Please help me with this.
  1 comentario
Walter Roberson
Walter Roberson el 11 de Feb. de 2023
If you ncread() the monthly mean temperature, is the result an array that is (number of longitude) by (number of latitude) by (12) by (number of years) ? Something else?
Data file sizes are 180 for latitude, 360 for longitude, 120 for month and monthly mean temperatures.
So when you ncread() the monthly mean temperature, the result is 360 x 180 x 120 ? Please verify this explicitly: it would be common in netcdf files to instead find that the data was 180 x 360 x 120 .

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Feb. de 2023
data_by_year = reshape(YourData, size(YourData,1), size(YourData,2), 12, []);
mean_by_month_over_years = mean(data_by_year, 4);
std_by_month_over_years = std(data_by_year, [], 4);
  2 comentarios
Thishan Dharshana
Thishan Dharshana el 11 de Feb. de 2023
Editada: Thishan Dharshana el 12 de Feb. de 2023
Thanks a lot.
Could you also help me plotting "std_by_month_over_years" on a global map? I can get the map as follows.
worldmap('world')
load coastlines
plotm(coastlat,coastlon)
Walter Roberson
Walter Roberson el 12 de Feb. de 2023
Well you have a problem that you have 2d data for each of 12 months
contourm(Data_lat, Data_lon, std_by_month_over_years(:,:,MonthNumber))

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by