0

当我为 ncks 发出 NCO 调用 usign pynco 时出现错误,看起来正在发送字节对象而不是字符串,结果如下:

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'' 

发生这种情况的代码:

# 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)

我可以调试 pynco 代码并看到这发生在 nco.__getattr__.get() 函数中,当它进入那里时,cmd传递给 ncks 二进制文件的列表对象如下所示:

<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']

错误消息似乎显示一个空的第二个输入,b''也许这是以某种方式错误地插入,因为没有第二个输入文件?

哪里出了问题?

4

1 回答 1

0

您对 pyno 的调用似乎是正确的。我无法在 Linux 机器上重现您的错误。而且我在 Windows 上没有 python。

您可以尝试几件事

  1. 直接运行 ncks 命令:

    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

  2. 尝试在pynco/tests中运行测试模块,方法是在您的 pynco 目录中运行命令“py.test”。您可能必须安装 python 模块“pytest”

...亨利

于 2018-02-08T12:26:55.547 回答