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_pprc … stereo_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#
A single ASP log file, parsed through the matching versioned adapter. |
|
Adapter describing how to read one ASP log layout. |
Functions#
|
Register an |
|
Return an adapter instance for a log whose first line is |
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 asbundle_adjust ...orstereo .... ReturnsNoneif no command line was found.
- property asp_version#
The ASP version string, or
Noneif the banner is absent.
- property command#
The full command line (tool + args), or
Noneif 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 inASP_LOG_FORMATSahead of the default.- parse_command_line(lines)#
Locate the tool invocation line in
lines.Returns
(tool, command)wheretoolis the executable basename (e.g.stereo_tri) andcommandis the full stripped command line, orNoneif 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, orNone.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
datetimefrom a leading timestamp, orNone.
- 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
AspLogFormatsubclass 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 itssupports(), then register it here. Registered formats are consulted byselect_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#