am

Submodules

Exceptions

AmError

Base exception for am errors.

Classes

ComputeError

Error during model computation.

ConfigError

Error parsing an .amc configuration file.

ModelGrid

Run an am model over a grid of parameter values.

Model

An am atmospheric model loaded from an .amc configuration file.

Package Contents

exception am.AmError

Base exception for am errors.

class am.ComputeError

Error during model computation.

class am.ConfigError

Error parsing an .amc configuration file.

class am.ModelGrid(path: pathlib.Path, params: xarray.Dataset, args_fn: Callable[Ellipsis, list[str]], max_workers: int | None = None)

Run an am model over a grid of parameter values.

Parameters

path:

Path to the .amc template file.

params:

xarray Dataset defining the parameter space. Two forms are supported:

  • Regular (Cartesian) grid — coordinates on independent dimensions:

    xr.Dataset(coords={"elevation": [30, 45, 60], "pwv": [0.5, 1.0, 2.0]})
    
  • Irregular grid — variables sharing one dimension:

    xr.Dataset({"elevation": ("profile", elev), "pwv": ("profile", pwv)})
    
args_fn:

Callable that maps parameter values to an am args list. Keyword argument names must match coordinate/variable names in params:

args_fn=lambda elevation, pwv: [
    "0", "GHz", "350", "GHz", "0.5", "GHz",
    str(elevation), "deg", str(pwv),
]
max_workers:

Number of worker processes (default: os.cpu_count()).

compute() xarray.Dataset

Run all models and return an xarray Dataset.

The output Dataset has the same dimensions and coordinates as params, plus a frequency dimension. Each requested am output (e.g. tb_rj, transmittance) becomes a data variable.

class am.Model(path, args)

An am atmospheric model loaded from an .amc configuration file.

Thin wrapper around the Rust _Model that returns xarray Datasets for outputs and jacobian().

Parameters

path:

Path to the .amc file.

args:

Positional substitution values for %1, %2, … placeholders in the config (frequency grid, zenith angle, PWV scale, etc.).

compute()

Run the radiative transfer computation.

property frequency: numpy.ndarray

Frequency grid in GHz.

property outputs: xarray.Dataset

Computed output spectra as an xarray Dataset.

Dimension is frequency (GHz). Only outputs listed in the output directive of the .amc file are present. Empty before compute() is called.

property variables: list[str]

Names of fit/differentiation variables defined in the config.

property n_variables: int

Number of fit/differentiation variables.

jacobian() xarray.Dataset

Compute Jacobians of all outputs w.r.t. fit variables.

Returns an xarray Dataset with dimensions (variable, frequency). The .amc config must define fit variables (parameters with scales).

Raises

ConfigError

If no fit variables are defined in the .amc config.

summary() str

Full resolved model configuration summary.