asp_plot.selections#
Reproducible “figure selections” for asp_plot reports.
When re-processing the same scene with different ASP parameters, the diagnostic figures silently change what they show between runs: a fresh ICESat-2 request returns a slightly different point set, the “best” profile track flips, the best/worst agreement segments move, and the detailed-hillshade clip boxes are re-selected from the (re-processed) intersection-error raster. That makes before/after comparison impossible.
This module persists every non-deterministic selection a run made to a small
YAML sidecar next to the report, and reads it back so a later run can replay the
same choices. It deliberately imports nothing from report.py / fpdf so
it stays safe to use from notebooks.
See issue: uw-cryo/asp_plot#121
Attributes#
Classes#
Container for the reproducible selections made while building a report. |
Functions#
|
Convert a map-coordinate bbox to a top-left pixel offset (row, col). |
|
Convert a pixel window (top-left row/col + size) to a map-coordinate bbox. |
|
Read a FigureSelections from a YAML file. |
|
Reproject a map-coordinate bbox from one CRS to another. |
|
Write a FigureSelections to a YAML file. |
Module Contents#
- class asp_plot.selections.FigureSelections#
Container for the reproducible selections made while building a report.
All nested values are plain JSON/YAML-serializable types (dicts, lists, numbers, strings) so the object round-trips cleanly through YAML.
- detailed_hillshade#
{"subset_km": float, "intersection_error_percentiles": [..], "dem_crs": "EPSG:XXXX", "clips": [{"label": str, "bbox": [xmin, ymin, xmax, ymax], "pixel_offset": [row, col]}, ...]}.bboxis indem_crsmap coordinates (robust to a re-gridded DEM).- Type:
dict or None
- icesat2#
{"request": {..}, "parquet_cache": {key: path}, "profile_track": {"rgt": int, "cycle": int, "spot": int}, "segments": {"best": {..}, "worst": {..}}}. Omitted (None) for planetary DEMs.- Type:
dict or None
- classmethod from_dict(data)#
Build a FigureSelections from a parsed YAML/JSON dict.
- to_dict()#
Return a plain dict suitable for YAML serialization.
- asp_plot.selections.bbox_to_pixel_offset(transform, bbox)#
Convert a map-coordinate bbox to a top-left pixel offset (row, col).
The window size is not returned: on reuse the subset size is recomputed from
subset_kmand the current DEM’s GSD so the ground footprint stays constant even if the DEM resolution changed. Only the top-left anchor is needed.
- asp_plot.selections.pixel_window_to_bbox(transform, row, col, n_rows, n_cols)#
Convert a pixel window (top-left row/col + size) to a map-coordinate bbox.
- Parameters:
- Returns:
[xmin, ymin, xmax, ymax]in the raster’s CRS.- Return type:
- asp_plot.selections.read_selections_yaml(path)#
Read a FigureSelections from a YAML file.
- Parameters:
path (str) – Path to a previously written selections file.
- Return type:
- asp_plot.selections.reproject_bbox(bbox, src_crs, dst_crs)#
Reproject a map-coordinate bbox from one CRS to another.
Used when replaying detailed-hillshade clips against a DEM in a different CRS than the run that wrote them (e.g. a mapprojected vs. non-mapprojected stereo variant of the same scene, which can land in different projections). Returns the input unchanged when either CRS is missing or they are equal.
- Parameters:
bbox (sequence of float) –
[xmin, ymin, xmax, ymax]insrc_crs.src_crs (str or rasterio.crs.CRS or None) – CRS the bbox is currently expressed in.
dst_crs (str or rasterio.crs.CRS or None) – Target CRS (the DEM being clipped on reuse).
- Returns:
[xmin, ymin, xmax, ymax]indst_crs.- Return type:
- asp_plot.selections.write_selections_yaml(path, selections)#
Write a FigureSelections to a YAML file.
- Parameters:
path (str) – Destination path (e.g.
<report_stem>_figure_selections.yml).selections (FigureSelections) – Selections to serialize.
- asp_plot.selections.HILLSHADE_CLIP_LABELS = ['low', 'medium', 'high']#
- asp_plot.selections.SELECTIONS_SCHEMA_VERSION = 1#
- asp_plot.selections.logger#