ssapy_toolkit.Plots.break_plot_lines
Utilities for working with longitude/latitude tracks.
Provides a helper to break line segments at large longitude jumps (e.g., crossing the dateline), inserting NaNs so matplotlib does not draw artifact lines across the whole map, while trying to preserve input types.
Functions
|
Insert NaNs into lon/lat where the longitude jumps more than max_jump degrees. |
- ssapy_toolkit.Plots.break_plot_lines.break_plot_line(lon: Sequence[float] | ndarray, lat: Sequence[float] | ndarray, max_jump: float = 179.0) Tuple[Sequence[float] | ndarray, Sequence[float] | ndarray][source]
Insert NaNs into lon/lat where the longitude jumps more than max_jump degrees.
- Type behavior:
If lon/lat are numpy arrays -> returns numpy arrays (dtype preserved unless conversion to float is needed to hold NaNs).
If lon/lat are lists -> returns lists.
Other sequences are converted to numpy arrays.
- Args:
- lon:
Sequence or numpy array of longitudes (degrees).
- lat:
Sequence or numpy array of latitudes (same length as lon).
- max_jump:
Threshold in degrees for detecting a “wrap” jump. Any consecutive longitude difference with absolute value > max_jump will be treated as a break point.
- Returns:
- (lon_fixed, lat_fixed):
Same container type as inputs (list or numpy array), with NaNs inserted at break points. When used with matplotlib, lines will break at NaNs.
- Example:
>>> lon = [170, 175, 179, -179, -175, -170] >>> lat = [ 0, 1, 2, 3, 4, 5] >>> lon2, lat2 = break_dateline(lon, lat) >>> type(lon2), type(lat2) (<class 'list'>, <class 'list'>)