spindoctor.config
YAML-backed configuration for SpinDoctor.
Loads and merges settings from bundled defaults and optional user YAML files
using ruamel.yaml.YAML (safe typ), then exposes sections as
spindoctor.support.attrdict.AttrDict for attribute-style access. The
Config class is the main public entry; helpers such as
_as_str_list() validate list-shaped YAML fragments used when building
config structures.
- class Config[source]
Bases:
objectManages configuration settings for the navigation system.
This class handles loading, updating, and accessing configuration settings from YAML files. It provides access to various configuration sections through properties and methods.
- property backplanes: Any
Returns backplanes configuration, including bodies, rings, and target LIDs.
- property body_shape: Any
Returns the per-body shape catalogue (
config_220_body_shape.yaml).Each entry is keyed by SPICE body name (e.g.
MIMAS) and exposesradii_km,ellipsoid_rms_residual_km,crater_scale_km,albedo_mean,albedo_variation, andshape_class_hint. Missing-body lookups returnNonefromAttrDict.get; downstream code applies the conservative fallback (10% radius default, reliability cap 0.3).
- category(category: str) AttrDict[source]
Returns the configuration settings for the specified category.
The result is cached per category and rebuilt on config reload (see
_update_attrdicts), matching the caching semantics of the named section properties. Config is treated read-only; mutating the returned AttrDict is not supported.
- ensure_loaded() None[source]
Load bundled default YAML if not already loaded.
Safe to call repeatedly; delegates to
read_config()with no path (same early-return behavior when data is already present).
- fuzzy_satellites(planet: str) list[str][source]
Returns the list of fuzzy satellites for the specified planet.
- Parameters:
planet – The name of the planet to get fuzzy satellites for.
- Returns:
A list of fuzzy satellite names for the specified planet.
- property override_paths: tuple[str, ...]
The user/CLI override config files applied, in application order.
Bundled default files (the
config_filesglob loaded byread_config()with no path) are not overrides and never appear here; only files loaded viaupdate_config()withread_default=True(usernav_default_config.yamlor--config-filepaths) or an explicitread_config()path are recorded.
- read_config(config_path: str | Path | None = None, reread: bool = False) None[source]
Reads configuration from the specified YAML file.
- Parameters:
config_path – Path to the configuration file. If None, uses the default config files.
reread – Whether to reread the configuration file if it has already been read.
- Raises:
ValueError – If any registered NavTechnique’s confidence spec references an attribute the technique does not declare. Validation runs once per
read_configinvocation.
- resolved_config_hash() str[source]
Return a stable sha256 hex digest of the fully-resolved config.
The merged config dict (bundled defaults plus every applied override) is serialized deterministically – mapping keys are stringified and sorted, list order is preserved – and hashed, so two configs with identical resolved content produce identical digests regardless of load order or comment/whitespace changes in the source YAML files.
- Returns:
64-character sha256 hex digest of the resolved config content.
- ring_satellites(planet: str) list[str][source]
Returns the list of ring satellites for the specified planet.
- Parameters:
planet – The name of the planet to get ring satellites for.
- Returns:
A list of ring satellite names for the specified planet.
- satellites(planet: str) list[str][source]
Returns the list of satellites for the specified planet.
- Parameters:
planet – The name of the planet to get satellites for.
- Returns:
A list of satellite names for the specified planet.
- update_config(config_path: str | Path, read_default: bool = True) None[source]
Updates the current configuration with values from the specified YAML file.
When
read_defaultis true the merged YAML is re-validated against every registeredNavTechniqueso per-technique overrides (confidence_specandtuning) take effect. The internal bootstrap path insideread_config()calls withread_default=Falseand validates once after the loop, since early default files are loaded beforeconfig_510_techniques.yamlhas populated the techniques block.- Parameters:
config_path – Path to the configuration file containing update values.
read_default – Whether to read the default configuration file if no config has been previously read.
- get_backplane_results_root(arguments: Namespace, config: Config) str[source]
Get the backplane results root from the arguments, configuration, or environment.
First look in arguments.backplane_results_root, then in config.environment.backplane_results_root, then in the environment variable NAV_BACKPLANE_RESULTS_ROOT.
- Parameters:
arguments – The parsed arguments. config: The configuration possibly containing the
section. (environment)
- Returns:
The backplane results root.
- Raises:
ValueError – If the backplane results root cannot be determined.
Get the navigation root from the arguments, configuration, or environment.
First look in arguments.nav_results_root, then in config.environment.nav_results_root, then in the environment variable NAV_RESULTS_ROOT.
- Parameters:
arguments – The parsed arguments. config: The configuration possibly containing the
section. (environment)
- Returns:
The navigation results root.
- Raises:
ValueError – If the navigation results root cannot be determined.
- get_pds4_bundle_results_root(arguments: Namespace, config: Config) str[source]
Get the PDS4 bundle root from the arguments, configuration, or environment.
First look in arguments.bundle_results_root, then in config.environment.bundle_results_root, then in the environment variable NAV_BUNDLE_RESULTS_ROOT.
- Parameters:
arguments – The parsed arguments. config: The configuration possibly containing the
section. (environment)
- Returns:
The PDS4 bundle root.
- Raises:
ValueError – If the PDS4 bundle root cannot be determined.
- load_default_and_user_config(arguments: Namespace, config: Config) None[source]
Load the default and user configuration (if any).
- Parameters:
arguments – The parsed arguments containing the config_file argument.
config – The configuration to update.
Logger instances and setup for the SpinDoctor pipeline.
Provides two PdsLogger instances:
MAIN_LOGGER("sd_offset") – top-level program events, written to stdout and to a timestamped logfile underNAV_RESULTS_ROOT/logs/sd_offset/.IMAGE_LOGGER("nav_image") – per-image processing events; both its stdout handler and its per-image logfile handler are attached as local handlers inside eachlogger.open()context so they are active only while that image is being processed.
Call setup_logging() from main() after the nav-results root and CLI
arguments have been resolved. It is safe to call more than once: existing
MAIN_LOGGER handlers are removed before new ones are attached.
- image_log_handlers(image_log_path: FCPath, arguments: Namespace | None, config: Config) list[Handler][source]
Create local handlers for a single image: a stdout handler and a file handler.
Both levels are resolved from
arguments, thenconfig.general, then"INFO". The returned handlers should be passed toIMAGE_LOGGER.open()so they are active only while that image is being processed and are automatically removed when that context exits.- Parameters:
image_log_path – Destination path for this image’s log file.
arguments – Parsed CLI arguments, or None to fall back entirely to config.
config – Navigation configuration.
- Returns:
A list containing a stdout stream handler and a file handler for the image log.
- Raises:
TypeError – If a configured log level is not a string or
None.ValueError – If a configured log level string is empty or not a standard name.
- setup_logging(arguments: Namespace, config: Config, nav_results_root_str: str) None[source]
Configure MAIN_LOGGER with stdout and a timestamped file handler.
Reads each log level from
argumentsfirst, then fromconfig.general, then falls back to"INFO". The main logfile is written as a timestamped file under{nav_results_root}/logs/sd_offset/.IMAGE_LOGGER handlers are not configured here; both its console and per-image file handlers are attached as local handlers inside each
IMAGE_LOGGER.open()context viaimage_log_handlers(). However, the image log levels from--log-level-image-consoleand--log-level-image-fileare validated here so that invalid values are caught at startup (before the batch loop) alongside the main-level validation.- Parameters:
arguments – Parsed CLI arguments; may carry
log_level_main_console,log_level_main_file,log_level_image_console, andlog_level_image_fileattributes.config – Navigation configuration providing
general.*fallback values.nav_results_root_str – Local filesystem path to the navigation results root.
- Raises:
TypeError – If a configured log level is not a string or
None.ValueError – If a configured log level string is empty or not a standard name.