使用CDO计算ERA5每日总降水量 [英] Calculating ERA5 Daily Total Precipitation using CDO

查看:2136
本文介绍了使用CDO计算ERA5每日总降水量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从本质上讲,这是该问题的转贴: https://confluence .ecmwf.int/pages/viewpage.action?pageId = 149341027

Essentially, this is a repost of this question: https://confluence.ecmwf.int/pages/viewpage.action?pageId=149341027

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

I have downloaded ERA5 from the CDS. The input file has 24 hourly steps (0, 1, 2, 3, 4,..,23) for each calendar day starting from Jan 1 to Dec 31 of each considered year.

此处的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,依此类推.

ECMWF state here https://confluence.ecmwf.int/display/CKB/ERA5%3A+How+to+calculate+daily+total+precipitation that daily total precipitation must be calculated by accumulating precipitation for e.g. Jan 1, 1979 by summing the steps 1, 2,...,23 of Jan 1 AND step 0 of Jan 2. It means that the step 0 of Jan 1, 1979 is not included in calculation of the total precipitation for that day. For calculation of total precipitation for Jan 2, 1979 we use also the steps 1, 2, 3,...,23 of that day plus step 0 of Jan 3 and so on.

似乎可以在python中执行以下操作:

There seems to be an option doing this in python like this:

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命令进行任何此类计算,但是我不确定这是正确的.

Now I am wondering whether this is also possible using the Climate Data Operators (CDO) in an easy way. Normally I would do any such calculation using the daysum command in CDO, but I'm not sure this is correct.

有人建议使用:

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

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

But I'm not sure this is correct - any suggestions?

推荐答案

对于此类问题,CDO中有用的命令是 shifttime ,该命令实际上执行了罐上的说明并移动了时间戳记.

For these kind of issues, the useful command in CDO is shifttime, which essentially does what is says on the can and shifts the time stamp.

这种问题经常出现在任何一种通量或累积字段中,其中分配给数据值的时间戳指向时间累积时段的 END 或窗口",例如,使用3小时的TRMM数据,在一天的最后三个小时中,其后的日期将带有00标记,并且直接应用诸如daymean或daysum之类的功能将不正确地计算一天中的21个小时和前一天的3个小时的平均值.在执行计算之前,将时间戳偏移三个小时,以便时间指向窗口的开始(或者实际上指向窗口的中间是1.5),即可解决此问题.

This kind of problem arises frequently with any kind of flux or accumulated field where the timestamp allocated to the data value points to the END of the time accumulation period, or "window", for example, with 3 hourly TRMM data the last three hours of the day have the stamp of 00 on the date afterwards, and functions such as daymean or daysum applied directly will calculate the average of 21 hours in one day and 3 hours from the previous day, incorrectly. Shifting the timestamp by three hours so the time points to the start of the window (or indeed by 1.5, pointing to the middle) before you perform the calculation will resolve this.

因此,对于您的特定问题,即您拥有来自ERA5的大量每小时数据,并且您需要每日总计,可以执行以下操作:

So for your specific question where you have a long series of hourly data from ERA5 and you want the daily total, you can do:

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做到这一点:

(NOTE: This procedure is not the same to users of fluxes from the older ERA-Interim, where the fluxes are accumulated through the short forecast period. For ERA5 the "deaccumulation" is already done for you. With ERA-Interim you need to difference consecutive timesteps to convert from an accumulated field, and there is a post here that shows how to do this with CDO or python: Better dispersion of accumulated netcdf timesteps with CDO )

这篇关于使用CDO计算ERA5每日总降水量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆