简体   繁体   English

NCL-有没有办法从索引信息中减去相同的变量、不同的值(相同的文件)?

[英]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.

相关问题 如何缩小栅格但保持相同的值? - How to dowscale a raster but keeping the same values? 从多个 Netcdf 文件中提取给定变量并连接到单个文件 - Extract a given variable from multiple Netcdf files and concatenate to a single file 如何将变量从一个 netcdf 文件添加到 python 中的另一个 netcdf 文件? - How can you add a variable from one netcdf file to another netcdf file in python? 将 Z 维度中的一个数组与另一个数组相加或减去,其中纬度(Y 维度)和经度(X)不同 - Add or subtract one array in the Z dimension from another, where latitude (Y dimension) and longitude (X) are different 使用 R 从另一个 nc 文件中提取基于 netcdf 文件的值的网格单元 - Extracting grid cells of a netcdf file based values from another nc file with R 合并经纬度不同但时间戳相同的nc文件 - Merge nc files with different longitude and latitude but same timestamps 使用 python 替换 netCDF 文件中的值 - Replace values in netCDF file using python 将低于阈值的值设置为 .netcdf 文件中的阈值 - setting values below a threshold to the threshold in a netcdf file 从 NETCDF 文件中提取数据的有效方法 - Efficient way to extract data from NETCDF files 如何在 netcdf 强制气候文件中使时间变量连续? - How to make time variable continuous in a netcdf forcing climatology file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM