Project

General

Profile

replace multi-year daily file with one year

Added by oliver david over 6 years ago

dear all,

I have a multi-year netCDF file of daily data and I would like to generate a file which includes only the first year of daily data looping over the full (retained) time axis of the multi-year input file. Is this possible in CDO?

thanks for the help!


Replies (3)

RE: replace multi-year daily file with one year - Added by Karin Meier-Fleischer over 6 years ago

Hi Oliver,

I'm not sure what you want to do. Do you want to create a file which contains only the first year and the data is copied to all time steps "full (retained) time axis"? Each time step contains the same data?

-Karin

RE: replace multi-year daily file with one year - Added by oliver david over 6 years ago

Hi Karin
Thanks for the reply. Yes I want to create a file of the same time length and axis as the input file but which has the first year of daily data repeating. i.e. a repeating annual cycle of daily data (rather than each daily timestep containing the same data). I experimented with using cdo duplicate and settaxis but haven't managed it yet. Since I have to do this for multiple datasets it would be great to use CDO.
Any help very welcome!
thanks
Oliver

RE: replace multi-year daily file with one year - Added by Karin Meier-Fleischer over 6 years ago

Hi Oliver,

you can do this with a little trick in doing so

- select first timestep

  cdo -f nc -seltimestep,1 infile tmp_1t.nc

- set the data of the variable you want (here tas) to value 1 and multiply it with the first timestep

  cdo -mul tmp_1t.nc -expr,'tas=1' infile outfile

The multiplication of the single timestep will cause a fill up by copying the first timestep to all other timesteps.

-Karin

    (1-3/3)