本质上,这是对这个问题的重新发布:https://confluence.ecmwf.int/pages/viewpage.action?pageId=149341027
我已经从光盘下载了ERA5。从每个考虑的年份的1月1日至12月31日,每个日历日的输入文件都有24个小时步骤(0、1、2、3、4、..,23)。
ECMWF在这里指出,日总降水量必须通过对1979年1月1日、1979年1月1日、1979年1月1日的...,23和1月2日第0步的求和来计算,这意味着1979年1月1日的步骤0不包括在该日总降水量的计算中。在计算1979年1月2日的总降水量时,我们还使用了当天的步骤1、2、3、...,23加上1月3日的步骤0等。
在python中这样做似乎有一个选择:
import xarray as xr # import xarray library
ds_nc = xr.open_dataset('name_of_your_file.nc') # read the file
daily_precipitation = ds_nc.tp.resample(time='24H').sum('time')*1000 # calculate sum with frequency of 24h and multiply by 1000
daily_precipitation.to_netcdf('daily_prec.nc') # save as netCDF现在,我想知道这是否也有可能以一种简单的方式使用气候数据运算符(CDO)。通常,我会使用CDO中的daysum命令进行任何这样的计算,但我不确定这是否正确。
有人建议使用:
cdo -f nc copy out.nc aux.nc
cdo -delete,timestep=1, aux.nc aux1.nc
cdo -b 32 timselsum,24 aux1.nc aux2.nc
cdo -expr,'ppt=tp*1000' -setmissval,-9999.9 -remapbil,r240x120 aux2.nc era5_ppt_prev-0_1979-2018.nc但我不确定这是对的-有什么建议吗?
发布于 2020-01-28 09:51:00
对于这类问题,CDO中有用的命令是shifttime,它本质上执行can上的内容并移动时间戳。
这种问题经常出现在任何类型的通量或累积场中,其中分配给数据值的时间戳指向时间积累周期的结束,或称为“窗口”,例如,一天中的最后三个小时的3小时数据在以后的日期为00,而直接应用的日平均或日和等函数将不正确地计算出前一天一天和3小时内平均21小时的时间。将时间戳移动三个小时,以便在执行计算之前将时间点移到窗口的开始(实际上是1.5,指向中间)就可以解决这个问题。
因此,对于您的具体问题,如果您有来自ERA5的长系列小时数据,并且您想要每天的数据总数,您可以这样做:
cdo shifttime,-1hour in.nc shift.nc # now step 0 on Jan 2 has Jan 1, 23:00 stamp
cdo daysum shift.nc daysum.nc 或管道连接在一起:
cdo daysum -shifttime,-1hour in.nc daysum.nc编辑:我现在有一个上传视频指南,它详细讨论这个问题,以防它对这篇文章的读者有帮助。
(注:对于较早的ERA-中期的通量用户来说,这一过程并不相同,即通量是通过短期预测期累积起来的。对于ERA5,“退积”已经为您完成了。对于ERA,您需要更改连续的时间步骤,以从累积字段转换,这里有一篇文章展示了如何使用CDO或python:用CDO将累积变量转换为netcdf文件中的时间步长值进行转换。
发布于 2020-04-26 00:32:20
# Correction to above python example to account for the time shift, as in the CDO example. Input file always needs to have the following day to the last day for which you want to compute daily sums/averages
import xarray as xr
ds_nc = xr.open_dataset('name_of_your_file.nc') # read the file
sds= ds_nc.shift(time=-1).dropna(dim='time',how='all') # shift to account for time shift for accumulated variables
daily_precipitation = sds.tp.resample(time='24H').sum('time')*1000 # calculate sum with frequency of 24h and multiply by 1000
# need to figure start_time and end_time for separately or slice differently.
sdaily=daily_precipitation.sel(time=slice("<start_time>", "<end_time>)") # drop the last value because values aren't complete.
sdaily.to_netcdf('daily_prec.nc') 发布于 2021-04-03 09:51:23
如果你显示任何两天的ERA 5数据,你可以观察到02 1月(例如)0时tp已经在过去24小时内累积降水(从01月01 0100到01月022400)。所以你只需要在时间步骤0000中选择降水的值。
https://stackoverflow.com/questions/59815665
复制相似问题