2

I have a large number of NetCDF files from which I would like to extract a small number of variables for one location, and merge them into a new NetCDF file. The dimensions of the files are:

dimensions:
    time = 18 ;
    level = 65 ;
    levelh = 66 ;
    domain = 36 ;

I can subtract/merge the files for all domains with something like:

cdo select,name=u,v file1.nc file2.nc out.nc

But all other operators seem to be related to selections in space (e.g. sellonlatbox) or time (e.g. seltimestep), but I can't find a way to select only 1 domain from the NetCDF files. Is this possible with CDO's or NCO's?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Bart
  • 9,825
  • 5
  • 47
  • 73
  • Interesting question indeed. I assume cdo's are not meant for such tasks - conventional climate datasets have geographical spatial dimensions + record dimension, but I hope you'll get an answer. I included nco to the question, perhaps that community can also help. – msi_gerva Sep 26 '18 at 09:39
  • I originally tried this with Python (which was horribly slow), so a solution with `NCO` is also very welcome.. – Bart Sep 26 '18 at 10:05

1 Answers1

3

Not sure I fully understand the question/intent. NCO treats all dimensions equally. If you want domain #17 then try

ncrcat -v u,v -d domain,17 file1.nc file2.nc out.nc

If file1.nc and file2.nc are not sequential in a record coordinate then try

ncecat -v u,v -d domain,17 file1.nc file2.nc out.nc

ADDED 20180929:

or if you don't like that, and the files do not have a record dimension yet are time-sequential then before using ncrcat turn the temporal dimension into a record coordinate for each file with

ncks -O --mk_rec_dmn time file1.nc file1.nc
ncks -O --mk_rec_dmn time file2.nc file2.nc
...

etc. and proceed as above. That may be the best way forward with NCO.

Charlie Zender
  • 5,929
  • 14
  • 19
  • Thanks Charlie. The files are sequential in the time dimension, but that dim is not unlimited, so `ncrcat` seems to have difficulties in recognizing the concat dimension (which CDO somehow manages to do). NCO gives hints on how to fix this, but that would require changing a (very) large number of NetCDF files... Is it possible to tell `ncrcat` which dimension it should concat? `ncecat` does not work, it adds a dimension `record` to all variables except time, so I loose all time information except the times from the first file. – Bart Sep 28 '18 at 10:34