Project

General

Profile

How to cange time dimension when making a new netCDF file?

Added by Eleanor Percy-Rouhaud over 1 year ago

I have an empty .nc , called 'frame.nc', which I use as a structure to fill up with various operations, like mergegrid and such. Right now, I need to merge some files into this frame file spatially, while preserving the time dimension, which has 299 time steps. To make a new frame file with a time dimension, i do:
``` cdo -b F64 -setreftime,1981-01-01,00:00:00 -setcalendar,gregorian -settaxis,1981-01-01,00:00:00,1mon -copy frame0.nc frame-time.nc ``` . which works to generate the frame-time.nc file, with the following specs (from ncdump):

```dimensions:
time = UNLIMITED ; // (1 currently)
lon = 1440 ;
lat = 720 ;
variables:
double time(time) ;
time:standard_name = "time" ;
time:units = "hours since 1981-1-1 00:00:00" ;
time:calendar = "gregorian" ;
time:axis = "T" ;
float lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
float lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
double frame(time, lat, lon) ;
frame:_FillValue = 3.32999990352581e+33 ;
frame:missing_value = 3.32999990352581e+33 ;

```

So now the problem is, when I do (pseudo code here) ```cdo mergegrid frame ghf output``` , I get in the log file: ```cdo mergegrid: Processed 1047168 values from 2 variables over 2 timesteps [0.06s 29MB].``` - but it should be over 300 time steps , as far as i understand it, to preserve the time steps. When I plot the resulting data, I get a map as expected, but only for one timestep - not 299.

Ive tried with NCO, since Ive read on other forums that this is how to do it - i tried: ```ncks --mk_rec_dmn time=299 frame-time.nc```, but, even though i have nco installed, it throws a 'command not found' error for nco.

so - is there anyway to change the time dimension in my frame-time.nc file to from time=1 to time = 299, using cdo?

Let me know if something wasnt clear! I tried to be a detailed but concise as possible. :)


Replies (1)

RE: How to cange time dimension when making a new netCDF file? - Added by Karin Meier-Fleischer over 1 year ago

Hi Eleanor,

I would use Python to do this. But maybe we can help if you provide the files.

    (1-1/1)