lunar_toolkit.config
¶
Flat YAML run configuration for lunar sfs: load, validate, merge, resolve regions and dump.
RUNS_DIR_ENV = 'LUNAR_RUNS_DIR'
module-attribute
¶
dem: pgda (or no dem with a region): the region's PGDA LOLA 5 m surf DEM.
ConfigError
¶
Bases: ValueError
An invalid configuration: unknown key, wrong type or inconsistent settings.
RunConfig(work_dir=Path('sfs_work'), runs_dir=None, dem=None, region=None, crop_km=None, crop_center=None, aoi=None, sources=list(), from_file=None, max_slew=None, max_pixel_scale=1.5, max_images=None, pgda_dir=None, data_dir=None, checksums=True, sfs=SfsConfig())
dataclass
¶
Everything a lunar sfs run needs: inputs, region and the
SfsConfig.
In YAML the run keys below and the SfsConfig fields share one flat
mapping. Relative paths are relative to the current directory.
| Parameters: |
|
|---|
from_dict(data, source='config')
¶
A validated RunConfig from a flat mapping (keys as in KEYS).
| Raises: |
|
|---|
to_dict(cfg)
¶
Flat, YAML / JSON-ready mapping of every setting (run keys first).
merge(cfg, overrides, source='overrides')
¶
cfg with overrides applied; option dicts are merged key by key, other values replaced.
load_config(path)
¶
Read and validate a YAML config (an empty file gives the defaults).
dump_config(cfg, path=None)
¶
YAML text of every setting (written to path when given).
pgda_file(region, kind, out_dir=None, download=True)
¶
Local path of a region's PGDA LOLA 5 m raster (surf, ldec, toterr, ...).
Downloaded into out_dir/<site>/ when missing and download; otherwise the
expected path (<site>_final_adj_5mpp_<kind>.tif, <site>_final_adj.xyzi)
is returned without touching the network or the disk.
region_id(region)
¶
Bertone et al. product prefix of a region, e.g. A311 for Malapert Massif.
resolve(cfg, download=True)
¶
Fill what region implies: projwin, region_id and the PGDA prior DEM.
An explicit projwin wins, then aoi (the crop is computed from it at run
time), then a crop_km window, then the region ROI. dem: pgda (or none)
is the region's PGDA surf DEM, downloaded when missing and download.
| Raises: |
|
|---|
search_aoi(cfg)
¶
Image-search AOI: aoi, else the region crop (projwin as lon/lat WKT), else None.
load_sources(cfg)
¶
sources plus the non-comment lines of from_file.