Project

General

Profile

cdo settaxis and shifttime

Added by Antonia Di Maio over 10 years ago

Hi to everyone
I have a netcdf file with following date and time: 2013-05-31 2013-06-01 23:00 00:00 01:00 02:00 03:00 04:00 05:00 06:00

I want change it in 2013-06-01 00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 i.e I want shift time of 1 hour
The comand shifttime, the comand settaxis gives as output "Errore di segmentazione"
I just can change the date but not to shift the hours

Please,help. How can I do?
thanks


Replies (4)

RE: cdo settaxis and shifttime - Added by Uwe Schulzweida over 10 years ago

Dear Antonia,

The CDO command to shift the time axis by one hour is:

cdo shifttime,1hour ifile ofile
If this does not work this is a bug and we need your input file and the CDO version number (cdo -V) to solve this problem.

Cheers,
Uwe

RE: cdo settaxis and shifttime - Added by Miles Sowden over 4 years ago

Uwe,
I'm trying to find the change over the past hour. I tried

cdo -sub infile.nc -shifttime,-1hour infile.nc deltahr.nc

the shift part is working fine but it is matching record 1 with record 1 in the shifted file and making a file full of zeros.
It should ignore the first hour (unmatched data) show the differences then ignore the last hour (unmatched data) for each field.

Suggestions?
Thanks

RE: cdo settaxis and shifttime - Added by Uwe Schulzweida over 4 years ago

shifttime changes only the time information and not the data.

If the time step of your data is 1 hour, then you can select the data with seltimestep. Here is an example for a dataset with 60 timesteps:

cdo sub -seltimestep,2/60 infile.nc -seltimestep,1/59 infile.nc  deltahr.nc
Or try the undocumented operator deltat:
cdo deltat infile.nc  deltahr.nc

RE: cdo settaxis and shifttime - Added by Miles Sowden over 4 years ago

Thanks Uwe,

deltat was what I was after. Works perfectly but I had to first update to the latest cdo version (1.7 -> 1.9)

I updated by following the minicoda instructions found at https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda

I have 6 timesteps an hour, 142 per day (2 are skipped for calibration) and four days in one file. I will try derivations of the seltimestep above but I think I will use.

cdo deltat -hourmean infile.nc dhr.nc

Cheers
Miles

    (1-4/4)