slv.inversion.sweep#

Parameter sweep harness for SLV methane inversions.

Run many inversion configurations (run()) in one pass, collect goodness-of-fit metrics (targeting reduced chi² ≈ 1), and analyse which parameter combinations produce stable, well-fitting inversions.

Quick start — single-node sweep#

from slv.inversion.sweep import Sweep, SweepResults

# Create and run a parameter sweep
sweep = Sweep(
    cache="/scratch/my_sweep/cache",
    prior_base_std=[0.01, 0.019, 0.03],
    prior_std_frac=[0.3, 0.5, 0.7],
    prior_time_scale=["16d", "32d", "64d"],
    mdm_config=[
        {},  # all defaults
        {"transport": {"fraction": 0.6}},
        {"transport": {"fraction": 1.0}},
    ],
)
# 3 × 3 × 3 × 3 = 81 configs
results = sweep.run(results_dir="/scratch/my_sweep", n_jobs=8)

best = results.best(tol=0.1)  # chi² ∈ [0.9, 1.1]
results.plot_chi2("cfg_prior_base_std")
cfg, pipeline = results.to_config(best.iloc[0])

SLURM job-array usage#

# 1. Generate the grid without running (n_jobs=0)
python -c "
from slv.inversion.sweep import Sweep
sweep = Sweep(cache='/scratch/sweep/cache', ...)
sweep.run(results_dir='/scratch/sweep', n_jobs=0)
"

# 2. Submit one job per config
sbatch --array=0-80 job.sh

# job.sh:
# python -c "
# from slv.inversion.sweep import run_sweep_job
# run_sweep_job('/scratch/sweep')
# "

Attributes

Pipeline

the function that solves one config, as run().

Functions

collect_metrics

Extract goodness-of-fit and flux metrics from a solved inversion.

config_id

Return a stable 16-char hex identifier for a config.

run_sweep_job

Run a single config from a pre-serialised sweep grid (SLURM job arrays).

Classes

Sweep

Object-oriented interface for parameter sweeps.

SweepResults

Wraps sweep_results.csv for post-sweep analysis.