Python#

The standard module for visualization in Python is Matplotlib. Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.

Matplotlib can be used in Python scripts, the Python and iPython shell (ala MATLAB®* or Mathematica®), web application servers, and six graphical user interface toolkits.

Matplotlib is free available: http://matplotlib.org/

For Python 3 Cartopy (https://pypi.org/project/Cartopy/), a cartographic python library with Matplotlib support for visualization, is used instead of Basemap.

How to use the example scripts at DKRZ#

On Levante you have to load the python3 module first:

module load python3

The module python3 includes the Matplotlib and Cartopy 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 the folder

/work/kv0653/NCL/data_examples

Modify and execute the script:

python <script name>

For example

python matplotlib_contour_filled.py

Note

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, tutorials, and packages using PyNGL/PYNIO, Matplotlib, Cartopy, Xarray, etc.

KMFleischer/PyEarthScience

Categories#

Maps

map resources, functions, sub-regions

XY-plots

1D data line plots, timeseries, scatter plots, statistics

Contours

2D data line, color fill (shaded), fill pattern, overlays

Vectors

2D vector data, e.g. wind components uv

Overlays

contour line on filled contour plot, vector on contours, different grid resolutions

Slices

draw contours longitudes/latitudes against time

Grids

rectilinear, curvilinear, unstructured grids

Special plots

miscellaneous plots

Shapefiles

work with shapefiles

Animations

scripts to generate animations

Colors, colormaps, colorbars

some specuals about colors

Miscellaneous

auxiliary scripts

Maps#

Matplotlib maps 1 example w200

Matplotlib maps 2 example w200

Projections

XY-plots#

Matplotlib xy-plot example w200

xy-plot

Matplotlib xy-plot example 2 w200

multi-timeseries plot

Matplotlib different anomalies w200

different anomalies plot

Contours#

Matplotlib contour lines example w200

Contour line plot

Matplotlib contour filled example w200

Contour fill plot

Vectors#

Matplotlib vectors w200

Vector plot

Matplotlib vectors on contour fill w200

Vectors on contour fill plot

Overlays#

Matplotlib overlays w200 Overlay regional on global grid

Slices#

Matplotlib slice-topo w200

Slice pressure levels with topography

Matplotlib Hovmoeller diagram w200

Hovmoeller diagram with additional map

Matplotlib Pressure/Height vs. Time w200

Pressure/height vs. time

Matplotlib lat vs. height 1 w200 Zonal mean latitude vs. height

Matplotlib lat vs. height 2 w200

Grids#

Matplotlib curvilinear rotated grid w200

Curvilinear grid with rotated pole e.g. CORDEX EUR-11

Matplotlib curvilinear rotated grid 2 w200

Contour plots of curvilinear grid without wrapped lines

Matplotlib ICON contour plot w200

ICON contour plot

Matplotlib ICON triangles py2 w200

ICON triangles (Python 2)

Matplotlib ICON triangles py3 w200

ICON triangles (Python 3)

Matplotlib ICON triangles with vectors py3 w200

ICON triangles with vectors (Python 3)

Matplotlib ICON R02B09 datashader w200

ICON R02B09 make it fast

Special plots#

Matplotlib wind speed direction polar projection w200

Wind speed and direction with polar projection

Matplotlib wind speed direction polar projection count w200

Wind speed and direction with polar projection colored by frequency

Matplotlib high res bck image w200

High resolution background image

Matplotlib quality points 1 w200 Matplotlib quality points 2 w200

Box plot and points plot sized by quality factor

Matplotlib arctic death spiral w200

Sea Ice Spiral plot based on ‘Arctic Death Spiral’ from Andy Lee Robinson

Matplotlib counts per country w200

Counts per country

Matplotlib satellite swath w200

Satellite swath data

Matplotlib sunshine duration w200

Sunshine duration data colored by temperature

Matplotlib warming stripes w200

Germany warming stripes and anomaly bars

Matplotlib warming stripes 2 w200

Warming stripes with timeseries and trend data

Matplotlib sea ice polar 1 w200

Sea ice data on NorthPolarStereographic projection

Matplotlib pressure extrema w200

Add symbols to surface pressure extrema

Matplotlib ONI 1 w200

Plot Oceanic Nino Index HadSST4 tos anomalies

Shapefiles#

Matplotlib shapefile basics w200

Shapefile basics

Matplotlib shapefile mask w200

Use shapefile to mask data

Animations#

Matplotlib animation 1 w200

Animation of time-dependent spatial data

Colors, colormaps, colorbars#

Matplotlib colorbar scratch w200

Colorbar from scratch

Matplotlib color box legend w200

Color box legend with white space

Matplotlib colormap named colors w200

Colormap from named colors

Matplotlib read NCL colormaps w200

Read and use NCL colormaps

Miscellaneous#

Merge multiple CSV files and write the data to netCDF file