I recently came across NCO, which I wanted to use within Python. How do I know if I've correctly installed pynco/if it is operating correctly?
I installed both nco and pynco through conda-forge/conda in my working environment (named py37), but while following the short setup, I noticed some things not working that should be right off the bat. For example, trying the nco.ncdump command yielded a warning that the command did not exist. Trying another command yielded an error I cannot understand. I am fairly new to python and I'm not sure how to figure out these errors on my own.
> from nco import Nco
> nco = Nco()
> file1 = '/Users/rg/Desktop/GRIDSAT-B1.2014.01.01.00.v02r01.nc'
> nco.ncdump(input=file1)
Traceback (most recent call last):
File "<ipython-input-2-41ab1ce4ac76>", line 1, in <module>
nco.ncdump(input=file1)
File "/Users/rg/anaconda3/envs/py37/lib/python3.7/site-
packages/nco/nco.py", line 173, in __getattr__
raise AttributeError("Unknown command: {cmd}".format(cmd=nco_command))
AttributeError: Unknown command: ncdump
> nco.ncra(input=file1, returnArray='T').variables['irwin_cdr'][:]
Error in calling operator ncra with:
/Users/rg/anaconda3/envs/py37/bin/ncra --
output=/var/folders/l3/6p30t5g91xg_kxmkt9c31y100000gn/T/ncra_GRIDSAT-
B1.2014.01.01.00.v02r01.ncdaltfozx.tmp /Users/rg/Desktop/GRIDSAT-
B1.2014.01.01.00.v02r01.nc <<<
Inputs: /Users/rg/Desktop/GRIDSAT-B1.2014.01.01.00.v02r01.nc
b''
Traceback (most recent call last):
File "<ipython-input-4-cc2ef1873b20>", line 1, in <module>
nco.ncra(input=file1, returnArray='T').variables['irwin_cdr'][:]
File "/Users/rg/anaconda3/envs/py37/lib/python3.7/site-
packages/nco/nco.py", line 342, in get
raise NCOException(**retvals)
NCOException: (returncode:1) b''
The first 3 lines of code executed result in no error messages, which makes me think it is installed. I've used this data file and know it is linked correctly. There might be a dependency issue or something, but I am not experienced enough with python to know where to look.
ncdump
is not an NCO command.ncks
is. Thus I suggest you try insteadHowever, my knowledge of
pynco
syntax is minimal, and I do not know what thencra
command expects, besides possibly and output filename?