Search code examples
netcdfcdo-climate

netcdf - CDO monmean


I have a netcdf file, with a daily time step, that I wish to convert to a monthly time step. The time is formatted as follow:

    double time(time) ;
            time:standard_name = "time" ;
            time:long_name = "time" ;
            time:bounds = "time_bnds" ;
            time:units = "days since 2000-01-01" ;
            time:calendar = "standard" ;
            time:axis = "T" ;

When I convert to monthly time step using the command:

cdo monmean input.nc output.nc

Everything works fine except that the time output is strange:

 time = "2000-01-16", "2000-02-15", "2000-03-16", "2000-04-15 12",
"2000-05-16", "2000-06-15 12", "2000-07-16", "2000-08-16",
"2000-09-15 12", "2000-10-16", "2000-11-15 12", "2000-12-16";

I wish to replace the day on the monthly value by the first day of the month and also remove those odd 12's for the time that appear. The desired output:

 time = "2000-01-01", "2000-02-01", "2000-03-01", "2000-04-01",
"2000-05-01", "2000-06-01", "2000-07-01", "2000-08-01",
"2000-09-01", "2000-10-01", "2000-11-01", "2000-12-01";

Any hints is appreciate


Solution

  • cdo --timestat_date first monmean input.nc output.nc
    

    works for me, I hope it's helpful! It places the timestamp at the first step of the averaging period, whereas the default is in the middle. (There is also a --timestat_date last if one want to do the opposite and put it at the last step of the window)