I would like to append multiple files in both time (record dimension) and a coordinate "lead" for the same variable (var).
Q1) To implment this with NCO, Is there any recommneded solution? For example by concatenating the time or by appending the lead coordinate as the first step?
Q2) I have tried to append the files at first step. To so do,lead" coordinate was not exist in the original file. I create it with 'defdim' and it ranges from 1 to 4. The question is what should be the initial size of "lead" array to be appended correctly and what is the correct command to do so?
I tried both ways (a) and (b) and non of them worked out after appending.
(a) By defining an array of size=4, initialising elements for each file and then append them
ncap2 -s 'defdim("lead",4);lead[lead]={1,0,0,0};pre[$time,$lead]=tp' -O in_file1.nc out_file1.nc
ncap2 -s 'defdim("lead",4);lead[lead]={0,2,0,0};pre[$time,$lead]=tp' -O in_file2.nc out_file2.nc
.
.
File 1
dimensions:
lead = 4 ;
time = UNLIMITED ; // (1 currently)
variables:
int lead(lead) ;
float var(time, lead) ;
pre:cell_methods = "lat, lon: mean" ;
double time(time) ;
File 2
dimensions:
lead = 4 ;
time = UNLIMITED ; // (1 currently)
variables:
int lead(lead) ;
float var(time, lead) ;
var:cell_methods = "lat, lon: mean" ;
double time(time) ;
(b) By defining an array of size=1, then augmenting the size by appending
ncap2 -s 'defdim("lead",1);lead[lead]=[1];var[$time,$lead]=var_old' -O in.nc out.nc
File 1
dimensions:
lead = 1 ;
time = UNLIMITED ; // (1 currently)
variables:
int lead(lead) ;
float var(time, lead) ;
var:cell_methods = "lat, lon: mean" ;
double time(time) ;
File 2
dimensions:
lead = 1 ;
time = UNLIMITED ; // (1 currently)
variables:
int lead(lead) ;
float var(time, lead) ;
var:cell_methods = "lat, lon: mean" ;
double time(time) ;
I do not really understand the desired outcome. I think you mean
concatenate
when you sayappend
, BTW. Any one single coordinate can be concatenated at a time. It must be the lead dimension, and all the other dimensions must be the same size across the files.