I'm trying to use NCO command ncap2 in python script for changing time units in the climatology NetCDF-file:
from nco import Nco
nco = Nco()
nco.ncap2(input='in.nc', output='out.nc', options =['-s', '\\"time@units=\\"days since 00-12-30 00:00:00\\"\\"'])
However, this gives me an error:
C:\Users\test\Miniconda3\envs\download\Library\bin\ncap2 -s "time@units="days since 00-12-30 00:00:00"" --output=out.nc in.nc <<< Inputs: out.nc b'' Traceback (most recent call last): File "C:\Users\test\workspace\GFSdownload\src\nc_info.py", line 13, in nco.ncap2(input='in.nc', output='out.nc', options =['-s', '\"time@units=\"days since 00-12-30 00:00:00\"\"']) File "C:\Users\test\Miniconda3\envs\download\lib\site-packages\nco\nco.py", line 342, in get raise NCOException(**retvals) nco.nco.NCOException: (returncode:1) b''
While using ncap2 directly from command line works good:
ncap2 -s "time@units=\"days since 00-12-30 00:00:00\"" in.nc out.nc
Is there a workaround for this? I'm writing my main code in python, so I'd like to use pynco everywhere.