asp_plot.gallery#

Attributes#

Classes#

GalleryPlotter

Plot a grid of DEM thumbnails sharing a single color scale.

Module Contents#

class asp_plot.gallery.GalleryPlotter(raster_list, downsample='auto', **kwargs)#

Bases: asp_plot.utils.Plotter

Plot a grid of DEM thumbnails sharing a single color scale.

This class extends the base Plotter class to visualize a stack of rasters (e.g. multi-date or multi-pair ASP DEMs over the same area) as a gallery of thumbnails. All panels share a single global percentile color stretch and one shared colorbar, which makes it easy to QA elevation differences across many outputs at a glance.

DEMs are rendered using the same convention as the rest of the package (gray hillshade underlay with a semi-transparent viridis DEM on top).

The layout sizes every panel to the rasters’ actual aspect ratio and places panels with absolute positioning, so a gallery of 1 to N rasters (including non-square ones) packs tightly without stray whitespace. Per-panel titles use the full filename, auto-shrunk to fit the panel width.

raster_list#

Resolved list of raster file paths to plot.

Type:

list of str

downsample#

Downsampling factor for reads, or “auto” to pick per-raster factors so the longest edge is ~``GALLERY_TARGET_PX`` pixels.

Type:

int or str

title#

Figure suptitle, inherited from the Plotter class.

Type:

str or None

Examples

>>> gallery = GalleryPlotter.from_directory("/path/to/dems", pattern="*-DEM.tif")
>>> gallery.plot_gallery(save_dir="/path/to/output", fig_fn="dem_gallery.png")
classmethod from_directory(directory, pattern='*-DEM.tif', **kwargs)#

Build a GalleryPlotter by globbing a directory for rasters.

Globbing is recursive, so ** in the pattern descends into subdirectories. This is handy for typical ASP layouts where each pair lives in its own subdirectory:

  • "*-DEM.tif" — top-level only

  • "*/*-DEM.tif" — exactly one subdirectory deep

  • "**/*-DEM.tif" — any depth (recursive)

Parameters:
  • directory (str) – Directory to search for rasters.

  • pattern (str, optional) – Glob pattern for the rasters, default is “*-DEM.tif”. Supports recursive ** to match nested subdirectories.

  • **kwargs (dict, optional) – Additional keyword arguments passed to __init__ (e.g. downsample, title).

Returns:

Plotter initialized with the sorted list of matching files.

Return type:

GalleryPlotter

Raises:

ValueError – If no files in directory match pattern.

Plot the DEM gallery.

Reads every raster (downsampled), computes a global shared color stretch, and lays the thumbnails out in an aspect-matched grid with one shared colorbar. Each panel is titled with its filename, auto-shrunk to fit the panel width.

Parameters:
  • hillshade (bool, optional) – If True (default), draw a gray hillshade underlay beneath each DEM and render the DEM semi-transparently on top, matching the convention used elsewhere in the package.

  • cmap (str, optional) – Colormap for the DEMs, default is “viridis”.

  • clim (tuple or None, optional) – Color limits (min, max). If None (default), a global percentile stretch shared across all rasters is computed via ColorBar.

  • cbar_label (str, optional) – Label for the shared colorbar, default is “Elevation (m HAE)”.

  • panel_size (float, optional) – Longest-edge size of each panel in inches, default 3.0.

  • dpi (int or None, optional) – Save resolution. If None (default), matched to the rendered detail (so one source pixel ~ one image pixel), then lowered if needed to respect max_filesize_mb and clamped to max_dpi.

  • max_dpi (int, optional) – Upper bound on the auto dpi to keep file size in check, default 600.

  • max_filesize_mb (float, optional) – Soft cap on the output PNG size in MB, default 10. The auto dpi is reduced so the total rendered pixel count stays within an estimated budget; this keeps galleries of many rasters from exceeding the cap. Ignored when dpi is given explicitly.

  • save_dir (str or None, optional) – Directory to save the figure, default is None (don’t save).

  • fig_fn (str or None, optional) – Filename for the saved figure, default is None.

Returns:

The gallery figure.

Return type:

matplotlib.figure.Figure

downsample = 'auto'#
raster_list#
asp_plot.gallery.GALLERY_TARGET_PX = 1200#
asp_plot.gallery.logger#