Azzera filtri
Azzera filtri

how to calculate 3D netcdf in matlab?

7 visualizzazioni (ultimi 30 giorni)
Habtamu Tsegaye
Habtamu Tsegaye il 3 Feb 2023
I have 300-by-240-by-365 3D netcdf file for 16 years rainfall data. I need to have mean monthly data which contains 300-by-240-by-12. how can I do this?
here is my trial script
clear all;
MP2(1:300,1:240,1:12)=0; % in case of IMERG lat is arranged in row where as lon is arranged in column((lat:lon,year)=0) is Monthly Precipitation (MP) with zero intial matrix to start for loop
for yy=2002:2017 % the year from 2002 to 2017
for mm=1:12
ap2(1:300,1:240)=0;
E = eomday(yy,mm);
dy=YYYYMMDD2doy(yy,mm,1);
hits1 = ['D:\Rainfall_Data_from_Satelite\CHIRPS/','chirps-v2.0.',num2str(yy,'%02d'),'.days_p05.nc'];
fe = dir(hits1);
ncid = netcdf.open(hits1);
lat=netcdf.getVar(ncid,0,'single'); % latitude
lon=netcdf.getVar(ncid,1,'single'); % longitude
p1=ncread(hits1,'precip',[4269,1061,dy],[300,240,E]);% days in a month
p1_sum=nansum(p1,3); % a monthly rainfall using sum of daily data
% scale=netcdf.getAtt(ncid,3,'scale_factor');
% offset=netcdf.getAtt(ncid,3,'add_offset');
netcdf.close(ncid);
end
MP2(:,:,mm)=p1_sum;
end

Risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by