Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 258
Hemraj Bhattarai Avatar asked Oct 20 '25 09:10

Hemraj Bhattarai


2 Answers

The NCO solution is

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

as documented here.

like image 107
Charlie Zender Avatar answered Oct 22 '25 03:10

Charlie Zender


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

like image 36
Adrian Tompkins Avatar answered Oct 22 '25 03:10

Adrian Tompkins