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#
Functions#
|
Find the y where each pressure's isobar crosses a staff x. |
|
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)withg(T) = MA·ln(T + KELVIN_ZERO) + T(strictly increasing) andc(p) = MA·KAPPA·ln(P_REF / p), fromx = MA·ln(theta_K) + Tand Poisson’s equation. Each level’s crossing temperature solvesg(T*) = x_edge - c(p)by inverse interpolation on one sampledg, and the crossing y then comes from the real transforms at(T*, p).- Parameters:
- Returns:
numpy.ndarrayThe 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:
- Returns:
numpy.ndarrayBoolean 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.ArtistOne sounding’s wind barbs on the gutter staff (spec §3.2).
A zoom-aware artist (the
IsoplethFamilyrefresh pattern) that manages amatplotlib.quiver.Barbschild. 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_axes
matplotlib.axes.Axes The tephigram axes the staff annotates.
- pressure
numpy.ndarray Level pressures in hPa, surface-first.
- u, v
numpy.ndarray Wind components in knots (the barb-increment units).
- x
float The staff position as a fraction across the gutter.
- minimum_separation
float Minimum vertical separation between drawn barbs, in points.
- **kwargs
Any Passed through to
matplotlib.quiver.Barbs, over the_constantsconventions (increments, rounding, length).
- main_axes
- property barbs: matplotlib.quiver.Barbs | None#
The managed matplotlib barbs collection.
- Returns:
matplotlib.quiver.BarbsorNoneThe child collection, or
Nonebefore the first draw.
- set_figure(fig: matplotlib.figure.Figure | matplotlib.figure.SubFigure) None[source]#
Propagate the owning figure to the managed child.
- Parameters:
- fig
matplotlib.figure.Figureormatplotlib.figure.SubFigure The figure the staff belongs to.
- fig
- draw(renderer: matplotlib.backend_bases.RendererBase) None[source]#
Draw the barbs visible in the current view.
- Parameters:
- renderer
matplotlib.backend_bases.RendererBase The active renderer.
- renderer