tephpy.plotting.barbs#

The wind-barb gutter staff (spec §3.2).

Free geometry builders — bare numpy in diagram-native units, headlessly testable (the isopleths.py/shading.py pattern) — plus BarbStaff, the zoom-aware artist plot_barbs installs in the gutter axes. Each draw places every barb at the y where its level’s isobar meets the diagram’s right edge (the printed-form staff convention), thins the visible levels to the densest subset at least BARB_MIN_SEPARATION apart, and renders them through matplotlib’s barbs machinery with the Met Office increments (flag 50 kt, full 10 kt, half 5 kt, 5 kt binning).

Classes#

BarbStaff

One sounding's wind barbs on the gutter staff (spec §3.2).

Functions#

staff_y(→ numpy.typing.NDArray[numpy.float64])

Find the y where each pressure's isobar crosses a staff x.

select_barbs(→ numpy.typing.NDArray[numpy.bool_])

Thin barb positions to a minimum vertical separation.

Module Contents#

tephpy.plotting.barbs.staff_y(pressure: numpy.typing.ArrayLike, x_edge: float) numpy.typing.NDArray[numpy.float64][source]#

Find the y where each pressure’s isobar crosses a staff x.

The tephigram x decomposes along an isobar into a level-independent part and a pressure offset: x = g(T) + c(p) with g(T) = MA·ln(T + KELVIN_ZERO) + T (strictly increasing) and c(p) = MA·KAPPA·ln(P_REF / p), from x = MA·ln(theta_K) + T and Poisson’s equation. Each level’s crossing temperature solves g(T*) = x_edge - c(p) by inverse interpolation on one sampled g, and the crossing y then comes from the real transforms at (T*, p).

Parameters:
pressureArrayLike

Level pressures in hPa.

x_edgefloat

The staff’s x in tephigram data space — the diagram’s right edge.

Returns:
numpy.ndarray

The float64 crossing ys in tephigram data space; NaN where the crossing temperature falls outside _STAFF_TEMPERATURE_SPAN (or the pressure is not positive and finite).

tephpy.plotting.barbs.select_barbs(y: numpy.typing.ArrayLike, *, minimum_separation: float) numpy.typing.NDArray[numpy.bool_][source]#

Thin barb positions to a minimum vertical separation.

A greedy scan in input order — surface-first, so the surface barb always survives — keeps each position at least minimum_separation from the last kept one; non-finite positions are dropped. Positions and separation share one space (the staff uses display points), so zooming in spreads the ys and reveals more levels (spec §3.2).

Parameters:
yArrayLike

Barb positions, ordered surface-first.

minimum_separationfloat

The minimum spacing between kept positions.

Returns:
numpy.ndarray

Boolean keep-mask over y.

class tephpy.plotting.barbs.BarbStaff(main_axes: matplotlib.axes.Axes, pressure: numpy.typing.NDArray[numpy.float64], u: numpy.typing.NDArray[numpy.float64], v: numpy.typing.NDArray[numpy.float64], *, x: float = BARB_STAFF_POSITION, minimum_separation: float, **kwargs: Any)[source]#

Bases: matplotlib.artist.Artist

One sounding’s wind barbs on the gutter staff (spec §3.2).

A zoom-aware artist (the IsoplethFamily refresh pattern) that manages a matplotlib.quiver.Barbs child. Each draw reads the main axes’ view, places every level at its isobar’s staff crossing (staff_y()), masks the levels outside the view or closer than the minimum separation (select_barbs()), and hands the child the same-length masked arrays — matplotlib’s barbs machinery skips masked points, so the member count never changes.

Parameters:
main_axesmatplotlib.axes.Axes

The tephigram axes the staff annotates.

pressurenumpy.ndarray

Level pressures in hPa, surface-first.

u, vnumpy.ndarray

Wind components in knots (the barb-increment units).

xfloat

The staff position as a fraction across the gutter.

minimum_separationfloat

Minimum vertical separation between drawn barbs, in points.

**kwargsAny

Passed through to matplotlib.quiver.Barbs, over the _constants conventions (increments, rounding, length).

property barbs: matplotlib.quiver.Barbs | None#

The managed matplotlib barbs collection.

Returns:
matplotlib.quiver.Barbs or None

The child collection, or None before the first draw.

set_figure(fig: matplotlib.figure.Figure | matplotlib.figure.SubFigure) None[source]#

Propagate the owning figure to the managed child.

Parameters:
figmatplotlib.figure.Figure or matplotlib.figure.SubFigure

The figure the staff belongs to.

draw(renderer: matplotlib.backend_bases.RendererBase) None[source]#

Draw the barbs visible in the current view.

Parameters:
renderermatplotlib.backend_bases.RendererBase

The active renderer.