When I issue an NCO call usign pynco for ncks I am getting an error, it looks like a bytes object is being sent instead of a string, resulting in this:
pydev debugger: starting (pid: 7864)
2018-02-05 11:30:53 INFO Start time: 2018-02-05 11:30:53.365789
Error in calling operator ncks with:
>>> C:/home/miniconda/pkgs/nco-4.7.1-vc14_0/Library/bin\ncks --dmn=lon,0,20,1 --output=C:/home/data/nclimgrid/work\nclimgrid_lowres_prcp_slice00.nc C:/home/data/nclimgrid/nclimgrid_lowres_prcp.nc <<<
Inputs: C:/home/data/nclimgrid/nclimgrid_lowres_prcp.nc
b''
2018-02-05 11:36:19 ERROR Failed to complete
Traceback (most recent call last):
File "C:\Users\DELL\git\process_grid\process_grid.py", line 949, in <module>
options=slice_option)
File "C:\home\miniconda\lib\site-packages\nco\nco.py", line 277, in get
raise NCOException(**retvals)
nco.nco.NCOException: (returncode:3221225781) b''
Traceback (most recent call last):
File "C:\home\eclipse\neon\eclipse\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1621, in <module>
main()
File "C:\home\eclipse\neon\eclipse\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1615, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\home\eclipse\neon\eclipse\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1022, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File
"C:\home\eclipse\neon\eclipse\plugins\org.python.pydev_6.2.0.201711281614\pysrc\_pydev_imps\_pydev_execfile.py", line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\DELL\git\process_grid\process_grid.py", line 949, in <module>
options=slice_option)
File "C:\home\miniconda\lib\site-packages\nco\nco.py", line 277, in get
raise NCOException(**retvals)
nco.nco.NCOException: (returncode:3221225781) b''
The code where this is happening:
# assume the same longitude slice specs across temperature, precipitation, and soils files
slice_option = ['--dmn=lon,{0},{1},1'.format(precip_files[i][1], precip_files[i][2])]
# use NCO to slice the specified longitude range from the files
slice_file_precip = precip_files[i][0]
nco.ncks(input=args.precip_file,
output=slice_file_precip,
options=slice_option)
I can debug into the pynco code and see that this is happening in the nco.__getattr__.get() function, when it gets in there the cmd
list object passed to the ncks binary looks like this:
<class 'list'>: ['C:/home/miniconda/pkgs/nco-4.7.1-vc14_0/Library/bin\\ncks',
'--dmn=lon,0,20,1',
'--output=C:/home/data/nclimgrid/work\\nclimgrid_lowres_prcp_slice00.nc',
'C:/home/data/nclimgrid/nclimgrid_lowres_prcp.nc']
The error message appears to show an empty second input, b''
, maybe this is being inserted by mistake somehow, as there is no second input file?
Where are things going wrong?
Your call to pyno appears correct. I am unable to recreate your error on a Linux box. And I don't have python on windows.
A couple of things you can try
Run the ncks command directly:
C:/home/miniconda/pkgs/nco-4.7.1-vc14_0/Library/bin\ncks --dmn=lon,0,20,1 --output=C:/home/data/nclimgrid/work\nclimgrid_lowres_prcp_slice00.nc C:/home/data/nclimgrid/nclimgrid_lowres_prcp.nc
Try running the test modules in pynco/tests do this by running the command 'py.test' in your pynco directory. You may have to install the python module 'pytest'
...Henry