Basically, this is a repost or follow-up from How to calculate daily average from ERA5 hourly netCDF data? I have four atmospheric variables, viz. dew point temperature, longwave radiation, shortwave radiation, and wind speed (calculated from u10 and v10 wind components). All are on an hourly scale and I need to convert them into the daily scale (note that here I've given the example of dew point temperature only). In order to do this first I applied the following command
cdo daymean -shifttime,-1hour d2m.nc d2m_wb.nc
and got the following result.
cdo sinfo d2m_wb.nc
File format : NetCDF2
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown v instant 1 1 475 1 F64 : -1
Grid coordinates :
1 : lonlat : points=475 (19x25)
lon : 85.5 to 90 by 0.25 degrees_east
lat : 21.5 to 27.5 by 0.25 degrees_north
Vertical coordinates :
1 : surface : levels=1
Time coordinate : 25904 steps
RefTime = 1900-01-01 00:00:00 Units = hours Calendar = gregorian Bounds = true
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
1949-12-31 23:00:00 1950-01-01 11:00:00 1950-01-02 11:00:00 1950-01-03 11:00:00
1950-01-04 11:00:00 1950-01-05 11:00:00 1950-01-06 11:00:00 1950-01-07 11:00:00
1950-01-08 11:00:00 1950-01-09 11:00:00 1950-01-10 11:00:00 1950-01-11 11:00:00
1950-01-12 11:00:00 1950-01-13 11:00:00 1950-01-14 11:00:00 1950-01-15 11:00:00
1950-01-16 11:00:00 1950-01-17 11:00:00 1950-01-18 11:00:00 1950-01-19 11:00:00
1950-01-20 11:00:00 1950-01-21 11:00:00 1950-01-22 11:00:00 1950-01-23 11:00:00
1950-01-24 11:00:00 1950-01-25 11:00:00 1950-01-26 11:00:00 1950-01-27 11:00:00
1950-01-28 11:00:00 1950-01-29 11:00:00 1950-01-30 11:00:00 1950-01-31 11:00:00
..................................................................................
................................................................................
................................................................................
.................
2020-10-31 11:00:00 2020-11-01 11:00:00 2020-11-02 11:00:00 2020-11-03 11:00:00
2020-11-04 11:00:00 2020-11-05 11:00:00 2020-11-06 11:00:00 2020-11-07 11:00:00
2020-11-08 11:00:00 2020-11-09 11:00:00 2020-11-10 11:00:00 2020-11-11 11:00:00
2020-11-12 11:00:00 2020-11-13 11:00:00 2020-11-14 11:00:00 2020-11-15 11:00:00
2020-11-16 11:00:00 2020-11-17 11:00:00 2020-11-18 11:00:00 2020-11-19 11:00:00
2020-11-20 11:00:00 2020-11-21 11:00:00 2020-11-22 11:00:00 2020-11-23 11:00:00
2020-11-24 11:00:00 2020-11-25 11:00:00 2020-11-26 11:00:00 2020-11-27 11:00:00
2020-11-28 11:00:00 2020-11-29 11:00:00 2020-11-30 11:00:00 2020-12-31 23:00:00
cdo sinfo: Processed 1 variable over 25904 timesteps [6.03s 37MB
The result (daily mean) seemed very dubious to me (since in timestamp it has 11:00:00
). Therefore, I asked the same in the CDO forum and they suggested shifting back 1 min instead of 1 hour.
cdo daymean -shifttime,-1min d2m.nc d2m_wb.nc
Here, the timestamp (of d2m_wb.nc
) shows 12:00:00
instead of 11:00:00
. I was not sure whether the result is correct or not. So, I tried to cross-check this using the following script in python (3.8.5).
import xarray as xr
hourly_d2m = xr.open_dataset(r'E:\Data\Rda\d2m\d2m.nc')
d2m = hourly_d2m['d2m']
d2m= hourly_d2m.shift(time=-1).dropna(dim='time',how='all')
sds = d2m.resample(time='D').mean(dim='time')
sds.to_netcdf('E:\Data\Rda\d2m\daily\d2m_wb.nc')
There I got the 00:00:00
timestamp after calculating the daily mean of d2m_wb.nc
. Now, the question is different software and commands are producing different results of a common objective (i.e. daily mean).
I'm completely confused and looking for a suitable solution or clarification. Thank you.