lunar_toolkit.asp
¶
Ames Stereo Pipeline wrappers: positional inputs as arguments, other options as keywords.
MatchOffsetStats(image, p25, p50, p75, p85, p95, count)
dataclass
¶
One row of <prefix>-mapproj_match_offset_stats.txt (metres; -1 when no matches).
ResidualStats(image, mean, median, count)
dataclass
¶
One row of <prefix>-final_residuals_stats.txt (pixels).
Raster(data, x0, y0, dx, dy)
dataclass
¶
Band 1 of a north-up raster: data[row, col] (NaN = nodata), top-left corner and pixel size.
mapproject(dem, image, out, camera=None, *, cwd=None, **options)
¶
Orthorectify image onto dem (tr=, t_projwin=, bundle_adjust_prefix=).
bundle_adjust(images, out_prefix, cameras=(), *, mapprojected=None, dem=None, parallel=False, cwd=None, **options)
¶
Run bundle_adjust (or parallel_bundle_adjust with parallel).
mapprojected (same order as images) and the dem they were projected
onto become --mapprojected-data, which finds matches between images of
very different illumination. Returns out_prefix.
Raises ToolError when the run writes no fresh
.adjust file for some image: ASP exits 0 even when it finds nothing to
optimize ("No points to optimize ... Cannot continue").
apply_transform(images, transform, out_prefix, cameras=(), *, input_adjustments_prefix=None, cwd=None, **options)
¶
Apply a pc_align 4×4 transform to (adjusted) cameras, without optimizing.
sfs(dem, images, out_prefix, cameras=(), *, parallel=False, cwd=None, **options)
¶
Run sfs (or parallel_sfs); returns <out_prefix>-DEM-final.tif.
parse_sun_angles(text)
¶
Parse sfs --query output into per-image Sun azimuth / elevation.
sun_angles(dem, images, cameras=(), *, out_prefix=Path('sfs_query/run'), cwd=None, **options)
¶
Sun azimuth (from north) and elevation per image at the DEM centre.
Runs sfs --query; results come back in input order. Sort by azimuth
before bundle adjustment and SfS.
pc_align(reference, source, out_prefix, *, max_displacement, cwd=None, **options)
¶
Align source to reference; returns <out_prefix>-transform.txt.
point2dem(cloud, *, cwd=None, **options)
¶
Grid a point cloud; returns <prefix>-DEM.tif (prefix from o= or the cloud).
stereo(left, right, out_prefix, left_camera=None, right_camera=None, *, dem=None, parallel=True, cwd=None, **options)
¶
Run parallel_stereo (or stereo); returns <out_prefix>-PC.tif.
Pass dem when the inputs are mapprojected onto it.
dem_mosaic(inputs, out, *, cwd=None, **options)
¶
Mosaic DEMs or images (max=True for a maximally-lit mosaic).
geodiff(dem1, dem2, out_prefix, *, cwd=None, **options)
¶
dem1 - dem2 (absolute=True for |diff|); returns <out_prefix>-diff.tif.
gdal_translate(src, dst, *, projwin=None, tr=None, r=None, cwd=None, **options)
¶
Crop (projwin = ulx uly lrx lry) and / or resample (tr metres, r method).
bundle_adjust_file_name(prefix, image, camera=None)
¶
<prefix>-<stem>.adjust as ASP names it (stem of camera, else image, up to the last dot).
read_mapproj_offset_stats(path)
¶
Parse bundle_adjust --mapproj-dem per-image offsets, keyed by image file name.
Format (ASP saveMapprojOffsets): # image_name 25% 50% 75% 85% 95% count.
read_residual_stats(path)
¶
Parse per-camera reprojection errors (# Image, mean, median, count), keyed by file name.
read_residual_norms(path)
¶
Per-image reprojection error norms (pixels) from <prefix>-final_residuals_raw_pixels.txt.
The file has, per image, a name, count line followed by count ex, ey lines.
image_subset(images, out, *, threshold, cwd=None, **options)
¶
Run image_subset; returns (image, contributing pixels) best first.
Writes the image list to <out>.in.txt; t_projwin=(xmin, ymin, xmax, ymax) limits
the evaluated extent. Empty in a dry run.
raster_info(path)
¶
gdalinfo -json of path (empty in a dry run).
raster_bounds(path)
¶
(ulx, uly, lrx, lry) of a north-up raster, or None in a dry run.
srs_proj4(path)
¶
PROJ string of a raster's spatial reference (gdalsrsinfo -o proj4; empty in a dry run).
read_raster(path, *, projwin=None, outsize=None, r='average')
¶
Read (a resampled window of) a raster through gdal_translate -of AAIGrid /vsistdout/.
projwin (ulx uly lrx lry) may extend past the raster (filled with nodata) and
outsize (columns, rows) resamples with r, so several images read with the
same window share one grid. Meant for small grids; returns None in a dry run.
parse_aaigrid(text)
¶
Parse ESRI ASCII grid text (as GDAL's AAIGrid driver writes it).