[ncl-talk] ncl vs PyNGL/PyNIO
haley at ucar.edu
Thu Jul 20 10:20:44 MDT 2017
Sorry for the delay. I wanted to create an example for you before I
answered this question, but ran out of time so I decided to send you this
email. I will try to get an example for you soon, that compares an NCL
script with a PyNIO/PyNGL script.
Basically, PyNIO is the Python replacement for the NCL "addfile" command,
and PyNGL is the replacement for NCL graphics.
However, you should be aware that PyNIO doesn't have the function of
"addfiles" (reading across several files in one call), so if you have calls
to addfiles, you will need to convert them to single "Nio.open_file" calls
in PyNIO, and then loop across the files yourself to read in the data.
The other feature that's missing from PyNIO is that when you read a
variable off a file, you don't automatically get the coordinate variables
like you do with NCL. This is not a huge deal, but you will need to read
them in separately. For example:
f = addfile("uv300.nc","r")
u = f->U
print(u&lat) ; the lat/lon coordinate arrays are automatically
f = Nio.open_file("uv300.nc")
u = f.variables["U"][:]
lat = f.variables["lat"][:]
lon = f.variables["lon"][:]
As for NCL graphics, PyNGL is *not* a one-to-one drop-in replacement for
the gsn_csm functions, if that's what you're using.
However, you should be able to reproduce any graphic that you have in NCL
in PyNGL, but it might require a few more steps.
I will try to create an example for you soon.
On Fri, Jul 14, 2017 at 5:29 AM, Ralf Mueller <ralf.mueller at mpimet.mpg.de>
> I'm thinking about a major re-write of a larger NCL program and I
> wondered, if there feature differences
> between plain NCL and the python-bindings PyNGL/PyNIO.
> My Script is rather complex and I always felt a little limited in terms of
> language features (not plotting)
> when programming NCL. So I thought, I better re-write my stuff in python
> instead of debugging the NCL version.
> thx in advance
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ncl-talk