[英]NCL-Is there a way to subtract same variable, diferent values (same file) from index information?
I have a 3D nc variable PP = (time, lat, lon) of accumulated precipitation for an entire year and I want to calculate daily values.我有一个 3D nc 变量 PP = (time, lat, lon) 一整年的累积降水量,我想计算每日值。
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)我试图做一个循环,其中减法应该在 [index+1] 减去值 [index] 的值之间(如下所示)
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.我正在与 ncl 合作,但如果您有 cdo 或 nco 提议,欢迎他们。
you can do this with two NCO shell commands您可以使用两个 NCO shell 命令执行此操作
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 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 找出差异
ncbo -v TOTALRAIN shift.nc in.nc diff.nc 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现在 netcdf 文件 diff 应该包含您的每日 pp 此文件中 TOTALRAIN 的最终记录将为零
...Henry ...亨利
In cdo you can disaggregate accumulated variables using在 cdo 中,您可以使用分解累积变量
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.这与此问题有关,请参阅那里的答案以获取更多详细信息,包括插入初始时间步长。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.