asp_plot.asp_log#

Versioned adapter for parsing NASA Ames Stereo Pipeline (ASP) log files.

ASP writes one plain-text log per tool invocation (bundle_adjust, stereo_pprcstereo_tri, point2dem). Each log starts with a version banner, then the literal command line that was run, then timestamped console lines. The exact layout has been stable across ASP 3.x but is not guaranteed to stay fixed.

Rather than scatter hardcoded regexes and line.split()[0] indexing through the call sites (which fail silently when the format drifts), all format knowledge lives here behind a small adapter that is keyed by ASP version. A new ASP log layout becomes a new AspLogFormat subclass registered in ASP_LOG_FORMATS; everything downstream keeps working through the stable AspLog interface.

When a field cannot be parsed the adapter returns None and logs a warning (at logger level) so format drift surfaces instead of being swallowed.

Attributes#

Classes#

AspLog

A single ASP log file, parsed through the matching versioned adapter.

AspLogFormat

Adapter describing how to read one ASP log layout.

Functions#

register_format(fmt[, prepend])

Register an AspLogFormat subclass for adapter selection.

select_format(banner_line)

Return an adapter instance for a log whose first line is banner_line.

Module Contents#

class asp_plot.asp_log.AspLog(path)#

A single ASP log file, parsed through the matching versioned adapter.

Reads the file once on construction and exposes the parsed fields as properties. Selecting the adapter from the version banner means a caller never needs to know which ASP version produced the log.

canonical_command(tool_name)#

Return the command line with its executable replaced by tool_name.

ASP logs the executable as an absolute path (or a stage-specific name like stereo_tri); reports want a canonical, path-free invocation such as bundle_adjust ... or stereo .... Returns None if no command line was found.

property asp_version#

The ASP version string, or None if the banner is absent.

property command#

The full command line (tool + args), or None if not found.

property first_timestamp#

The earliest console timestamp, or None.

format#
property last_timestamp#

The latest console timestamp, or None.

path#
property reference_dem#

The reference-DEM path announced in the log, or None.

property timestamps#

All parsed console timestamps, in file order.

property tool#

The executable basename of the invocation (e.g. stereo_tri).

class asp_plot.asp_log.AspLogFormat#

Adapter describing how to read one ASP log layout.

The base class implements the ASP 3.x layout. To support a drifted format, subclass it, override the class attributes (or methods) that changed, give it a distinguishing supports(), and register the subclass in ASP_LOG_FORMATS ahead of the default.

parse_command_line(lines)#

Locate the tool invocation line in lines.

Returns (tool, command) where tool is the executable basename (e.g. stereo_tri) and command is the full stripped command line, or None if no known ASP tool invocation is found.

The line is found by matching the basename of its first token against ASP_TOOL_NAMES, skipping the banner, build metadata and timestamped console lines – robust against substring collisions in later log output.

parse_reference_dem(lines)#

Return the last reference-DEM path announced in lines, or None.

The last match wins to mirror the historical behavior (ASP re-announces the DEM and the final mention is the one used).

parse_timestamp(line)#

Return the datetime from a leading timestamp, or None.

parse_version(banner_line)#

Return the ASP version string from the banner, or None.

classmethod supports(banner_line)#

Whether this adapter handles a log with the given first line.

The default ASP 3.x adapter claims any ASP 3.* banner.

name = 'asp-3.x'#
reference_dem_re#
timestamp_fmt = '%Y-%m-%d %H:%M:%S'#
timestamp_re#
version_banner_re#
asp_plot.asp_log.register_format(fmt, prepend=True)#

Register an AspLogFormat subclass for adapter selection.

The extension point for ASP format drift: when a future ASP version changes the log layout, subclass AspLogFormat, override what changed and its supports(), then register it here. Registered formats are consulted by select_format() in order, so by default a new (more specific) format is prepended ahead of the permissive ASP 3.x default.

asp_plot.asp_log.select_format(banner_line)#

Return an adapter instance for a log whose first line is banner_line.

Falls back to the default ASP 3.x adapter (with a warning) when no registered format claims the banner, so an unrecognized version degrades gracefully instead of dropping all fields.

asp_plot.asp_log.ASP_LOG_FORMATS#
asp_plot.asp_log.ASP_TOOL_NAMES#
asp_plot.asp_log.DEFAULT_FORMAT#
asp_plot.asp_log.STEREO_STEP_ORDER = ('stereo_pprc', 'stereo_corr', 'stereo_blend', 'stereo_rfne', 'stereo_fltr', 'stereo_tri')#
asp_plot.asp_log.logger#