NCO permutation command in Python

639 views Asked by At

I need to permute the dimensions of my netcdf file from time,lat,lon, to lat,lon,time.

The NCO command for that purpose is : " ncpdq -a lat,lon,time input.nc input_fixed.nc"

How can I run this command using Python library 'pynco' please ?

2

There are 2 answers

0
Charlie Zender On

Please read the example on this page: https://github.com/nco/pynco Those instructions suggest this invocation

from nco import Nco
nco = Nco()
nco.ncpdq(input=in.nc, output=out.nc, options="-a lat,lon,time")
0
tmpst On

The other answer didn't work for me, and there is no longer any mention of ncpdq in the github example. However, the following syntax seems to work:

nco.ncpdq(input="in.nc", output="out.nc", options=['-a', 'lat,lon,time'])