Hemraj Bhattarai
Hemraj Bhattarai

Reputation: 41

How to add variable from nc1 to nc2 file without deleting/removing the variables in nc2?

I have two kinds of variables in two different nc files. The dimension and other things are same, I just have to add one more variable in the existing nc file, How can I do this (using CDO or R or any other)

I used the command line (cdo selvar,varname in.nc out.nc) but it doesn't help. This command does work but deletes the existing variables. Any suggestions on how can I add new variables without deleting the variable inside the nc file? Many thanks.

Upvotes: 4

Views: 3182

Answers (2)

ClimateUnboxed
ClimateUnboxed

Reputation: 8077

From your comment of clarification, I think the cdo command you need is cat

cdo cat aaa.nc bbb.nc output.nc 

This will concatenate the fields in bbb.nc to the ones in aaa.nc and put the result in output.nc

Upvotes: 3

Charlie Zender
Charlie Zender

Reputation: 6322

The NCO solution is

ncks -A -v yyy bbb.nc aaa.nc

as documented here.

Upvotes: 6

Related Questions