How to change julian_days to standard calendar?
Added by Fredrick AJ. almost 7 years ago
Hi Guys,
Is it possible now to change julian_days to standard calendar?
$ cdo sinfon data.nc
File format : NetCDF
-1 : Institut Source Steptype Levels Num Points Num Dtype : Parameter name
1 : unknown unknown constant 12752 1 900 1 F32 : prcp
Grid coordinates :
1 : lonlat : points=900 (30x30)
X : 37.625 to 39.075 by 0.05000003 degrees_east
Y : -5.275 to -3.825 by 0.04999971 degrees_north
Vertical coordinates :
1 : generic : levels=12752
T : 2444606 to 2457357 by 1 julian_day
cdo sinfon: Processed 1 variable ( 0.00s )
Replies (8)
RE: How to change julian_days to standard calendar? - Added by Karin Meier-Fleischer almost 7 years ago
Hi Frederick,
to my knowledge CDO do not support Julian calendar. Maybe you can use NCL or Python instead.
-Karin
RE: How to change julian_days to standard calendar? - Added by Fredrick AJ. almost 7 years ago
Hello Karin,
Thanks for the hint, do you have the NCL code for conversion?
Best regards
Fredrick
RE: How to change julian_days to standard calendar? - Added by Karin Meier-Fleischer almost 7 years ago
Sorry, but I don't have a script. Can you send me a test file with Julian calendar.
-Karin
RE: How to change julian_days to standard calendar? - Added by Fredrick AJ. almost 7 years ago
Thanks a lot karin,
I attach the data file. I was also wondering, since I know the given start/end julian days (2444606) and (2457357)are 1st jan 1985 and 30th nov. 2015 respectively, maybe, CDO settaxis can be used?
Also,my windows version does not allow me to install NCL, therefore, python code would be helpful but If you work-it-out with NCL, I will have to install it on another machine, which I have access..so no problem..
Thanks again
Fredrick
RE: How to change julian_days to standard calendar? - Added by Karin Meier-Fleischer almost 7 years ago
Hi Frederick,
setcalendar is working correct with the test data.
cdo setcalendar,standard data.nc outfile.nc
ncdump -h outfile.nc
netcdf oufile { dimensions: time = UNLIMITED ; // (1 currently) X = 30 ; Y = 30 ; T = 12752 ; variables: double time(time) ; time:standard_name = "time" ; time:units = "hours since 1-1-1 00:00:00" ; time:calendar = "standard" ; time:axis = "T" ; float X(X) ; X:standard_name = "longitude" ; X:long_name = "longitude" ; X:units = "degree_east" ; X:axis = "X" ; float Y(Y) ; Y:standard_name = "latitude" ; Y:long_name = "latitude" ; Y:units = "degree_north" ; Y:axis = "Y" ; float T(T) ; T:units = "julian_day" ; T:axis = "Z" ; T:pointwidth = 1.f ; T:gridtype = 0 ; float prcp(time, T, Y, X) ; prcp:standard_name = "lwe_precipitation_rate" ; prcp:long_name = "precipitation" ; prcp:units = "mm/day" ; prcp:_FillValue = -9999.f ; prcp:missing_value = -9999.f ; prcp:pointwidth = 1.f ; prcp:CE = 100.f ; prcp:CS = 0.f ; prcp:scale_min = 0.f ; prcp:maxncolor = 254 ; prcp:colormap = "[13882323 16777215 16777215 [16777184 6] [15453831 6] [16748574 14] [13434880 18] [4026644 24] [7451452 21] [9419919 43] [9234160 44] [6333684 41] [2237106 43] 2237106]" ; prcp:colorscalename = "prcp_dailyrate_max100_smooth" ; prcp:scale_max = 100.f ; prcp:ncolor = 254 ; // global attributes: :CDI = "Climate Data Interface version 1.9.2 (http://mpimet.mpg.de/cdi)" ; :Conventions = "CF-1.6" ; :history = "Thu Jun 07 11:55:54 2018: cdo setcalendar,standard data.nc ooo.nc" ; :CDO = "Climate Data Operators version 1.9.2 (http://mpimet.mpg.de/cdo)" ; }
-Karin
RE: How to change julian_days to standard calendar? - Added by Fredrick AJ. almost 7 years ago
Hi again Karin,
I actually tried this before but it seems it only output 1 time step.
dimensions:
time = UNLIMITED ; // (1 currently)
X = 30 ;
Y = 30 ;
T = 12752 ;
ie. time variable is created but has only 1 value. The original T variable with julian day units remains and has 12752 values.
not sure if am missing something..
Thanks
Fredrick
RE: How to change julian_days to standard calendar? - Added by Karin Meier-Fleischer almost 7 years ago
Jupp, I was too fast. The 'cdo info' shows in both cases a wrong time:
cdo info data.nc
-1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 0000-00-00 00:00:00 2.44461e+06 900 0 : 0.0000 0.0093669 2.9884 : -1 2 : 0000-00-00 00:00:00 2.44461e+06 900 0 : 0.0000 1.0977 8.6689 : -1 3 : 0000-00-00 00:00:00 2.44461e+06 900 0 : 0.0000 0.0000 0.0000 : -1
cdo info outfile.nc
-1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 0001-01-01 00:00:00 2.44461e+06 900 0 : 0.0000 0.0093669 2.9884 : -1 2 : 0001-01-01 00:00:00 2.44461e+06 900 0 : 0.0000 1.0977 8.6689 : -1 3 : 0001-01-01 00:00:00 2.44461e+06 900 0 : 0.0000 0.0000 0.0000 : -1
I'll see what I can do.
-Karin
RE: How to change julian_days to standard calendar? - Added by Karin Meier-Fleischer almost 7 years ago
With NCL you can convert the time of your file with the following script.
begin ;-- open file f = addfile("$HOME/CDO/Support/time/calendar/data.nc","r") ;-- read variable and time var = f->prcp ;-- read variable time = f->T ;-- read time ;-- set correct units of julian calendar time@units = "days since -4712-1-1 12:00" ;-- convert time to standard calendar; t1 = 2444606 is 1981-01-01 12:00 t = cd_convert( time, "days since 1981-01-01 12:00" ) ;-- define a correct time coordinate variable t!0 = "time" t&time = t t@units = t@units t@standard_name = "time" t@long_name = "time" t@calendar = "standard" t@axis = "T" ;-- overwrite time of variable var&T := t ;-- create new netCDF file and write variable and its associated dimension variables to file system("rm -rf prcp_julian_calendar.nc") ;-- delete file if existing outf = addfile("prcp_julian_calendar.nc","c") ;-- create file outf->prcp = var ;-- write var to file end
cdo sinfon prcp_julian_calendar.nc
File format : NetCDF -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v instant 1 1 900 1 F32 : prcp Grid coordinates : 1 : lonlat : points=900 (30x30) X : 37.625 to 39.075 by 0.05000003 degree_east Y : -5.275 to -3.825 by 0.04999999 degree_north Vertical coordinates : 1 : surface : levels=1 Time coordinate : 12752 steps RefTime = 1981-01-01 12:00:00 Units = days Calendar = standard YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 1981-01-01 12:00:00 1981-01-02 12:00:00 1981-01-03 12:00:00 1981-01-04 12:00:00 1981-01-05 12:00:00 1981-01-06 12:00:00 1981-01-07 12:00:00 1981-01-08 12:00:00 1981-01-09 12:00:00 1981-01-10 12:00:00 1981-01-11 12:00:00 1981-01-12 12:00:00 1981-01-13 12:00:00 1981-01-14 12:00:00 1981-01-15 12:00:00 1981-01-16 12:00:00 1981-01-17 12:00:00 1981-01-18 12:00:00 1981-01-19 12:00:00 1981-01-20 12:00:00 1981-01-21 12:00:00 1981-01-22 12:00:00 1981-01-23 12:00:00 1981-01-24 12:00:00 1981-01-25 12:00:00 1981-01-26 12:00:00 1981-01-27 12:00:00 1981-01-28 12:00:00 1981-01-29 12:00:00 1981-01-30 12:00:00 1981-01-31 12:00:00 1981-02-01 12:00:00 1981-02-02 12:00:00 1981-02-03 12:00:00 1981-02-04 12:00:00 1981-02-05 12:00:00 1981-02-06 12:00:00 1981-02-07 12:00:00 1981-02-08 12:00:00 1981-02-09 12:00:00 1981-02-10 12:00:00 1981-02-11 12:00:00 1981-02-12 12:00:00 1981-02-13 12:00:00 1981-02-14 12:00:00 1981-02-15 12:00:00 1981-02-16 12:00:00 1981-02-17 12:00:00 1981-02-18 12:00:00 1981-02-19 12:00:00 1981-02-20 12:00:00 1981-02-21 12:00:00 1981-02-22 12:00:00 1981-02-23 12:00:00 1981-02-24 12:00:00 1981-02-25 12:00:00 1981-02-26 12:00:00 1981-02-27 12:00:00 1981-02-28 12:00:00 1981-03-01 12:00:00 ................................................................................ ................................................................................ ................................................................................ .... 2015-10-02 12:00:00 2015-10-03 12:00:00 2015-10-04 12:00:00 2015-10-05 12:00:00 2015-10-06 12:00:00 2015-10-07 12:00:00 2015-10-08 12:00:00 2015-10-09 12:00:00 2015-10-10 12:00:00 2015-10-11 12:00:00 2015-10-12 12:00:00 2015-10-13 12:00:00 2015-10-14 12:00:00 2015-10-15 12:00:00 2015-10-16 12:00:00 2015-10-17 12:00:00 2015-10-18 12:00:00 2015-10-19 12:00:00 2015-10-20 12:00:00 2015-10-21 12:00:00 2015-10-22 12:00:00 2015-10-23 12:00:00 2015-10-24 12:00:00 2015-10-25 12:00:00 2015-10-26 12:00:00 2015-10-27 12:00:00 2015-10-28 12:00:00 2015-10-29 12:00:00 2015-10-30 12:00:00 2015-10-31 12:00:00 2015-11-01 12:00:00 2015-11-02 12:00:00 2015-11-03 12:00:00 2015-11-04 12:00:00 2015-11-05 12:00:00 2015-11-06 12:00:00 2015-11-07 12:00:00 2015-11-08 12:00:00 2015-11-09 12:00:00 2015-11-10 12:00:00 2015-11-11 12:00:00 2015-11-12 12:00:00 2015-11-13 12:00:00 2015-11-14 12:00:00 2015-11-15 12:00:00 2015-11-16 12:00:00 2015-11-17 12:00:00 2015-11-18 12:00:00 2015-11-19 12:00:00 2015-11-20 12:00:00 2015-11-21 12:00:00 2015-11-22 12:00:00 2015-11-23 12:00:00 2015-11-24 12:00:00 2015-11-25 12:00:00 2015-11-26 12:00:00 2015-11-27 12:00:00 2015-11-28 12:00:00 2015-11-29 12:00:00 2015-11-30 12:00:00 cdo sinfon: Processed 1 variable over 12752 timesteps ( 0.02s 23MB )
-Karin