I have a 3D nc variable PP = (time, lat, lon) of accumulated precipitation for an entire year and I want to calculate daily values.
I want to do something linke in the example, but culdn'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 commands
the below command shifts the records up by one
ncks -v TOTALRAIN --msa_usr_rdr -d time,1,364 -d time,364 in.nc shift.nc
now use ncbo to find the difference
ncbo -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
...Henry
In cdo you can disaggregate accumulated variables using
cdo deltat in.nc diff.nc
This is related to this question , please refer to the answers there for more details, including inserting the initial timestep.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.