Project

General

Profile

Chaining in Python

Added by Alexander Koutsouris almost 6 years ago

Hi,

I'm trying to chain two operations (sellonlatbox and selyear) but fail to make the code work.

I've written it as:

cdo.sellonlatbox('20,30,70,80', input = '-selyear,2010' + 'ifile.nc', output = 'output.nc')

I get the error message "Too few streams specified! Operator -selyear,2030ifile.nc needs 1 input and 1 output streams.

So it seems as the '+' sign joins the two strings into one, but I don't know how it should be written to be interpreted correctly.

Best
-Alex


Replies (2)

RE: Chaining in Python - Added by Karin Meier-Fleischer almost 6 years ago

Hi Alex,

there is a blank missing bwteen 2010 and ifile.nc:

cdo.sellonlatbox('20,30,70,80', input = '-selyear,2010 ' + 'ifile.nc', output = 'output.nc')

If the input file name is known you don't need to concatenate the two parts:

cdo.sellonlatbox('20,30,70,80', input = '-selyear,2010 ifile.nc', output = 'output.nc')

If you use a variable for the input file:

ifile = my_inputfile.nc
cdo.sellonlatbox('20,30,70,80', input = '-selyear,2010 '+ ifile, output = 'output.nc')

-Karin

RE: Chaining in Python - Added by Ralf Mueller almost 6 years ago

if you set

cdo.debug = True
the underlying CDO calls will be printed. Things like missing spaces should be easy to find then.

hth
ralf

    (1-2/2)