Project

General

Profile

cdo selvar with multiple input files

Added by Stefan Muthers over 8 years ago

Hello,

is it possible to select a variable from multiple input files with cdo, similar to the 'ncrcat -v var1 *.nc out.nc' command?

thank you and best regards,
stefan


Replies (5)

RE: cdo selvar with multiple input files - Added by Uwe Schulzweida over 8 years ago

yes of course, but this feature is still not documented. The name of this powerful operator is select. Use the parameter 'name=' to select variables by name:

cdo select,name=var1,var2,...,varN ifiles ofile

As all CDO operators with an unlimited number of input files this operator can't be combined with other operators.
This operator is still under construction, so please use the latest CDO version.
Your feedback is very welcome.

Best regards,
Uwe

RE: cdo selvar with multiple input files - Added by Stefan Muthers over 8 years ago

wonderful! thank you for the fast response.

best regards,
stefan

RE: cdo selvar with multiple input files - Added by Stefan Muthers over 8 years ago

The combination of select with other operations produces unexpected results.

See the following example:

  • input files are daily values (grb format) with multiple variables per file
  • output should be a file with monthly mean values of a single variable

$ cdo select,name=t -monmean echam5_160001.grb echam5_160002.grb test.nc
cdo select: Started child process "monmean ../1600-ohne/outdata/echam5/1600-ohne_echam5_160001.grb (pipe1.1)".
cdo(2) monmean: Processed 29623680 values from 111 variables over 30 timesteps. ( 0.36s )
cdo select: Processed 601920 values from 222 variables over 30 timesteps. ( 0.48s )

The output already show it, monthly means are only calculated for the first input file.

$ cdo showdate test.nc
1600-01-31 1600-02-01 1600-02-02 1600-02-03 1600-02-04 1600-02-05 1600-02-06 1600-02-07 1600-02-08 1600-02-09 1600-02-10 1600-02-11 1600-02-12 1600-02-13 1600-02-14 1600-02-15 1600-02-16 1600-02-17 1600-02-18 1600-02-19 1600-02-20 1600-02-21 1600-02-22 1600-02-23 1600-02-24 1600-02-25 1600-02-26 1600-02-27 1600-02-28 1600-02-29
cdo showdate: Processed 1 variable over 30 timesteps. ( 0.00s )

I think this is a bug, should a open a new issue?

best regards,
stefan

RE: cdo selvar with multiple input files - Added by Uwe Schulzweida over 8 years ago

PLEASE NOTE: As all CDO operators with an unlimited number of input files this operator can't be combined with other operators.

RE: cdo selvar with multiple input files - Added by Stefan Muthers over 8 years ago

ok. Isn't it possible to interrupt the execution of this command in this case, the same way it is done when an operator that expects one input stream is executed with multiple input files:

Error (cdo sellevel) : Too many streams! Operator needs 1 input and 1 output streams.

(Or at least raise a warning)

Otherwise the user assumes that everything went fine.

Thanks you and best regards,
stefan

    (1-5/5)