Goose_08
Goose_08

Reputation: 31

Concatenate netcdf files with different variables - using nco

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.

Upvotes: 3

Views: 5096

Answers (3)

Mike T
Mike T

Reputation: 43642

You can only append one variable at at time, so -A *.nc is invalid.

If you have var1.nc, var2.nc, var3.nc with common dimensions and sizes, try:

cp var1.nc out.nc
ncks -h -A var2.nc out.nc
ncks -h -A var3.nc out.nc
# repeat as needed

This will combine them into one out.nc file, leaving the original files unmodified.

Upvotes: 3

ClimateUnboxed
ClimateUnboxed

Reputation: 8077

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.

Upvotes: 5

Charlie Zender
Charlie Zender

Reputation: 6322

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.

Upvotes: 5

Related Questions