asp_plot.stereo_geometry#

Attributes#

Classes#

StereoGeometryPlotter

Create visualizations of stereo geometry for satellite imagery.

Functions#

camera_files_from_stereo_run(processing_directory, ...)

Recover the camera metadata files named in a stereo run's command.

Module Contents#

class asp_plot.stereo_geometry.StereoGeometryPlotter(directory=None, add_basemap=True, inputs=None, **kwargs)#

Create visualizations of stereo geometry for satellite imagery.

This class composes a StereopairMetadataParser to provide plotting capabilities for stereo geometry visualization, including skyplots showing satellite viewing angles and map views showing footprints and satellite positions. Metadata access goes through the parser attribute rather than inheritance, keeping the (sensor-agnostic) plotting concerns separate from the (sensor-specific) metadata parsing.

directory#

Path to directory containing XML files

Type:

str

parser#

The composed metadata parser used to extract stereo-pair geometry

Type:

StereopairMetadataParser

add_basemap#

Whether to add a basemap to map plots, default is True

Type:

bool

Examples

>>> plotter = StereoGeometryPlotter('/path/to/stereo/directory')
>>> plotter.stereo_geom_plot(save_dir='/path/to/output', fig_fn='stereo_geom.png')
get_scene_string(p, key='catid1_dict')#

Format scene metadata as a string.

Creates a formatted string with key metadata for a scene, including catalog ID, GSD, viewing angles, and acquisition parameters.

Parameters:
  • p (dict) – Stereo pair dictionary containing scene metadata

  • key (str, optional) – Key for the scene dictionary within the pair dictionary, default is “catid1_dict”

Returns:

Formatted string with scene metadata

Return type:

str

get_title(p)#

Generate a comprehensive title for stereo geometry plots.

Creates a multi-line title string that includes stereo pair name, acquisition time information, stereo geometry parameters, and key metadata for both scenes.

Parameters:

p (dict) – Stereo pair dictionary containing metadata

Returns:

Formatted multi-line title string

Return type:

str

Notes

The title includes pairname, center datetime, time offset, convergence angle, base-to-height ratio, bisector elevation angle, asymmetry angle, intersection area, and metadata for both scenes.

map_plot(ax, p, map_crs='EPSG:3857', title=True, tight_layout=True)#

Create a map view of satellite paths and image footprints.

Plots the satellite ground tracks (ephemeris) and the image footprints for both images in a stereo pair on a map.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes object to plot on

  • p (dict) – Stereo pair dictionary with metadata from get_pair_dict()

  • map_crs (str, optional) – Coordinate reference system for the map, default is “EPSG:3857” (Web Mercator)

  • title (bool, optional) – Whether to add a title to the plot, default is True

  • tight_layout (bool, optional) – Whether to apply tight layout to the figure, default is True

Returns:

Modifies the provided axes object in-place

Return type:

None

Notes

  • Satellite footprints are shown as polygons

  • Satellite paths (ephemeris) are shown as point tracks

  • The start of each satellite path is marked with a white circle

  • A basemap is added if self.add_basemap is True

Credit#

Adapted from David Shean’s notebook: dshean/dgtools

satellite_position_orientation_plot(save_dir=None, fig_fn=None)#

Create a visualization of satellite position and orientation data.

Generates a 3-row x N-column figure (one column per scene): - Row 0: Map of satellite positions colored by position covariance std

(plain positions when the sensor provides no covariance, e.g. DIMAP; footprint only, titled “not provided”, when no positions can be had at all — RPC-only products)

  • Row 1: Roll, pitch, yaw over time — computed relative to the orbital reference frame for sensors reporting quaternions, or as delivered for sensors reporting angles directly (the frame is named in the panel title); annotated as not provided for sensors reporting no attitude at all (ASTER)

  • Row 2: Attitude covariance trace std over time (annotated as not provided when the sensor has no attitude covariance)

Parameters:
  • save_dir (str, optional) – Directory to save the figure, default is None (figure not saved)

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

Returns:

The created figure object (not shown automatically)

Return type:

matplotlib.figure.Figure

skyplot(ax, p, title=True, tight_layout=True)#

Create a polar plot showing satellite viewing geometry.

This plot shows the satellite azimuth and elevation angles for both images in a stereo pair on a polar plot, where azimuth is the angle and (90 - elevation) is the radius.

Parameters:
  • ax (matplotlib.axes.PolarAxes) – Polar axes object to plot the skyplot on

  • p (dict) – Stereo pair dictionary with metadata from get_pair_dict()

  • title (bool, optional) – Whether to add a title to the plot, default is True

  • tight_layout (bool, optional) – Whether to apply tight layout to the figure, default is True

Returns:

Modifies the provided axes object in-place

Return type:

None

Notes

In the polar plot: - The origin represents 90° elevation (satellite directly overhead) - The outer edge represents 40° elevation (50° from zenith) - Azimuth is measured clockwise from North (0°) - The symbols represent the satellite positions for each image - The dashed line connects the two satellite positions

stereo_geom_plot(save_dir=None, fig_fn=None)#

Create stereo geometry visualization(s).

For exactly two scenes this produces a single figure (skyplot + map + full pairwise-stats title) — unchanged from prior behavior. For more than two scenes it produces, as separate files:

  • one overview figure with all scenes color-coded (skyplot + map), and

  • one figure per pair (every N-choose-2 combination), each with the full pairwise stats in its title.

Parameters:
  • save_dir (str, optional) – Directory to save the figure(s), default is None (not saved).

  • fig_fn (str, optional) – Filename for the two-scene figure; for N>2 it is the stem from which <stem>_overview.png and <stem>_<labelA>_<labelB>.png are derived (label is the CATID, or pairN if a CATID is missing).

Returns:

The filename(s) saved (empty if save_dir/fig_fn were not provided).

Return type:

list of str

Notes

Each figure’s map uses a local transverse Mercator projection centered on the relevant footprints to minimize distortion.

add_basemap = True#
directory#
parser#
asp_plot.stereo_geometry.camera_files_from_stereo_run(processing_directory, stereo_directory)#

Recover the camera metadata files named in a stereo run’s command.

Parses the run’s *log-stereo*.txt command line for camera metadata tokens (.xml/.XML: WorldView camera files, Pléiades DIMAPs; the image tokens themselves for an RPC-only run, which names no camera files) so the stereo geometry can be scoped to the scenes the run actually used rather than every metadata file in the processing directory — the two differ when a directory holds scenes for several runs (e.g. multi-view subsets). Relative tokens are resolved against processing_directory (ASP logs record the command as typed, and asp_report reports are anchored there), falling back to the token’s basename in that directory.

Parameters:
  • processing_directory (str) – ASP processing directory the report is anchored to.

  • stereo_directory (str) – Stereo subdirectory (relative to processing_directory) containing the *log-stereo*.txt files.

Returns:

Resolved metadata file paths in command order (deduplicated), or None if there is no parseable log, the command names fewer than two metadata files (e.g. CSM .json cameras), or a named file cannot be found — callers should then fall back to directory-based discovery.

Return type:

list of str or None

asp_plot.stereo_geometry.logger#