【问题标题】:Calculating ERA5 Daily Total Precipitation using CDO使用 CDO 计算 ERA5 每日总降水量
【发布时间】:2020-05-06 00:18:19
【问题描述】:

基本上,这是这个问题的转贴: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 日的 step 1, 2,...,23 与 Jan 2 的 step 0 相加,表示 1979 年 1 月 1 日的 step 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

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

【问题讨论】:

    标签: python netcdf weather cdo-climate era5


    【解决方案1】:

    对于这类问题,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 执行此操作:Better dispersion of accumulated netcdf timesteps with CDO )

    【讨论】:

    • 太棒了,成功了!只是为了确保问题得到充分回答,并考虑到我试图在这里获得总降水量,显然必须是 daysum 而不是 daymean。您能否快速编辑此内容,然后我会接受答案。
    【解决方案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') 
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 2021-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多