asp_plot.processing_parameters#
Attributes#
Classes#
Extract and manage processing parameters from ASP log files. |
Module Contents#
- class asp_plot.processing_parameters.ProcessingParameters(processing_directory, bundle_adjust_directory=None, stereo_directory=None)#
Extract and manage processing parameters from ASP log files.
This class extracts parameters from ASP processing log files, including bundle adjustment, stereo, and point2dem logs. It provides methods to parse these logs and obtain command lines, run times, and other relevant processing information.
All of the format-specific parsing (version banner, command line, timestamps, reference DEM) is delegated to the versioned adapter in
asp_plot.asp_log, so this class stays focused on locating the right log files and assembling the parameter dictionary.Examples
>>> params = ProcessingParameters('/path/to/asp', 'ba', 'stereo') >>> params_dict = params.from_log_files() >>> print(params_dict['bundle_adjust']) # Print bundle adjustment command line >>> print(params_dict['stereo_run_time']) # Print stereo processing time
- from_bundle_adjust_log()#
Extract parameters from the bundle adjustment log file.
Parses the bundle adjustment log file to extract the command line, identifies the reference DEM, and calculates the run time.
- Returns:
A tuple containing (bundle_adjust_params, run_time, reference_dem) where: - bundle_adjust_params: str, the canonical
bundle_adjustcommand - run_time: str, formatted run time (e.g., “2 hours and 15 minutes”) - reference_dem: str, path to the reference DEM used (”” if none)- Return type:
- Raises:
ValueError – If the bundle adjustment log file cannot be found
- from_log_files()#
Extract processing parameters from log files.
Parses the bundle adjustment, stereo, and point2dem log files to extract command lines, run times, and other parameters.
- Returns:
Dictionary containing processing parameters: - processing_timestamp: When processing was performed - reference_dem: Path to reference DEM - bundle_adjust: Bundle adjustment command line - bundle_adjust_run_time: Time to run bundle adjustment - stereo: Stereo command line - stereo_run_time: Time to run stereo - point2dem: point2dem command line - point2dem_run_time: Time to run point2dem
- Return type:
Notes
If bundle adjustment was not run, its command and run time are set to placeholder values. Reference DEM is searched for in either bundle adjustment or stereo logs, depending on availability.
- from_point2dem_log()#
Extract parameters from the point2dem log file.
Parses the point2dem log file to extract the command line and calculates the run time.
- Returns:
A tuple containing (point2dem_params, run_time) where: - point2dem_params: str, the canonical
point2demcommand line - run_time: str, formatted run time (e.g., “0 hours and 45 minutes”)- Return type:
- Raises:
ValueError – If the point2dem log file cannot be found
- from_stereo_log(search_for_reference_dem=False)#
Extract parameters from the stereo log files.
Parses the stereo log files to extract command lines, processing timestamp, and optionally searches for reference DEM information. The earliest and latest stereo stages present (per
asp_plot.asp_log.STEREO_STEP_ORDER) bracket the run, so the command/reference DEM come from the final stage and the run-time span from first-stage start to last-stage end.- Parameters:
search_for_reference_dem (bool, optional) – Whether to search for reference DEM in the log files, default is False
- Returns:
If search_for_reference_dem is False, returns: (processing_timestamp, stereo_params, run_time) where: - processing_timestamp: datetime, when processing started - stereo_params: str, the canonical
stereocommand line - run_time: str, formatted run timeIf search_for_reference_dem is True, additionally returns: - reference_dem: str, path to the reference DEM used (”” if none)
- Return type:
- Raises:
ValueError – If stereo log files cannot be found
Notes
The stereo process proceeds through several steps: 1. stereo_pprc - preprocessing 2. stereo_corr - correlation 3. stereo_blend - tile blending (logs in tile/ dirs) 4. stereo_rfne - refinement (logs in tile/ dirs) 5. stereo_fltr - filtering 6. stereo_tri - triangulation
This method uses the first stage’s log for the start time and the last stage’s log for the end time to calculate total runtime.
- get_asp_version()#
Extract the ASP version string from the first available log file.
- Returns:
ASP version string (e.g., “3.4.0-alpha”), or “N/A” if not found.
- Return type:
- get_mapproject_commands(stereo_command=None)#
Reconstruct
mapprojectcommands from mapprojected scene metadata.ASP’s
mapprojectdoes not write a log file, but it stamps the reconstruction inputs into each output GeoTIFF header (issue #96). The mapprojected scenes live alongside the raw inputs in the processing root and/or the bundle-adjust directory, so we scan those plus the stereo directory.- Parameters:
stereo_command (str, optional) – The stereo command line for this run. When supplied, only mapprojected outputs that the stereo run actually consumed (their filename appears in the command) are reported – so a non-mapprojected run that shares a directory with mapprojected scenes does not spuriously list a mapproject step.
- Returns:
Reconstructed
mapprojectcommand lines (one per mapprojected input image found), sorted; empty if the run was not mapprojected or the outputs carry no ASP metadata.- Return type:
- get_reference_dem(logfile)#
Extract reference DEM path from a log file.
- Parameters:
logfile (str) – Path to the log file to search
- Returns:
Path to the reference DEM if found, empty string otherwise
- Return type:
Notes
Parsing is delegated to the versioned adapter, which recognizes the known ASP phrasings (“Loading DEM:”, “Using input DEM:”, “Input DEM:”).
- get_run_time(logfiles)#
Calculate the run time from timestamps in log files.
Extracts the earliest timestamp from the first log file and the latest timestamp from the last log file to compute the total execution time.
- Parameters:
logfiles (list of str) – Paths to log files to analyze. The first file is used to find the start time, and the last file is used to find the end time.
- Returns:
Formatted run time as “X hours and Y minutes”, or “N/A” if timestamps couldn’t be found
- Return type:
Notes
This is a helper method used by other methods to calculate processing run times. It expects log files to have timestamps in the format “YYYY-MM-DD HH:MM:SS”.
If only one log file is provided, it will be used for both start and end times. This is useful for single-stage processes.
- bundle_adjust_directory = None#
- bundle_adjust_log#
- full_ba_directory#
- full_stereo_directory#
- point2dem_log#
- processing_directory#
- processing_parameters_dict#
- stereo_directory = None#
- stereo_logs#
- asp_plot.processing_parameters.logger#