3

I downloaded a netcdf file containing 4-5 variables but it has only 2 dimensions (lat and lon). Time is missing and this does not allow me to merge timesteps or do anything useful.

Is there any way to fix this hopefully by using CDO?

there are 100 netcdf files (without time dimension) and I want to merge them using time as the main variable for merging.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Theo Eurotrip
  • 41
  • 1
  • 3

2 Answers2

4

You can use command:

ncecat -O -u time in.nc out.nc

to create a new time dimension from scratch.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Ales
  • 495
  • 3
  • 11
4

Let me expound a bit on the answer by @Ales --

ncecat is a command-line function in the NCO package that concatenates multiple netcdf files lacking a record (oftentimes "Time") dimension. The concatenated file will have a new record dimension, by default it is 'record'.

Let's say you have a list of netcdf files such as A.nc, B.nc, and C.nc, all with the dimensions lat x lon. You can concatenate them using ncecat A.nc B.nc C.nc -O new_file.nc. new_file.nc will have dimensions record x lat x lon, where record will have a size of 3 (the number of files you concatenated). The -O option is not necessary, but will explicitly create (and overwrite) the file new_file.nc...or whatever you want to call it.

N1B4
  • 3,377
  • 1
  • 21
  • 24