Calculating ERA5 Daily Total Precipitation using CDO

后端 未结 2 481
面向向阳花
面向向阳花 2021-01-20 01:51

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

I have downloaded ERA5 from the CDS. The input fi

2条回答
  •  时光取名叫无心
    2021-01-20 02:14

    # 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("", ")")    # drop the last value because values aren't complete.  
    
    sdaily.to_netcdf('daily_prec.nc') 
    

提交回复
热议问题