Error creating temporary file until additional options specified
Added by XR Chua over 1 year ago
I was trying to create an example file with cdo.const but found that additional inputs (e.g. specifying the file type) was required for it to be saved into a netcdf file. Not sure if it is a bug, but documenting it here in any case.
```
from cdo import Cdo
cdo = Cdo()
cdo.const("1,r240x120")
<cdo.Cdo.__getattr__.<locals>.Operator object at 0x14e907373d00>
cdo.const("1,r240x120",options=" -f nc")
'/tmp/cdoPyqxnw8d9q'
```
This is from version 1.5.7 of the bindings and v2.1.1 of CDO.
Replies (4)
RE: Error creating temporary file until additional options specified - Added by Ralf Mueller over 1 year ago
hi Chua!
this is normal behaviour
cdo.const("1,r240x120",options=" -f nc")does not provide any output file name. Hence the library creates a temporary file to save the data and returns that filename.
What did you expect to get as a return value from that call?
cheers
ralf
RE: Error creating temporary file until additional options specified - Added by XR Chua over 1 year ago
Hi Ralf,
I agree that cdo.const("1,r240x120",options=" -f nc")
performs as expected.
What surprised me was that cdo.const("1,r240x120")
does not produce a path to a file.
RE: Error creating temporary file until additional options specified - Added by Ralf Mueller over 1 year ago
ah - you are perfectly right. This is behaviour is not correct - thx a lot for the report!
The reason is, that the python bindings support different syntax for chaining operators:
cdo.fldmean(input=' -copy,1,10x10')
cdo.fldmean.const('1,10x10').run()
I personally find that counter-intuitiv, because fldmean is called first in python but called last on the command execution.
But for now this needs a fix.
cheers
ralf
RE: Error creating temporary file until additional options specified - Added by XR Chua over 1 year ago
Hi Ralf, I'm not familiar with the different syntax for chaining operators that you mentioned. If I understand you right, run() is only triggered for some combination of operators, even though they may both appear to be correct syntax. If it is something important, it would help us users if it were mentioned in the documentation. Thanks!