Skip to main content

cool_maps

Documentation Status

cool_maps is a small toolbox of helper functions, built on top of Cartopy (and, optionally, Basemap), for quickly producing nice-looking oceanographic maps: coastlines, bathymetry, ocean currents, and your own data overlaid on top. It was written to easily generate maps using pre-defined settings that our lab, the Rutgers Center for Ocean Observing Leadership, prefers to use – but the defaults are general-purpose and the styling is fully customizable.

Full documentation, including a complete tutorial and API reference, is hosted at https://cool-maps.readthedocs.io/en/latest/.

Features

  • One function, cplt.create(), to build a complete map from just an extent – coastlines, land/ ocean colors, ticks, and borders included by default.

  • Built-in bathymetry download and plotting (contours, shaded contours, or continuous depth shading), and ocean current quiver plots from xarray datasets. Large extents are automatically tiled to stay under the server’s request-size limits.

  • Supported on two interchangeable mapping engines, Cartopy and Basemap – the same code works under either, including plotting your own data directly on the returned axes.

  • Nicely spaced, DMS- or decimal-degree-labeled ticks computed automatically from your map extent.

Quickstart

import cool_maps.plot as cplt

# Gulf of Mexico
extent = [-99, -79, 18, 31]

fig, ax = cplt.create(extent, bathymetry=True)

See the full tutorial (also available as a runnable notebook at notebooks/tutorial.ipynb) for a complete walkthrough covering projections, coastline resolution, colors, ticks, bathymetry, overlaying your own data, currents, and choosing between engines.

Selecting a map engine

The plotting helpers support both Cartopy (the default) and Basemap. Cartopy remains the default engine, but you can select Basemap after installing it:

>>> import cool_maps.plot as cplt
>>> cplt.set_engine('basemap')

You can also set COOL_MAPS_ENGINE=basemap in your environment before importing cool_maps.plot, or pass engine= to any individual call without touching the global default:

>>> cplt.create(extent, engine="basemap")

When switching engines you can keep using the same Cartopy CRS objects in calls such as cplt.create(..., proj=ccrs.Mercator()). The Basemap backend will translate a handful of common projections automatically; if a CRS cannot be converted, pass the Basemap projection name or keyword dictionary instead (for example proj={'projection': 'lcc', 'lon_0': -74, 'lat_0': 39}).

For a Cartopy-free workflow you can use the shared projection keywords provided by cool_maps:

>>> cplt.create(extent, proj="mercator")

Behind the scenes the string is mapped to the appropriate Cartopy CRS or Basemap projection depending on the active engine.

Axes returned by create() remember which engine they were built with, so you never need to pass engine= to add_features/add_bathymetry/add_currents/add_ticks yourself – it’s inferred from the axes. You can also plot directly on the returned axes with ax.scatter/ax.plot/ax.contour/ ax.contourf/ax.pcolormesh/ax.quiver/ax.fill using plain lon/lat data; cool_maps injects the right transform= (Cartopy) or latlon=True (Basemap) for you, so the exact same plotting code works under either engine:

>>> fig, ax = cplt.create(extent, engine="basemap")  # or "cartopy"
>>> ax.scatter(lon, lat, c=values)  # no transform=/latlon= needed, regardless of engine

Installation

Stable release

We recommend using miniconda to manage your Python environments. Download and follow the Miniconda installation guide for the appropriate Miniconda installer for your operating system.

Install with conda (includes Cartopy; the only required engine):

$ conda install -c conda-forge cool_maps

To also enable the optional Basemap engine:

$ conda install -c conda-forge basemap basemap-data-hires

If you’re installing with pip instead, the basemap extra pulls it in for you:

$ pip install cool_maps[basemap]

From sources

The sources for cool_maps can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/rucool/cool_maps

Or download the tarball:

$ curl -OJL https://github.com/rucool/cool_maps/tarball/master

Change your directory to the source code of cool_maps

$ cd ~/cool_maps

Once you are in the correct directory, there are two ways to install from source.

Method 1:

$ python setup.py install

Method 2:

$ pip install .

Documentation

  • Full docs, tutorial, and API reference: https://cool-maps.readthedocs.io/en/latest/

  • Runnable tutorial notebook: notebooks/tutorial.ipynb

  • Cartopy/Basemap parity deep-dive and performance comparison: notebooks/dual_backend_demo.ipynb

License

MIT license – see LICENSE for details.

History

0.0.6 (2022-09-21)

  • Create conda build for conda-forge

  • Add Sphinx documentation

0.0.3 (2022-07-20)

  • Create conda build

0.0.2 (2022-07-19)

  • Initial commit to GitHub

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cool_maps-1.1.0.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cool_maps-1.1.0-py2.py3-none-any.whl (30.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cool_maps-1.1.0.tar.gz.

File metadata

  • Download URL: cool_maps-1.1.0.tar.gz
  • Upload date:
  • Size: 51.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for cool_maps-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6ccf8145894d72506bd5ab914278018ac0563b3c81879bb34782d43ef445bcac
MD5 72cc6c3e8e67eee03be4b9935883b454
BLAKE2b-256 29593cbf8fcbe097b913f6631c9f0f8c16ccfe7bf3178d50e4858b9e0eb2b6f8

See more details on using hashes here.

File details

Details for the file cool_maps-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: cool_maps-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for cool_maps-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c6aaad131362ef501bbf5a567de45095800c392f1307aa3e03df647ddd658b07
MD5 0fa88bf770904497c23eda4198d49b2e
BLAKE2b-256 14be1151833e0a3a52ba0b429138b4c5c52715162884da1743c706603bfa6971

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.2

2 files

1.1.1

2 files

This release

1.1.0 This release

2 files

1.0.2

2 files

0.0.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page