Skip to content

About

Publication-grade meteorological visualization (curly vectors, NCL-style axes, stippling) with Pure-Rust geometry acceleration

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

skyborn-plot (skybornplot)

NCL-style atmospheric & climate vector, contour, and stippling visualization for Matplotlib & Cartopy, powered by Pure-Rust native kernels

PyPI version Python versions License

Part of the Skyborn (skyborn-org) ecosystem.


Why skyborn-plot?

  • Pure-Rust _plot_rs Core: Unified PyO3 native extension (rust/skybornplot-core + rust/skybornplot-py) backed by rayon multithreading, with zero C, Cython, or Fortran runtime dependencies.
  • Zero-Copy C-Order Buffers & GIL Release: Borrows contiguous float64/bool slices directly across the PyO3 boundary and automatically releases the Python GIL (py.detach) for workloads with >= 2,048 elements.
  • Cross-Subplot ref_length_px & plt.quiver Compatibility: Calibrate vector glyph lengths in absolute display pixels across panels of different widths or aspect ratios, with automatic CurlyVectorKey synchronization and plt.quiver-style aliases (ax=, c=, linewidths=, facecolors=, edgecolors=, pivot=, vmin/vmax).
  • Swept & Straight Contour Arrowheads: O(log N) cumulative arc-length PathProfile queries, local straightness scoring, and label-avoiding placement via arrow_contour and arrow_contour_clabel.
  • Broad Platform & Python Support: Python 3.9+ and NumPy, with prebuilt wheels for Linux (manylinux2014_x86_64), macOS (arm64 & x86_64), and Windows (win_amd64).

Pure-Rust Architecture & Cross-Subplot Scaling

1. Streamline Integration & Contour Kernel Pipeline

Pure-Rust Curly-Vector and Contour Kernel Architecture

curly_vector normalizes regular, non-uniform (ncl_preset="profile"), curvilinear, and Cartopy-projected grids into display-space coordinates, applies O(1) spatial-hash thinning (thin_display_candidates), integrates curved glyphs in parallel across rayon threads (trace_ncl_glyphs_batch), and builds batched Matplotlib LineCollection (closed-apex open "->" heads) and PolyCollection ("-|>" filled heads) artists. Display-thinned scatter stippling and arrow_contour / arrow_contour_clabel reuse the same Pure-Rust spatial-hashing and PathProfile kernels.

2. Cross-Subplot ref_length_px & plt.quiver-Compatible Key Scaling

ref_length_px Cross-Subplot and plt.quiver-Compatible Key Scaling


Pure-Rust vs. Legacy C / Python Benchmarks

skyborn-plot Pure-Rust vs. Legacy Benchmarks

Measured on Apple Silicon (Apple M5, arm64, 10 CPU, 32 GB RAM) comparing Pure-Rust _plot_rs against legacy C/Python kernels and full Matplotlib Agg rendering (24.80× contour arrows, 5.92× 400-glyph Rust batch vs Python loop, 2.63× candidate thinning, and 1.46× end-to-end curly_vector Agg draw).


Installation

pip install skyborn-plot

Optional geospatial & xarray support:

pip install "skyborn-plot[geo]"

Or install the full Skyborn suite:

pip install skyborn

Quick Start

Cross-Subplot Comparison with ref_length_px & plt.quiver-Style Key

import matplotlib.pyplot as plt
import skybornplot as splt

fig, (ax_wide, ax_narrow) = plt.subplots(
    1, 2, figsize=(10, 4), gridspec_kw={"width_ratios": [2, 1]}
)

# Identical physical wind speed renders at the exact same 24 px length in both panels
shared = dict(
    density=1.1,
    arrowstyle="->",
    ref_magnitude=10.0,
    ref_length_px=24.0,
    cmap="viridis",
)

cv_wide = splt.curly_vector(ax_wide, lon_g, lat_g, u_g, v_g, c=speed_g, **shared)
splt.curly_vector_key(ax_wide, cv_wide, U=10.0, label="10 m s⁻¹")

cv_narrow = splt.curly_vector(ax_narrow, lon_r, lat_r, u_r, v_r, c=speed_r, **shared)
splt.curly_vector_key(ax_narrow, cv_narrow, U=10.0, label="10 m s⁻¹")

Contours, Stippling & Layout Helpers

  • arrow_contour & arrow_contour_clabel: Streamline-aligned directional contour arrows with swept heads and automatic label avoidance.
  • shadow_contourf: Shaded and hatched significance or terrain overlays.
  • scatter: Display-space-thinned stippling that adapts to map projections and panel aspect ratios.
  • gradient_fill_between / GradientFillBetween, createFigure, add_equal_axes, add_centered_axes.

Note: skyborn.plot in the skyborn package seamlessly re-exports skybornplot.


License

BSD 3-Clause License. See LICENSE.

About

Publication-grade meteorological visualization (curly vectors, NCL-style axes, stippling) with Pure-Rust geometry acceleration

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages