What is this package?

This package simplifies plotting geospatial data on top of a base map. It is intended to make plotting easy and uniform across multiple applications, while remaining flexible with options for changing the map projection, domain, plotting levels, and more. It’s capable of plotting multiple fields as well.

How do I plot data?

In cpc.geoplot a Geomap object defines how the map will look. It contains attributes such as basemap and ax (mpl_toolkits.basemap.Basemap object and matplotlib.axes object respectively), which define the axis and the underlying map, and other attributes that affect how the data will be plotted, such as colorbar options, domain, projection, title, etc.

A Geofield object defines how the plotted field will look. It contains attributes such as the data, plotting levels, fill/contour colors, etc.

Using these two objects a geospatial plot can be created. First import the dependencies:

>>> from cpc.geogrids import Geogrid
>>> from cpc.geoplot import Geomap, Geofield

Next create a Geomap:

geomap = Geomap()

Then load the data:

import numpy as np
data = np.fromfile('/path/to/files/observation.bin', dtype='float32')

Then create a Geofield (which needs a Geogrid):

geogrid = Geogrid('1deg-global')
geofield = Geofield(data, geogrid)

Finally plot the data and save it:

geomap.plot(field)
geomap.save('out.png', dpi=100)

Here’s the result:

example default options

Options

Geomap options

The following options are available as parameters when calling Geomap():

Geofield options

The following options are available as parameters when calling Geofield():

Examples