Project

General

Profile

issue with settaxis

Added by Ivana Cvijanovic 5 months ago

Hi,

I am dealing with a set of .nc files that were converted from the satellite data and are a bit 'unstandard' and I am not able to set the date and time axis.

Here is a brief description of one of them:

netcdf SMDI_Weekly_ESACCI-SOILMOISTURE-L3S-SSMV-COMBINED-20221231000000-fv08.1 {
dimensions:
time = 1 ;
lat = 96 ;
lon = 216 ;
variables:
float time(time) ;
time:_FillValue = -9999.f ;
float lat(lat) ;
lat:_FillValue = -9999.f ;
float lon(lon) ;
lon:_FillValue = -9999.f ;
float SMDI ;
SMDI:_FillValue = -9999.f ;
data:

time = 19351 ;
lat = 49.875, 49.625, 49.375, 49.125, 48.875, 48.625, 48.375, 48.125, 
47.875, 47.625, 47.375, 47.125, 46.875, 46.625, 46.375, 46.125, 45.875,
45.625, 45.375, 45.125, 44.875, 44.625, 44.375, 44.125, 43.875, 43.625,
....

As you can see time is both dimension and variable and for each file it is set to a certain value (with increment of 1). When I concatenate all the files from one year (I have weekly files), I get something like this:

netcdf test {
dimensions:
time = UNLIMITED ; // (53 currently)
lon = 216 ;
lat = 96 ;
variables:
float time(time) ;
time:standard_name = "time" ;
time:calendar = "proleptic_gregorian" ;
time:axis = "T" ;
time:units = "day as %Y%m%d.%f" ;
float lon(lon) ;
lon:axis = "X" ;
float lat(lat) ;
lat:axis = "Y" ;
float SMDI ;
SMDI:_FillValue = -9999.f ;
SMDI:missing_value = -9999.f ;

..........

time = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0 ;

lon = -11.875, -11.625, -11.375, -11.125, -10.875, -10.625, -10.375, 
....

with the values of time variable becoming zeros.

If I try to do cdo settaxis,2022-01-01,00:00:00,7day test.nc test1.nc, the time values become:

time = 2.02201e+07, 2.022011e+07, 2.022012e+07, 2.022012e+07, 2.022013e+07, 
2.02202e+07, 2.022021e+07, 2.022022e+07, 2.022023e+07, 2.02203e+07,
2.022031e+07, 2.022032e+07, 2.022033e+07, 2.02204e+07, 2.022041e+07,
2.022042e+07, 2.022042e+07, 2.022043e+07, 2.022051e+07, 2.022051e+07,
2.022052e+07, 2.022053e+07, 2.02206e+07, 2.022061e+07, 2.022062e+07,
2.022062e+07, 2.02207e+07, 2.022071e+07, 2.022072e+07, 2.022072e+07,
2.022073e+07, 2.022081e+07, 2.022081e+07, 2.022082e+07, 2.022083e+07,
2.02209e+07, 2.022091e+07, 2.022092e+07, 2.022092e+07, 2.0221e+07,
2.022101e+07, 2.022102e+07, 2.022102e+07, 2.022103e+07, 2.02211e+07,
2.022111e+07, 2.022112e+07, 2.022113e+07, 2.02212e+07, 2.022121e+07,
2.022122e+07, 2.022122e+07, 2.022123e+07 ;

and the dates are not incremented by 7 dates nor they start on 2022-01-01:

cdi warning (split_timevalue): Reset wrong date/time to 2022-12-01 00:00:00!
File format : NetCDF4
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name
1 : unknown unknown v instant 1 1 20736 1 F32 : SMDI
Grid coordinates :
1 : generic : points=20736 (216x96)
lon : -11.875 to 41.875 by 0.25
lat : 49.875 to 26.125 by -0.25
Vertical coordinates :
1 : surface : levels=1
Time coordinate :
time : 53 steps
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
2022-01-00 00:00:00 2022-01-08 00:00:00 2022-01-16 00:00:00 2022-01-22 00:00:00
2022-01-28 00:00:00 2022-02-04 00:00:00 2022-02-12 00:00:00 2022-02-20 00:00:00
2022-02-26 00:00:00 2022-03-04 00:00:00 2022-03-12 00:00:00 2022-03-20 00:00:00
2022-03-26 00:00:00 2022-04-02 00:00:00 2022-04-08 00:00:00 2022-04-16 00:00:00
2022-04-24 00:00:00 2022-04-30 00:00:00 2022-05-08 00:00:00 2022-05-14 00:00:00
2022-05-20 00:00:00 2022-05-28 00:00:00 2022-06-04 00:00:00 2022-06-12 00:00:00
2022-06-18 00:00:00 2022-06-24 00:00:00 2022-07-02 00:00:00 2022-07-08 00:00:00
2022-07-16 00:00:00 2022-07-24 00:00:00 2022-07-30 00:00:00 2022-08-06 00:00:00
2022-08-12 00:00:00 2022-08-20 00:00:00 2022-08-28 00:00:00 2022-09-04 00:00:00
2022-09-10 00:00:00 2022-09-16 00:00:00 2022-09-24 00:00:00 2022-10-00 00:00:00
2022-10-08 00:00:00 2022-10-16 00:00:00 2022-10-22 00:00:00 2022-10-28 00:00:00
2022-11-04 00:00:00 2022-11-12 00:00:00 2022-11-20 00:00:00 2022-11-26 00:00:00
2022-12-04 00:00:00 2022-12-10 00:00:00 2022-12-16 00:00:00 2022-12-24 00:00:00
2022-12-01 00:00:00
cdo sinfon: Processed 1 variable over 53 timesteps [0.01s 19MB]

Note the warning : cdi warning (split_timevalue): Reset wrong date/time to 2022-12-01 00:00:00!

Do you have any advice how I could resolve this? I need to set the time axis correctly in order to be able to further manipulate the data. I am thinking it has to do with time being a variable but I have no idea how to change that.

Many thanks!

Ivana


Replies (2)

RE: issue with settaxis - Added by Estanislao Gavilan 4 months ago

Hi Ivana,

I think you are having that error because of the unit attributes of your time axis. Over there you can read

time:units = "day as %Y%m%d.%f"

that means that your time is absolute, thus no hours, minutes etc..

You need to convert it to relative time

cdo -r -settaxis,2022-01-01,00:00:00,7days test.nc test1.nc.

You can even change the reference time in your unit attributes with setreftime

RE: issue with settaxis - Added by Ivana Cvijanovic 4 months ago

Thank you very much Estanislao, that worked!

    (1-2/2)