2

I want to concatenate two sets of netcdf files using nco, where each set has about 30 files.

Set 1 contains: longitude, latitude, time and v.

Set 2 contains: longitude, latitude, time and u.

I have tried:

ncks *.nc out.nc    

but I get:

Error received 97 filenames; need no more than two

then I tried:

ncks -A *.nc out.nc

but the error persists:

Error received 97 filenames; need no more than two

Please can you point me in the right direction, I am quite new to this.

Thanks in advance.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Goose_08
  • 23
  • 1
  • 6

2 Answers2

3

Your first try should work if you use ncrcat instead of ncks:

ncrcat *.nc out.nc

And be careful that your wildcard expression evaluates to the files you intend, i.e., that ls *.nc results in all input files and nothing else.

Charlie Zender
  • 5,929
  • 14
  • 19
  • My apologies for only getting back to you now @Charlie Zender, but I have been out of office. There seems to be a problem with the data on my side, so I will accept this answer. – Goose_08 Oct 03 '19 at 05:04
  • This would work on each set separately but not with a mixture of them. Attempt to merge files with different variables leads to ERROR: nco_inq_varid() reports requested variable "XXX" is not defined in file – Roux Jan 13 '21 at 16:37
3

As an alternative you can also use Climate Data Operators (CDO):

cdo cat *.nc out.nc

assuming all files are on the same grid and times.

Luke Davis
  • 2,548
  • 2
  • 21
  • 43
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86