How to extract time series averaged over a region?
Afficher commentaires plus anciens
Hi All,
I've been working on this monthly chlorophyll dataset where the "chl variable" has the dimensions 489x221x1X24 (lon x lat x depth x time). So basically the 4th dimensions has 24 chlorophyll values corresponding to 24 months from Jan'20 to Dec'21. Now I wanted to extract the chlorophyll values for 24 months of the entire region into a table; in that way I have a time series for further analysis.
lon=ncread("chl2020.nc","longitude");lat=ncread("chl2020.nc","latitude");
chl=ncread("chl2020.nc","chl");
this=squeeze(chl);
% removes the 3rd dimension
latrange= -25:0.25:30;
lonrange= 32:0.25:120;
% Indexing the region
for i=1:length(latrange)
latindex(i)= find(lat==latrange(i));
end
for i=1:length(lonrange)
longindex(i)= find(lon==lonrange(i));
end
%Finding the values for January - 2020
newchl = this(longindex,latindex,1);
%Finding the values for February - 2020
newchl2 = this(longindex,latindex,2);
Now, the last two lines basically extract for each month. However, this is time consuming and I wanted to know how to code a more efficient and quicker way to get all the monthly values averaged over the entire region from Jan '20 - Dec '21. The dataset is below:
My end goal is a 2-D result with Months and Chlorophyll values. I'd be grateful for any assistance in this. Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur NetCDF dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!