Wrong time axis when converting from GRIB to netCDF
Added by Joakim Kjellsson about 7 years ago
Hi
I've got some output from the OpenIFS model, in grib format. The output is mixed grib1/grib2, but I've used grib_set -s editionNumber=1 to convert all to grib1.
When I use CDO to convert from spectral to grid-point space, and from grib to netcdf, I sometimes don't get the right time axis. It works for 95% of the files, but not for some, and I have no idea why.
I'm enclosing the two grib files "wrong_time.grb" and "right_time.grb". They are outputs from hours 3066 and 3072 (i.e. 127 days 18hours and 128 days into the run).
If I do
cdo -t ecmwf -f nc sp2gpl right_time.grb right_time.nc ncdump -v time right_time.nc
I see that the time is 3066 hours since 1982-01-01, which is correct.
However, if I do
cdo -t ecmwf -f nc sp2gpl wrong_time.grb wrong_time.nc ncdump -v time wrong_time.nc
I find that it's 128 days since 1982-01-01, which is correct, but why is CDO listing time in units "days since 1982-01-01" in this file, but in almost all other files it has units "hours since 1982-01-01"?
Is there a setting that I'm missing?
I've tried with CDO version 1.9.2 on our cluster and version 1.9.0 on my laptop with the same results.
Best wishes
Joakim
right_time.grb (13.9 MB) right_time.grb | |||
wrong_time.grb (13.9 MB) wrong_time.grb | |||
right_time.nc (53.9 MB) right_time.nc | |||
wrong_time.nc (53.9 MB) wrong_time.nc |
Replies (2)
RE: Wrong time axis when converting from GRIB to netCDF - Added by Karin Meier-Fleischer about 7 years ago
Hi Joakim,
the GRIB files have different reference time units.
cdo sinfo right_time.grb
File format : GRIB -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID 1 : ECMWF unknown v instant 1 1 25760 1 P16 : 152.128 2 : ECMWF unknown v instant 91 2 25760 1 P16 : 131.128 3 : ECMWF unknown v instant 91 2 25760 1 P16 : 132.128 4 : ECMWF unknown v instant 91 2 25760 1 P16 : 130.128 5 : ECMWF unknown v instant 1 3 25760 1 P16 : 152.128 6 : ECMWF unknown v instant 1 3 25760 1 P16 : 129.128 Grid coordinates : 1 : spectral : points=25760 nsp=12880 truncation=159 complexPacking Vertical coordinates : 1 : pressure : levels=1 plev : 100000 2 : hybrid : levels=91 lev : 1 to 91 by 1 available : vct 3 : hybrid : levels=1 lev : 1 available : vct Time coordinate : 1 step RefTime = 1982-01-01 00:00:00 Units = hours Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 1982-05-08 18:00:00 cdo sinfo: Processed 6 variables over 1 timestep ( 0.01s 13MB )
Have a look at the line: RefTime = 1982-01-01 00:00:00 Units = hours Calendar = proleptic_gregorian
cdo sinfo wrong_time.grb
File format : GRIB -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID 1 : ECMWF unknown v instant 1 1 25760 1 P16 : 152.128 2 : ECMWF unknown v instant 91 2 25760 1 P16 : 131.128 3 : ECMWF unknown v instant 91 2 25760 1 P16 : 132.128 4 : ECMWF unknown v instant 91 2 25760 1 P16 : 130.128 5 : ECMWF unknown v instant 1 3 25760 1 P16 : 152.128 6 : ECMWF unknown v instant 1 3 25760 1 P16 : 129.128 Grid coordinates : 1 : spectral : points=25760 nsp=12880 truncation=159 complexPacking Vertical coordinates : 1 : pressure : levels=1 plev : 100000 2 : hybrid : levels=91 lev : 1 to 91 by 1 available : vct 3 : hybrid : levels=1 lev : 1 available : vct Time coordinate : 1 step RefTime = 1982-01-01 00:00:00 Units = days Calendar = proleptic_gregorian YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 1982-05-09 00:00:00 cdo sinfo: Processed 6 variables over 1 timestep ( 0.01s 13MB )
Have a look at the line: RefTime = 1982-01-01 00:00:00 Units = days Calendar = proleptic_gregorian
You can change the reference time unit with the settaxis operator. E.g.
cdo -settaxis,1982-01-01,00:00:00,1hour wrong_time.grb ex_wrong_time.grb
-Karin
RE: Wrong time axis when converting from GRIB to netCDF - Added by Joakim Kjellsson about 7 years ago
Dear Karin
Thanks for your reply, and for locating the issue in the GRIB files.
The fix you posted did not work for me, but I found something similar that does:
cdo -settunits,hours wrong_time.grb ex_wrong_time.grb
This converts 128 days since 1982-01-01 to 3072 hours since 1982-01-01. Heureka!
Thanks for your help!
/Joakim