Project

General

Profile

cdo in python error: too many files open

Added by Victoria Naipal about 10 years ago

Hi,
I am using cdo with python.
I am trying to get a fldsum for every single file and put that in an array,
so that I will be able to plot a timeseries of that fldsum.
The problem is now I iterate over several netcdf files but I don't know how to close them afterwards.
I have something like this:

fname = ...
numbers = range(100000)
fldsum = []
for k in range(len(numbers)):
ifile = '%s%05i.nc' (fname,numbers[k])
fldsum.append(cdo.fldsum(input=ifile,returnArray='m'))


Replies (1)

RE: cdo in python error: too many files open - Added by Ralf Mueller about 10 years ago

Why closing them manually? do you get any errors?

cdo.fldsum(input=ifile,returnArray='m')

creates tempfiles, which are removed, when the script is finished - or that's what it should do.

cheers
ralf

    (1-1/1)