Skip to content

API reference

Generated from the docstrings in src/dscim_cil. The page is built from the source files without importing them, so it does not need dscim installed.

options

dscim_cil.options

Catalogue of the dscim option surface.

Every option dscim accepts, with its default, the pipeline stages that consume it, its status, and a source citation into dscim main @ 6a1f4d7e (cited as path:line).

__all__ module-attribute

__all__ = [
    "CATALOGUE",
    "COMPATIBILITY",
    "CONST_DISC_RATES",
    "DEFAULT_SAVE_FILES",
    "DISCOUNT_TYPES",
    "EXTRA_SAVE_FILES",
    "FAIR_AGGREGATIONS",
    "FORMULAS",
    "KNOWN_ECS_MASKS",
    "MODES",
    "PIPELINE",
    "RECIPES",
    "REDUCTIONS",
    "REQUIRED",
    "STATUSES",
    "Combination",
    "Option",
    "Stage",
    "Value",
    "option",
]

REQUIRED module-attribute

REQUIRED = _Required()

STATUSES module-attribute

STATUSES = ('supported', 'unsupported', 'dead', 'removed')

MODES module-attribute

MODES = ('ssp', 'rff')

FORMULAS module-attribute

FORMULAS = (
    "damages ~ -1 + np.power(anomaly, 2)",
    "damages ~ gmsl + np.power(gmsl, 2)",
    "damages ~ -1 + gmsl + np.power(gmsl, 2)",
    "damages ~ -1 + gmsl",
    "damages ~ anomaly + np.power(anomaly, 2)",
    "damages ~ -1 + anomaly + np.power(anomaly, 2)",
    "damages ~ -1 + gmsl + anomaly + np.power(anomaly, 2)",
    "damages ~ -1 + anomaly + np.power(anomaly, 2) + gmsl + np.power(gmsl, 2)",
    "damages ~ -1 + anomaly * gmsl + anomaly * np.power(gmsl, 2) + gmsl * np.power(anomaly, 2) + np.power(anomaly, 2) * np.power(gmsl, 2)",
    "damages ~ anomaly + np.power(anomaly, 2) + gmsl + np.power(gmsl, 2)",
    "damages ~ -1 + anomaly:gmsl + anomaly:np.power(gmsl, 2) + gmsl:np.power(anomaly, 2) + np.power(anomaly, 2):np.power(gmsl, 2)",
    "damages ~ -1 + gmsl:anomaly + gmsl:np.power(anomaly, 2)",
)

DISCOUNT_TYPES module-attribute

DISCOUNT_TYPES = (
    "constant",
    "constant_model_collapsed",
    "constant_gwr",
    "naive_ramsey",
    "euler_ramsey",
    "naive_gwr",
    "gwr_gwr",
    "euler_gwr",
)

CONST_DISC_RATES module-attribute

CONST_DISC_RATES = (0.01, 0.015, 0.02, 0.025, 0.03, 0.05)

DEFAULT_SAVE_FILES module-attribute

DEFAULT_SAVE_FILES = (
    "damage_function_points",
    "damage_function_coefficients",
    "damage_function_fit",
    "marginal_damages",
    "discount_factors",
    "uncollapsed_sccs",
    "scc",
    "uncollapsed_discount_factors",
    "uncollapsed_marginal_damages",
    "global_consumption",
    "global_consumption_no_pulse",
)

EXTRA_SAVE_FILES module-attribute

EXTRA_SAVE_FILES = (
    "ce_fair_pulse",
    "ce_fair_no_pulse",
    "global_consumption_pulse",
    "stat_uncertainty_iqr",
    "full_uncertainty_iqr",
)

FAIR_AGGREGATIONS module-attribute

FAIR_AGGREGATIONS = ('ce', 'mean', 'gwr_mean', 'median', 'median_params')

RECIPES module-attribute

RECIPES = ('adding_up', 'risk_aversion', 'equity')

REDUCTIONS module-attribute

REDUCTIONS = ('cc', 'no_cc')

KNOWN_ECS_MASKS module-attribute

KNOWN_ECS_MASKS = (
    "truncate_at_ecs995symmetric_passing_mask",
    "truncate_at_ecs990symmetric_passing_mask",
    "truncate_at_ecs950symmetric_passing_mask",
    "truncate_at_ecs830symmetric_passing_mask",
    "truncate_at_ecs750symmetric_passing_mask",
)

PIPELINE module-attribute

PIPELINE: tuple[Stage, ...] = (
    Stage(
        name="sum-sectors",
        summary="Sum member sectors' delta and histclim into an aggregate sector zarr (e.g. AMEL from agriculture+mortality+energy+labor).",
        consumes=("member sector damages zarrs (sectors.<name>.sector_path)",),
        produces=("aggregate sector damages zarr (its sector_path)",),
        collapses=(
            "no collapse: sums variables across sectors at identical dimensions (preprocessing.py sum_AMEL)",
        ),
        modes=("ssp",),
        library_call="dscim.preprocessing.preprocessing.sum_AMEL",
    ),
    Stage(
        name="reduce",
        summary="Collapse the batch dimension of sector damages against socioeconomics, producing the reduced-damage zarrs runs consume.",
        consumes=("sector damages zarrs (batch chunked at 15)", "econ zarr (external)"),
        produces=(
            "reduced zarrs: adding_up_{cc,no_cc}.zarr and risk_aversion_{cc,no_cc}_eta{eta}.zarr per sector",
        ),
        collapses=(
            "batch: mean for adding_up, certainty equivalent at eta for risk_aversion (preprocessing.py ce_from_chunk)",
        ),
        modes=("ssp",),
        library_call="dscim.preprocessing.preprocessing.reduce_damages",
    ),
    Stage(
        name="run",
        summary="Execute menu runs: fit damage functions (or load precomputed coefficients), apply FaIR, discount, and write SCC artifacts.",
        consumes=(
            "reduced zarrs (sectors without damage_function_path; ssp only)",
            "damage-function coefficient nc4s (sectors with damage_function_path; all rff sectors)",
            "climate files: gmst/gmsl fitting inputs, FaIR control/pulse, pulse conversion (external)",
            "econ zarr or rff socioeconomics nc4 (external)",
        ),
        produces=(
            "per-run artifacts named {recipe}_{discounting}_eta{eta}_rho{rho}_{artifact} under the save path",
        ),
        collapses=(
            "ssp and model: collapsed when discounting contains gwr (pooled damage-function fit, pop.mean(['model','ssp']); main_recipe.py collapsed_pop and damage_function_calculation)",
            "fair_dims (default [simulation]): collapsed by the FaIR aggregations ce/mean/median (main_recipe.py marginal_damages)",
            "discrate: a new dimension added by constant discounting, one entry per CONST_DISC_RATES value (main_recipe.py discounted_damages)",
            "rff mode: runid (10,000 draws) replaces gcm/rcp/ssp/model as the uncertainty dimensions; the ssp/model collapse happened upstream in the emulator weights (utils/rff.py weight_df; utils/menu_runs.py run_rff)",
        ),
        library_call="dscim MENU_OPTIONS[recipe](**kwargs).order_plate(order)",
    ),
    Stage(
        name="combine",
        summary="Merge coastal and AMEL damage-function coefficients into the combined (CAMEL) sector's coefficient files.",
        consumes=("coastal and AMEL coefficient nc4s written by run (fit sectors)",),
        produces=("combined-sector coefficient (and optionally fit) nc4s",),
        collapses=(
            "no collapse: concatenates coefficient variables from the two sources (midprocessing.py combine_CAMEL_coefs)",
        ),
        modes=("ssp",),
        library_call="dscim.preprocessing.midprocessing.combine_CAMEL_coefs",
    ),
    Stage(
        name="scc",
        summary="Compose SCCs from the uncollapsed run outputs: sum marginal damages times discount factors over years, deflate, and collapse the uncertainty dimension.",
        consumes=(
            "uncollapsed_marginal_damages and uncollapsed_discount_factors nc4s written by run",
        ),
        produces=("SCC files under scc.output",),
        collapses=(
            "year: summed out by the present-value integration (dscim-facts-epa scghg_utils.py:335-337)",
            "runid (rff) or the fair dims (ssp): collapsed per scc.collapse: mean, certainty_equivalent (adjustment factor (gcnp/pop)^(-eta) normalized at the pulse year, scghg_utils.py:352-357), or none",
        ),
    ),
)

CATALOGUE module-attribute

CATALOGUE: dict[str, Option] = {opt.name: opt for opt in _OPTIONS}

COMPATIBILITY module-attribute

COMPATIBILITY: tuple[Combination, ...] = (
    Combination(
        key="median-params-fair-dims",
        options=("fair_aggregation", "fair_dims"),
        kind="requires",
        description="fair_aggregation containing median_params requires fair_dims to be exactly [simulation]; dscim documents this and does not enforce it.",
        citation="main_recipe.py:47 (docstring); no matching assert in __init__",
    ),
    Combination(
        key="clip-gmsl-formula",
        options=("clip_gmsl", "formula"),
        kind="requires",
        description="clip_gmsl requires the formula to be one of the two gmsl-quadratic formulas.",
        citation="main_recipe.py:264-270 (assert)",
    ),
    Combination(
        key="equity-not-reduced",
        options=("recipe",),
        kind="forbidden",
        description="reduce.recipes may not include equity: reduce_damages has no equity branch, and the equity recipe reads risk_aversion reduced damages. Add risk_aversion to reduce.recipes instead.",
        citation="preprocessing.py (ce_from_chunk has adding_up and risk_aversion branches only); equity.py reads risk_aversion CEs",
        modes=("ssp",),
    ),
    Combination(
        key="rff-emission-scenarios-null",
        options=("emission_scenarios",),
        kind="requires",
        description="rff mode requires climate.emission_scenarios to be null so the rcp selection is skipped on runid-shaped FaIR files.",
        citation="simple_storage.py:58 docstring",
        modes=("rff",),
    ),
    Combination(
        key="rff-coefficients-required",
        options=("damage_function_path",),
        kind="requires",
        description="rff mode requires damage_function_path on every swept sector: ce_path is None in rff runs, so fitting is impossible and coefficients must be precomputed.",
        citation="utils/menu_runs.py:163-167 (run_rff)",
        modes=("rff",),
    ),
    Combination(
        key="rff-no-masks-or-fair-dims",
        options=("ecs_mask_name", "fair_dims"),
        kind="forbidden",
        description="sweep.masks and sweep.fair_dims are not available in rff mode; run_rff has no such parameters and forces the mask off.",
        citation="utils/menu_runs.py:119-127,169-170",
        modes=("rff",),
    ),
    Combination(
        key="ssp-gmst-path-required",
        options=("gmst_path",),
        kind="requires",
        description="ssp mode requires a non-empty climate.gmst_path: damage points are merged with the GMST anomalies during fitting.",
        citation="main_recipe.py damage_function_points (gmst merge)",
        modes=("ssp",),
    ),
    Combination(
        key="gmsl-formula-needs-gmsl-paths",
        options=("formula", "gmsl_path", "gmsl_fair_path"),
        kind="requires",
        description="a swept sector whose formula contains gmsl requires climate.gmsl_path (ssp fitting) and climate.gmsl_fair_path.",
        citation="main_recipe.py (gmsl merge keyed on slr/gmsl columns); simple_storage.py:54 (anomaly_vars gate)",
    ),
    Combination(
        key="quantreg-lengths",
        options=("quantreg_quantiles", "quantreg_weights"),
        kind="requires",
        description="quantreg_quantiles and quantreg_weights must have equal length (dscim asserts this even though the weights are otherwise unused).",
        citation="main_recipe.py:241-243",
    ),
)

Value dataclass

Value(
    value: object,
    status: str = "supported",
    reason: str = "",
    citation: str = "",
    restriction: str = "",
)

One accepted value of an option, with its own status.

Parameters:

  • value (object) –

    The literal value as it appears in config or dscim source.

  • status (str, default: 'supported' ) –

    One of STATUSES.

  • reason (str, default: '' ) –

    Why the value has its status; required when not supported.

  • citation (str, default: '' ) –

    Source location backing the reason.

  • restriction (str, default: '' ) –

    Why the restriction exists: library (a dscim limitation), data (a consequence of precomputed inputs), or specification (a policy choice). Empty for supported values.

value instance-attribute

value: object

status class-attribute instance-attribute

status: str = 'supported'

reason class-attribute instance-attribute

reason: str = ''

citation class-attribute instance-attribute

citation: str = ''

restriction class-attribute instance-attribute

restriction: str = ''

Option dataclass

Option(
    name: str,
    summary: str,
    stages: tuple[str, ...],
    default: object,
    citation: str,
    status: str = "supported",
    reason: str = "",
    restriction: str = "",
    modes: tuple[str, ...] = MODES,
    values: tuple[Value, ...] = (),
    open_set: bool = False,
    config_required: bool = False,
)

One option dscim accepts.

Parameters:

  • name (str) –

    Config-facing name; matches the dscim parameter name.

  • summary (str) –

    One-sentence description.

  • stages (tuple[str, ...]) –

    Pipeline stages that consume the option: subset of ("reduce", "fit", "fair", "discount", "output", "climate", "econ", "combine").

  • default (object) –

    dscim main's default, or REQUIRED.

  • citation (str) –

    Where the parameter and its default live in dscim main.

  • status (str, default: 'supported' ) –

    One of STATUSES; non-supported statuses need reason.

  • reason (str, default: '' ) –

    Why the option has its status.

  • restriction (str, default: '' ) –

    Why the restriction exists: library, data, or specification.

  • modes (tuple[str, ...], default: MODES ) –

    Run modes in which the option applies.

  • values (tuple[Value, ...], default: () ) –

    Enumerated accepted values when the set is closed.

  • open_set (bool, default: False ) –

    True when values documents known values but others are legal.

  • config_required (bool, default: False ) –

    True when the value must appear in config; dscim's default is recorded in default for reference only.

name instance-attribute

name: str

summary instance-attribute

summary: str

stages instance-attribute

stages: tuple[str, ...]

default instance-attribute

default: object

citation instance-attribute

citation: str

status class-attribute instance-attribute

status: str = 'supported'

reason class-attribute instance-attribute

reason: str = ''

restriction class-attribute instance-attribute

restriction: str = ''

modes class-attribute instance-attribute

modes: tuple[str, ...] = MODES

values class-attribute instance-attribute

values: tuple[Value, ...] = ()

open_set class-attribute instance-attribute

open_set: bool = False

config_required class-attribute instance-attribute

config_required: bool = False

value

value(raw: object) -> Value | None

Return the catalogued entry for raw, or None.

Combination dataclass

Combination(
    key: str,
    options: tuple[str, ...],
    kind: str,
    description: str,
    citation: str,
    modes: tuple[str, ...] = MODES,
)

A cross-option validity rule.

Parameters:

  • key (str) –

    Stable identifier linking this rule to its checker.

  • options (tuple[str, ...]) –

    Option names involved.

  • kind (str) –

    "requires" or "forbidden".

  • description (str) –

    The rule as one sentence; rendered by dscim-cil constraints.

  • citation (str) –

    Source backing the rule.

  • modes (tuple[str, ...], default: MODES ) –

    Run modes the rule applies to.

key instance-attribute

key: str

options instance-attribute

options: tuple[str, ...]

kind instance-attribute

kind: str

description instance-attribute

description: str

citation instance-attribute

citation: str

modes class-attribute instance-attribute

modes: tuple[str, ...] = MODES

Stage dataclass

Stage(
    name: str,
    summary: str,
    consumes: tuple[str, ...],
    produces: tuple[str, ...],
    collapses: tuple[str, ...],
    modes: tuple[str, ...] = MODES,
    library_call: str = "",
)

One pipeline stage: a dscim-cil command with its data flow.

Parameters:

  • name (str) –

    The command name.

  • summary (str) –

    What the stage does, in one sentence.

  • consumes (tuple[str, ...]) –

    Input kinds the stage reads.

  • produces (tuple[str, ...]) –

    Output kinds the stage writes.

  • collapses (tuple[str, ...]) –

    Dimension transformations the stage performs, with source citations.

  • modes (tuple[str, ...], default: MODES ) –

    Run modes in which the stage exists.

  • library_call (str, default: '' ) –

    The dscim function(s) the stage wraps, if any.

name instance-attribute

name: str

summary instance-attribute

summary: str

consumes instance-attribute

consumes: tuple[str, ...]

produces instance-attribute

produces: tuple[str, ...]

collapses instance-attribute

collapses: tuple[str, ...]

modes class-attribute instance-attribute

modes: tuple[str, ...] = MODES

library_call class-attribute instance-attribute

library_call: str = ''

option

option(name: str) -> Option

Look up a catalogued option by name.

config

dscim_cil.config

Config loading, validation, sweep expansion, and pipeline planning.

Precedence: catalogue defaults < YAML < command flags < -c overrides.

__all__ module-attribute

__all__ = [
    "COMBINATION_CHECKERS",
    "ConfigError",
    "Input",
    "PlanStep",
    "Run",
    "apply_overrides",
    "apply_selectors",
    "config_provenance",
    "effective_settings",
    "expand_sweep",
    "load_config",
    "plan_steps",
    "render_plan",
    "render_summary",
    "resolved_config",
    "run_inputs",
    "run_outputs",
    "save_path_for",
    "settings_summary",
    "summary_data",
    "validate_config",
]

TOP_LEVEL_KEYS module-attribute

TOP_LEVEL_KEYS = (
    "mode",
    "climate",
    "econ",
    "paths",
    "aggregates",
    "sectors",
    "menu",
    "sweep",
    "reduce",
    "combine",
    "scc",
)

MENU_KEYS module-attribute

MENU_KEYS = (
    "fit_type",
    "discrete_discounting",
    "fair_aggregation",
    "weitzman_parameter",
    "subset_dict",
    "ext_method",
    "ext_subset_start_year",
    "ext_subset_end_year",
    "ext_end_year",
    "clip_gmsl",
    "scenario_dimensions",
    "save_files",
    "filename_suffix",
    "full_uncertainty_quantiles",
    "quantreg_quantiles",
    "quantreg_weights",
)

CLIMATE_KEYS module-attribute

CLIMATE_KEYS = (
    "gases",
    "gas_conversions",
    "gmst_path",
    "gmsl_path",
    "gmst_fair_path",
    "gmsl_fair_path",
    "damages_pulse_conversion_path",
    "ecs_mask_path",
    "emission_scenarios",
    "base_period",
)

SAVABLE module-attribute

SCC_COLLAPSES module-attribute

SCC_COLLAPSES = ('certainty_equivalent', 'mean', 'none')

EXTERNAL module-attribute

EXTERNAL = ''

COMBINATION_CHECKERS module-attribute

COMBINATION_CHECKERS = {
    "median-params-fair-dims": _check_median_params_fair_dims,
    "clip-gmsl-formula": _check_clip_gmsl_formula,
    "equity-not-reduced": _check_equity_not_reduced,
    "rff-emission-scenarios-null": _check_rff_emission_scenarios,
    "rff-coefficients-required": _check_rff_coefficients,
    "rff-no-masks-or-fair-dims": _check_rff_no_masks,
    "ssp-gmst-path-required": _check_ssp_gmst_path,
    "gmsl-formula-needs-gmsl-paths": _check_gmsl_paths,
    "quantreg-lengths": _check_quantreg_lengths,
}

SCC_KEYS module-attribute

SCC_KEYS = ('deflator', 'collapse', 'output', 'damages_from', 'discounting_from')

OPTION_LOCATIONS module-attribute

OPTION_LOCATIONS = {
    **{key: ("menu", key) for key in MENU_KEYS},
    **{key: ("climate", key) for key in CLIMATE_KEYS},
    "path_econ": ("econ", "path"),
    "order": (None, "order"),
    "ce_path": ("paths", "reduced_damages_library"),
    "damage_function_path": ("sectors", None),
    "reduction": ("reduce", "reductions"),
}

SWEEP_OPTIONS module-attribute

SWEEP_OPTIONS = {
    "sector": "sectors",
    "pulse_year": "pulse_years",
    "recipe": "menu_pairs",
    "discounting_type": "menu_pairs",
    "eta": "eta_rho",
    "rho": "eta_rho",
    "ecs_mask_name": "masks",
    "fair_dims": "fair_dims",
}

SUMMARY_OPTIONS module-attribute

SUMMARY_OPTIONS = (
    "eta",
    "rho",
    "recipe",
    "discounting_type",
    "sector",
    "pulse_year",
    "fit_type",
    "fair_aggregation",
    "weitzman_parameter",
    "discrete_discounting",
    "ext_method",
    "gases",
)

ConfigError

ConfigError(errors: list[str])

Bases: Exception

Validation failure; errors lists every message.

errors instance-attribute

errors = errors

Run dataclass

Run(
    sector: str,
    pulse_year: int,
    recipe: str,
    discounting: str,
    eta: float,
    rho: float,
    mask: str | None = None,
    fair_dims: tuple[str, ...] = ("simulation",),
)

One fully-resolved element of the sweep.

eta and rho are one pair from sweep.eta_rho. mask and fair_dims apply in ssp mode only.

sector instance-attribute

sector: str

pulse_year instance-attribute

pulse_year: int

recipe instance-attribute

recipe: str

discounting instance-attribute

discounting: str

eta instance-attribute

eta: float

rho instance-attribute

rho: float

mask class-attribute instance-attribute

mask: str | None = None

fair_dims class-attribute instance-attribute

fair_dims: tuple[str, ...] = ('simulation',)

Input dataclass

Input(path: str, kind: str, producer: str = EXTERNAL)

One input file, with the dscim-cil command that produces it.

producer is empty for external inputs the user supplies.

path instance-attribute

path: str

kind instance-attribute

kind: str

producer class-attribute instance-attribute

producer: str = EXTERNAL

PlanStep dataclass

PlanStep(name: str, title: str, inputs: tuple[Input, ...], outputs: tuple[str, ...])

One ordered step of the pipeline for a given config.

name instance-attribute

name: str

title instance-attribute

title: str

inputs instance-attribute

inputs: tuple[Input, ...]

outputs instance-attribute

outputs: tuple[str, ...]

status

status() -> str

Return outputs-present, ready, or blocked-by-N.

load_config

load_config(path: str) -> dict

Load a YAML config file.

Raises ConfigError if the file is missing or is not a mapping.

apply_overrides

apply_overrides(config: dict, *, overrides: list[str]) -> dict

Apply KEY=VALUE overrides, merged last.

Keys are dotted paths; values are parsed as YAML scalars so lists and nulls work (-c sweep.pulse_years=[2020]).

apply_selectors

apply_selectors(
    config: dict,
    *,
    sectors: tuple[str, ...] = (),
    pulse_years: tuple[int, ...] = (),
    recipes: tuple[str, ...] = (),
    discountings: tuple[str, ...] = (),
    masks: tuple[str, ...] = (),
    eta: float | None = None,
    rho: float | None = None,
) -> dict

Narrow (or, where absent, define) the config's sweep from flags.

A selector filters an axis the config sweeps (selecting outside it is an error) and defines an axis the config omits. The mask value unmasked selects the no-mask run; eta and rho must come together.

validate_config

validate_config(config: dict, *, allow_unsupported: bool = False) -> list[str]

Validate a config; return warnings, raise ConfigError on errors.

Covers schema, value-status, and compatibility checks; filesystem existence is reported by the dry-run plan instead. With allow_unsupported, unsupported settings become warnings. The ConfigError carries every error found.

resolved_config

resolved_config(config: dict) -> dict

Return a copy of the config with dscim's defaults filled in.

Fills the menu keys and the climate keys gases, base_period, and emission_scenarios where the config omits them, and order. Options marked config_required are never filled.

expand_sweep

expand_sweep(config: dict) -> list[Run]

Expand the sweep: block into concrete runs.

The axes mirror run_ssps's product (utils/menu_runs.py:44-46): sector, pulse year, menu pair, eta and rho pair, mask, fair_dims. menu_pairs and eta_rho hold pairs, not independent axes. rff mode has no masks or fair_dims axes.

save_path_for

save_path_for(config: dict, run: Run) -> str

Build a run's save path.

{results}/{sector}/{pulse_year}/{mask} with unmasked for no mask, plus a fair_collapsed_* suffix for non-default fair_dims (utils/menu_runs.py:48-70).

epa_coefficient_file

epa_coefficient_file(directory: str, run: Run) -> str

The EPA library's name for the same coefficient file.

dscim-facts-epa rounds eta and rho to three places and ends the name in _dfc.nc4 (scghg_utils.py:257-270). dscim main does not read this name; see _coefficient_file.

run_inputs

run_inputs(config: dict, run: Run) -> list[Input]

List a run's input files with their producers.

gmsl inputs appear only for sectors whose formula has a gmsl term. Reduced-damage names follow dscim main: adding_up_{cc,no_cc}.zarr and risk_aversion_{cc,no_cc}_eta{eta}.zarr (simple_storage.py:387,414); equity reads the risk_aversion files.

run_outputs

run_outputs(config: dict, run: Run) -> list[str]

List a run's output files.

Names follow dscim's save decorator (decorators.py:33): {recipe}_{discounting}_eta{eta}_rho{rho}_{artifact} under the run's save path, one per entry of menu.save_files. damage_function_points is a csv, everything else nc4.

plan_steps

plan_steps(config: dict) -> list[PlanStep]

Derive the ordered pipeline for this config.

Steps appear only when the config asks for them; run splits into fit-sector and coefficient-sector phases.

summary_data

summary_data(config: dict, runs: list[Run]) -> dict

Collect the dry-run summary as plain data.

Keys: mode, run count, axis sizes, missing inputs grouped by producer, output totals, and the blocked-run count.

render_summary

render_summary(config: dict, runs: list[Run]) -> str

Render the dry-run summary as text.

Gives the mode, the run count with axis sizes, missing inputs grouped by the command that produces them, output totals, and blocked runs.

render_plan

render_plan(config: dict, runs: list[Run], *, indices: list[int] | None = None) -> str

Render per-run dry-run detail as text.

Each run lists its settings, its input files marked ok or missing (with the producing command), and its output files marked exists or new. indices are 1-based; None shows every run.

effective_settings

effective_settings(
    config: dict | None, *, sources: dict[str, str] | None = None
) -> list[tuple[str, object, str]]

Resolve every catalogued option to (name, value, origin).

Origins: config, flag, override, default, required, or the option's status for dead and removed entries. config may be None for dscim's defaults alone.

settings_summary

settings_summary(
    config: dict, *, sources: dict[str, str] | None = None, verbose: bool = False
) -> str

Render the values a run will use, with their origins.

The short form covers the result-selecting settings; verbose covers every catalogued option.

config_provenance

config_provenance(
    config: dict, *, sources: dict[str, str] | None = None
) -> dict[str, str]

Map every resolved option name to where its value came from.

runner

dscim_cil.runner

Execute planned runs against dscim.

Builds recipe kwargs the way dscim's drivers do (utils/menu_runs.py), preflights input files, runs order_plate, and writes *_run_metadata.yaml beside each run's outputs.

__all__ module-attribute

__all__ = [
    "TESTED_DSCIM_COMMIT",
    "PreflightError",
    "build_kwargs",
    "combine_all",
    "execute",
    "preflight",
    "reduce_all",
    "sum_sectors",
]

TESTED_DSCIM_COMMIT module-attribute

TESTED_DSCIM_COMMIT = '6a1f4d7e'

logger module-attribute

logger = logging.getLogger(__name__)

MENU module-attribute

MENU = {
    "adding_up": dscim.menu.baseline.Baseline,
    "risk_aversion": dscim.menu.risk_aversion.RiskAversionRecipe,
    "equity": dscim.menu.equity.EquityRecipe,
}

PreflightError

PreflightError(errors: list[str])

Bases: Exception

Input-file check failure; errors lists every message.

errors instance-attribute

errors = errors

preflight

preflight(config: dict, runs: list[Run]) -> None

Check input files before any compute.

Raises PreflightError listing every failure: econ variables and year range for the declared mode, pulse_year and gas coordinates in the FaIR file, FaIR coverage of base_period through ext_end_year (an uncovered base period yields all-NaN results with no error), GMST coverage of the fit window, discounting membership in the installed dscim's DISCOUNT_TYPES, and reduced-damage naming.

build_kwargs

build_kwargs(config: dict, run: Run) -> dict

Build the recipe constructor kwargs for one run.

Mirrors run_ssps (utils/menu_runs.py:77-99) and run_rff (:157-171). subset_dict defaults to an empty mapping because StackedDamages.cut iterates it unguarded.

execute

execute(
    config: dict,
    runs: list[Run] | None = None,
    *,
    resume: bool = False,
    invocation: str = "",
    sources: dict[str, str] | None = None,
) -> list[str]

Execute runs and write metadata beside their outputs.

Preflights every run first, then builds each recipe from build_kwargs and calls its order_plate with the config's order (default scc). With resume, runs whose declared outputs all exist are skipped. Returns one status line per run.

sum_sectors

sum_sectors(config: dict) -> list[str]

Build every aggregate sector declared in the aggregates block.

sum_AMEL re-reads the config file itself and writes summed_delta and summed_histclim to the aggregate's sector_path (preprocessing.py:216-282). It rechunks to fixed production dimensions (batch, ssp, model, rcp, gcm, year, region), so a sector with other dimensions fails inside dscim.

reduce_all

reduce_all(config: dict) -> list[str]

Run reduce_damages for the swept fit sectors.

adding_up takes eta=None (dscim asserts it, preprocessing.py:85-88); risk_aversion runs once per swept eta. reduce_damages reads a precomputed gdppc variable from the socioeconomics file (preprocessing.py:30-36), which the menu runs do not need, and re-reads the config file from disk.

combine_all

combine_all(config: dict) -> list[str]

Merge coastal and AMEL coefficients per the combine block.

Writes to {results}/{target}/{pulse_year}/{mask}/. dscim never merges the fitted-values files: combine_CAMEL_coefs rebinds its fit parameter before testing it (midprocessing.py:23,50), so only coefficients are combined.

scc

dscim_cil.scc

Compose SCCs from uncollapsed run outputs.

The SCC is the year-summed product of uncollapsed marginal damages and discount factors, deflated and collapsed over the uncertainty dimension. scc.damages_from and scc.discounting_from may point at different result roots, e.g. territorial-US damages against global discounting. Needs xarray but not dscim.

__all__ module-attribute

__all__ = ['compose']

compose

compose(config: dict, runs: list[Run] | None = None) -> list[str]

Compose, deflate, and collapse SCCs for every run.

Each SCC is the sum over years of uncollapsed marginal damages times uncollapsed discount factors, multiplied by scc.deflator, then collapsed per scc.collapse (mean, certainty_equivalent, or none). Writes {recipe}_{discounting}_eta{eta}_rho{rho}_scghg.nc4 under scc.output. Returns one status line per run, naming the file written. Raises FileNotFoundError when a run output is missing and ValueError when the collapse cannot be applied to the data.

cli

dscim_cil.cli

Command-line entry points.

__all__ module-attribute

__all__ = ['main']

ACCENT module-attribute

ACCENT = 'yellow'

main

main(log_level: str, plain: bool) -> None

Command-line interface to the dscim SCC library.

validate

validate(config_path: str, overrides: tuple[str, ...], allow_unsupported: bool) -> None

Validate CONFIG_PATH and report every problem found.

run

run(
    config_path: str,
    overrides: tuple[str, ...],
    allow_unsupported: bool,
    dry_run: bool,
    verbose: bool,
    run_indices: str | None,
    resume: bool,
    sectors: tuple[str, ...],
    pulse_years: tuple[int, ...],
    recipes: tuple[str, ...],
    discountings: tuple[str, ...],
    masks: tuple[str, ...],
    eta: float | None,
    rho: float | None,
) -> None

Expand the sweep and execute menu runs.

Selector flags narrow the config's sweep. In a config without a sweep block they supply the sweep axes; the config file is still required for the data paths, sectors and menu options.

plan

plan(config_path: str, overrides: tuple[str, ...], allow_unsupported: bool) -> None

Show the whole pipeline for CONFIG_PATH as ordered, statused steps.

stages

stages() -> None

Explain the pipeline: stages, data flow, and dimension collapses.

options_command

options_command(stage: str | None, mode: str | None, status: str | None) -> None

List the catalogued dscim option surface.

explain

explain(option_name: str, values: tuple[str, ...]) -> None

Show the full catalogue record for OPTION_NAME (and given VALUES).

constraints

constraints() -> None

List the cross-option validity rules.

defaults

defaults(config_path: str | None, overrides: tuple[str, ...]) -> None

Show every option's effective value and where it came from.

With CONFIG_PATH, values come from the config where set and from dscim's defaults otherwise. Without one, dscim's defaults are shown alone.

sum_sectors

sum_sectors(config_path: str, overrides: tuple[str, ...]) -> None

Build the aggregate sectors declared in the aggregates block.

reduce

reduce(config_path: str, overrides: tuple[str, ...]) -> None

Collapse the batch dimension per the reduce block.

adding_up takes the mean over batch; risk_aversion takes the certainty equivalent at each swept eta. The econ file must carry a precomputed gdppc variable.

combine

combine(config_path: str, overrides: tuple[str, ...]) -> None

Merge coastal and AMEL coefficients per the combine block.

scc

scc(config_path: str, overrides: tuple[str, ...]) -> None

Compose SCCs from the uncollapsed run outputs per the scc block.

Reads the uncollapsed marginal damages and discount factors that run wrote, so both must be in menu.save_files.