3

本质上,这是对这个问题的转发:https ://confluence.ecmwf.int/pages/viewpage.action?pageId=149341027

我已经从 CDS 下载了 ERA5。输入文件从每个考虑年份的 1 月 1 日到 12 月 31 日的每个日历日都有 24 小时步长(0、1、2、3、4、..、23)。

ECMWF 在这里声明https://confluence.ecmwf.int/display/CKB/ERA5%3A+How+to+calculate+daily+total+precipitation每日总降水量必须通过累积降水量来计算,例如 1979 年 1 月 1 日通过求和1 月 1 日的第 1、2、...、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

但我不确定这是正确的 - 有什么建议吗?

4

3 回答 3

5

对于这类问题,CDO 中有用的命令是shifttime,它基本上执行罐头上所说的操作并移动时间戳。

这种问题经常出现在任何类型的通量或累积字段中,其中分配给数据值的时间戳指向时间累积周期或“窗口”的END,例如,在最后三个小时的 3 小时 TRMM 数据中之后的日期当天有00的戳记,直接应用daymean或daysum等函数会计算一天21小时和前一天3小时的平均值,错误。在您执行计算之前将时间戳移动三个小时,以便时间指向窗口的开始(或者实际上是 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-Interim 中的通量用户不同,其中通量在较短的预测期内累积。对于 ERA5,“去累积”已经为您完成。使用 ERA-Interim,您需要从累积字段转换的连续时间步长的差异,这里有一篇文章展示了如何使用 CDO 或 python 执行此操作:使用 CDO更好地分散累积的 netcdf 时间步长

于 2020-01-28T09:51:00.240 回答
2
# 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') 
于 2020-04-26T00:32:20.323 回答
1

如果您显示任意两天的 ERA 5 的数据,您可以观察到 1 月 2 日(例如)0000 的 tp 已经是过去 24 小时(从 1 月 1 日的 0100 到 1 月 1 日的 2400(1 月 2 日的 0000))过去 24 小时内的累积降水)。因此,您只需要在时间步 0000 处选择降水值。

于 2021-04-03T09:51:23.010 回答