I have a 3D netcdf variable PP = (time, lat, lon) of accumulated precipitation for an entire year and I want to calculate daily values.
I want to do something link in the example, but couldn't find any examples.
I've tried to do a loop in which the subtraction should be between the values with [index+1] minus value [index] (like below)
t = f->time(:) ;size = 365
pp = f->TOTALRAIN(:,:,:) ; time, lat, lon dimensions
do i = 0,dimsizes(t)-1
DailyPp = pp(i,:,:) - pp(i-1,:,:)
end do
but that way produces an error.
I need the daily values and only have accumulated precipitation as input information, and thought that a loop like that should be the best way.
How can I do the calculation from the variable???
I'm working with ncl
but if you have cdo
or nco
propositions they're welcome.
you can do this with two
nco
shell commandsthe
ncks
command shifts the records up by onencks -v TOTALRAIN --msa_usr_rdr -d time,1,364 -d time,364 in.nc shift.nc
now use
ncbo
to find the differencencbo -v TOTALRAIN shift.nc in.nc diff.nc
now the netcdf file diff should contain your daily pp The final record of TOTALRAIN in this file will be zero's.