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
# 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')