[ncl-talk] ncl vs PyNGL/PyNIO

Mary Haley haley at ucar.edu
Thu Jul 20 10:20:44 MDT 2017


Hi Ralf,

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.

*PyNIO*

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:

NCL:

   f = addfile("uv300.nc","r")
   u = f->U
   printVarSummary(u)
   print(u&lat)    ; the lat/lon coordinate arrays are automatically
attached
   print(u&lon)

*PyNIO*

  f = Nio.open_file("uv300.nc")
  u = f.variables["U"][:]
  lat = f.variables["lat"][:]
  lon = f.variables["lon"][:]

*PyNGL*

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.

--Mary


On Fri, Jul 14, 2017 at 5:29 AM, Ralf Mueller <ralf.mueller at mpimet.mpg.de>
wrote:

> Hi!
>
> 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
> ralf
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170720/c5239f03/attachment.html 


More information about the ncl-talk mailing list