Add gallery plotting for many DEM outputs (#11)#120
Merged
Conversation
Bring the legacy original_code/gallery.py into the modular package as a reusable GalleryPlotter(Plotter) class plus a gallery CLI command. - Plots a grid of DEM thumbnails sharing a single global percentile color stretch and one shared colorbar. - Reuses Raster (downsampled reads), ColorBar.find_common_clim, and save_figure; drops the pygeotools/imview dependencies. - Renders DEMs with the existing convention: gray hillshade underlay + semi-transparent viridis DEM (matches stereo.py _plot_dem_with_hillshade). - Auto grid layout (ported aspect-ratio formula) and auto downsampling. - Adds tests/test_gallery.py (grid math, shared clim, plotting with/without hillshade, save-to-disk, CLI smoke test) and import-test coverage.
…size cap Addresses review feedback on the gallery output: - Titles: shrink the per-panel font so the full filename fits within the panel width (no more oversized, overlapping titles). - Whitespace: size each panel box to the rasters' median aspect ratio and place panels with absolute positioning, so 1..N rasters (incl. non-square) pack tightly with no internal or trailing-cell whitespace. - Resolution/filesize: read more source detail (GALLERY_TARGET_PX 800->1200) and match save dpi to the rendered detail for crisp zoom, then cap dpi to a pixel budget so the PNG stays under max_filesize_mb (default 10) regardless of raster count. New --max_filesize_mb CLI option. Verified on the 7-DEM WorldView stack (8.3 MB) and 1/2/4-raster layouts.
The character-count font estimate undersized wide, digit/uppercase-heavy filenames, so titles still overflowed into neighboring panels. Measure the real text extent with an Agg renderer and scale the font by the width ratio, guaranteeing the full filename fits the panel width (shrinks when cramped, fills when roomy). Falls back to the heuristic estimate if measurement fails.
- Add docs/cli/gallery.md documenting the gallery CLI and GalleryPlotter API - List gallery in the CLI index (four -> five tools, card + toctree) - CHANGELOG entry for 1.15.0 - Bump version 1.14.1 -> 1.15.0 in pyproject.toml
from_directory now globs with recursive=True so '**' descends into subdirectories (e.g. '**/*-DEM.tif'), matching the common ASP layout where each pair lives in its own subdirectory. Previously the shared glob_file helper was non-recursive, so '**' collapsed to a single level and only explicit-depth patterns like '*/*-DEM.tif' worked. - Recursive glob in GalleryPlotter.from_directory (no change to glob_file) - Updated --pattern help and docs with subdirectory examples - Added test_from_directory_recursive
Embed a rendered 7-DEM WorldView gallery as a figure on the gallery CLI doc page. Store committed doc figures in a new docs/figures/ directory (docs/_static is Sphinx's static-asset dir and only holds the gitignored report copies). Figure regenerated at --max_filesize_mb 2 (~2 MB) to keep the repo lean while staying legible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11. Brings the legacy
original_code/gallery.pyinto the modular package as a robust, reusable class + CLI for visualizing a stack of DEMs.What's new
asp_plot/gallery.py—GalleryPlotter(Plotter)Raster(downsampled reads),ColorBar.find_common_clim, andsave_figure; drops the removedpygeotools/imviewdeps.viridisDEM (matchesstereo.py_plot_dem_with_hillshade),"Elevation (m HAE)"colorbar. Hillshade underlay on by default, toggleable.from_directory(directory, pattern="*-DEM.tif")resolves a directory + glob into the raster list, with recursive**support for DEMs nested in subdirectories (the common ASP per-pair layout). Also accepts an explicit file list.galleryCLI (asp_plot/cli/gallery.py) —--directory+--pattern(or explicitFILES),--hillshade/--no-hillshade,--cmap,--downsample,--max_filesize_mb,--title,--output_directory/--output_filename. Registered as agalleryentry point; saves into the working directory by default.Layout & quality decisions
--max_filesize_mb(default 10) regardless of raster count.Tests
tests/test_gallery.py: grid math, title-fit, shared clim, recursive globbing, end-to-end plotting (with/without hillshade), save-to-disk, and a CLI smoke test — reusing the tiny synthetic DEMs already intests/test_data/(no new fixtures).GalleryPlotter/asp_plot.galleryadded totests/test_imports.py. Full suite passes (network-only altimetry tests deselected locally).Docs & release prep
docs/cli/gallery.md(usage incl. subdirectories, full--help, Python API) + a rendered example figure stored in a new committeddocs/figures/dir (regenerated at ~2 MB to keep the repo lean). Listed in the CLI index.1.14.1 → 1.15.0(minor; new feature). Release auto-publishes on merge tomainper the existing workflow.Not in this PR (possible follow-ups)
asp_plotPDF report.Verified end-to-end on a 7-DEM WorldView stack and 1/2/4-raster layouts.