Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

PyNGL

The Python module PyNGL is a Python language module for creating visualizations of scientific data. PyNIO is the IO module of PyNGL similar to NCL's addfile/addfiles functions.

The Python language module PyNGL (pronounced "pingle") is used to visualize scientific data, with an emphasis on high quality 2D visualizations. It is based on the capabilities and functionality of NCL. In addition the PyNIO Python module is used for reading and writing files in several different data formats, including netCDF, netCDF 4, GRIB1, GRIB2, HDF 4, HDF-EOS 2 and HDF-EOS5, and CCM history files, similar to the NCL file input/output functionality.

PyNGL and PyNIO provide Python interfaces to most of the NCL functionality. A knowledge of NCL would give you a leg up in using these modules, but they are meant to be independent from NCL and used as a stand-alone suite of Python functions.

PyNGL/PyNIO is free available: http://www.pyngl.ucar.edu/index.shtml

Most examples use the PyNIO module to read/write data from/to a file independant of the file type but in the future we will use xarray to read NetCDF files, ECMWF's cfgrib to read GRIB files, and pyshp to read shapefiles.

How to use the example scripts at DKRZ

On Mistral you have to load the python 2.7 module first:

module load python/2.7-ve0

The module python includes the PyNGL and PyNIO packages already.

Copy the example script you want to use to your work space. Not all example data sets are available but most files are stored in

/work/kv0653/NCL/data_examples

Modify and execute the script:

python <script name>

For example

python PyNGL_unstructured_ICON_triangles.py

 

DKRZ has created a GitHub Python repository named PyEarthScience that contains Visualization, Analysis and IO example scripts. The sence of the repository is to establish a kind of a platform for Earth scientists for searching and representing Python scripts and packages using PyNGL/PYNIO, matplotlib, cartopy, etc.  The repository is still in progress.

https://github.com/KMFleischer/PyEarthScience/

  1.  Maps map resources, functions, sub-regions
  2.  XY-plots 1D data line plots, timeseries, scatter plots, statistics
  3.  Contours 2D data line, color fill (shaded), fill pattern, overlays
  4.  Vectors 2D vector data, e.g. wind components uv
  5.  Slice plots contour plot of a vertical slice
  6.  Overlays ontour line on filled contour plot, vector on contours, different grid resolutions
  7.  Panel plots multiple plots in one frame (page)
  8.  Grids rectilinear, curvilinear, unstructured grids
  9.  Special plots some special plots
10.  Masking mask the data
11. Shapefiles country outlines, compute temperature means of counties
12. Regridding regrid curvilinear to rectilinear, regrid to higher resolution
13. xarray / PyNIO example scripts using xarray to read data files


1. Maps

DKRZ PyNGL example orthographic projection w200

Map using Orthographic projection

PyNGL map settings w400

 Map plot with colored land and ocean

 

Color fill country area by value

Map tickmarks with HighRes

Map tickmarks with gridlines

 

Map tickmarks for Robinson projection

Map tickmarks for Lambert Conformal Projection

Mask Lambert Conformal Projection

 

 

 


2. XY-plots

PyNGL xy-plot w400

 XY-plots drawing 3 lines

 DKRZ PyNGL example simple xy-plot w200

Simple xy-plot

 DKRZ PyNGL example bar chart plot w200

Bar chart plot

DKRZ PyNGL example scatter plot w200

Scatter plot

DKRZ PyNGL example scatter plot w200

Scatter plot with regression line

 

 

Compute de-trended variable data
and add a Box-Whisker plot

Regression and moving average
using numpy

 

 

 

3. Contours

PyNGL rectilinear grid contour plot w400

 Contour plot of rectilinear grid

PyNGL curvilinear grid contour plot w400

 Contour plot of curvilinear data

 

Overlay filled contours plot on
polar stereographic map

PyNGL unstructured data contour plot w400

 Contour plot of unstructured data
(ICON)

PyNGL unstructured ICON triangles w400

Contour plot of unstructured data
showing the edges

(run time: 4.1s)

PyNGL unstructured ICON triangles projections w400

PyNGL unstructured ICON triangles 2 projections w400

ICON plot with Mollweide and
Winkel Triple projection

 DKRZ NCL example default Hovmueller plot w200

Default Hovmueller plot

 DKRZ NCL example colored Hovmueller plot w200

Color filled Hovmueller plot

 

4. Vectors

DKRZ PyNGL example vectors on map w200

Vectors on a map

 

PyNGL rectilinear vector 1 w400
PyNGL rectilinear vector 2 w400

Vector plots colored by second variable

 

Streamline plot

 

5. Slice plots

PyNGL rectilinear slice w400

 Slice plot

 

6. Overlays

 DKRZ PyNGL example overlay plot w200

Overlay plot

 

7. Panel plots

PyNGL panel plot w400

 Panel plot 3rows x 1 column

 

Panel plot without Ngl.panel.This
example uses the vp-resources instead.

8. Grids



Plot curvilinear grid (python3)

 

9. Special plots

 

Overlay two grids with different resolutions

 

Scatter plot with two attached
histograms

Draw filled circles instead of grid cells. The size depends on a quality value

 
 

 
 

Hovmoeller plot

 

Hovmoeller plot with filled contours

 

Location of stations with marker

 

 

 

 

10. Masking

DKRZ PyNGL masking example w200

Mask the data using area specifiers

 

11. Shapefiles

DKRZ PyNGL example shapefile w200

Plot shapefile contents

 

12. Regridding

DKRZ PyNGL example regridding xesmf w200

Regrid from coarse to higher
resolution grid

 

13. xarray / PyNIO

Contour plot

Timeseries

Demonstrate the use of xarray to read
the content of a netCDF file

 

Demonstrate the use of PyNIO to read
the content of a netCDF file

Demonstrate the use of xarray to read
the content of a GRIB file

 

Demonstrate the use of PyNIO to read
the content of a GRIB file

 

 

Artikelaktionen