[ncl-talk] NCL to Python
Jared Lee
jaredlee at ucar.edu
Fri Apr 24 09:53:57 MDT 2020
Hi Damianos,
I've been translating a number of my scripts from NCL to Python, and now
all my new development is in Python. When dealing with WRF output, if you
want to use the WRF-Python functions, you'll need to import these modules:
import wrf
import netCDF4
And if you want to use PyNGL to make NCL-style plots:
import Ngl
PyNIO isn't being updated anymore, but it still has a lot of readers for
numerous current geophysical data formats (grib, netcdf, hdf, etc.). I try
to use xarray as much as I can, but there are some things for which netCDF4
or PyNIO work more smoothly (for instance, netCDF4 is simpler than xarray
for converting character arrays to strings, in my experience, and PyNIO
could read a grib output file straightforwardly, while with xarray you need
additional packages called cfgrib and ecCodes):
import Nio
import xarray
While I still use PyNGL for making map-style plots from my gridded model
output, I've switched to using Matplotlib for other plots, including line
plots and box plots, because I think they look nicer than NCL/PyNGL:
import matplotlib
Some other really common modules for data analysis that you'll want to use
include:
import numpy
import pandas
import datetime
import pytz (for explicit time zone conversion and handling)
Karin Meier-Fleischer of DKRZ has a helpful NCL to Python transition guide,
with side by side examples of how to do quite a few things in both
languages. I found this quite helpful for me initially as I was just
getting my feet wet with Python, coming from an NCL framework:
https://www.ncl.ucar.edu/Applications/NCL_to_Python/
I hope that all helps. It's been a slow learning process for me, but I'm
fairly comfortable with Python now. There are lots of resources available
on the web for Python, such as StackOverflow, etc., and numerous "beginning
Python" tutorials for free viewing/download to get started with
basics. Good luck!
Jared
On Fri, Apr 24, 2020 at 2:27 AM Damianos Mantsis via ncl-talk <
ncl-talk at ucar.edu> wrote:
> Hi everyone
>
> I have a question about the transition from NCL to Python. I need to
> transition to the NCL related Pyhon modules, that have been developed by
> the NCAR team given the fact that NCL will not be further developed.
>
> My question is about the use of PyNGL, PyNIO, WRF-Python modules. Which of
> these need to be installed with Python. Some of these are interdependent
> and I got a little confused, and one might contain the other. If you are
> not familiar with the topic please suggest someone that has done this
> transition (NCL to Python). any help would be greatly appreciated.
>
> Thank you
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
*My working day may not be your working day.Please do not feel obligated to
reply to this email outside of your normal working day.*
===============================
Jared A. Lee, Ph.D.
Project Scientist II
Research Applications Laboratory
National Center for Atmospheric Research
Boulder, Colorado, USA
Member, AMS Planning Commission
Email: jaredlee at ucar.edu (w)
Phone: 303.497.8485 (w)
Web: https://staff.ucar.edu/users/jaredlee
===============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200424/629c1c0e/attachment.html>
More information about the ncl-talk
mailing list