geoprior.cli.sensitivity_lib#

Drop-in run_one() for nat.com/sensitivity_lib.py.

This implementation is adapted from nat.com/sensitivity.py, with the heavy steps moved to build_context(): - Stage-1 manifest lookup - NPZ loading - tf.data pipeline building

run_one() assumes ctx contains: - ctx.manifest, ctx.manifest_path - ctx.cfg_base - ctx.base_output_dir - ctx.scaler_info - ctx.X_train / ctx.y_train / ctx.X_val / ctx.y_val - optional ctx.X_test / ctx.y_test - ctx.ds_train / ctx.ds_val / optional ctx.ds_test - ctx.dyn_names / ctx.fut_names / ctx.sta_names

It writes all artifacts under run_dir.

Functions

build_context(*[, city, stage1_manifest, ...])

One-time heavy setup: - locate Stage-1 manifest - resolve cfg (hybrid) - load NPZ arrays - build tf.data datasets (train/val/test)

cleanup_between_runs()

Clear TF/Keras graphs between runs.

run_one(ctx, *, overrides, run_tag[, ...])

Run one physics sensitivity trial.

Classes

SensitivityContext(manifest_path, manifest, ...)

class geoprior.cli.sensitivity_lib.SensitivityContext(manifest_path: 'str', manifest: 'dict[str, Any]', cfg_base: 'dict[str, Any]', base_output_dir: 'str', scaler_info: 'dict[str, Any]', X_train: 'dict[str, np.ndarray]', y_train: 'dict[str, np.ndarray]', X_val: 'dict[str, np.ndarray]', y_val: 'dict[str, np.ndarray]', X_test: 'dict[str, np.ndarray] | None', y_test: 'dict[str, np.ndarray] | None', ds_train: 'tf.data.Dataset', ds_val: 'tf.data.Dataset', ds_test: 'tf.data.Dataset | None', dyn_names: 'tuple[str, ...]', fut_names: 'tuple[str, ...]', sta_names: 'tuple[str, ...]', mode: 'str', horizon: 'int', batch_size: 'int')[source]#

Bases: object

Parameters:
manifest_path: str#
manifest: dict[str, Any]#
cfg_base: dict[str, Any]#
base_output_dir: str#
scaler_info: dict[str, Any]#
X_train: dict[str, ndarray]#
y_train: dict[str, ndarray]#
X_val: dict[str, ndarray]#
y_val: dict[str, ndarray]#
X_test: dict[str, ndarray] | None#
y_test: dict[str, ndarray] | None#
ds_train: DatasetV2#
ds_val: DatasetV2#
ds_test: DatasetV2 | None#
dyn_names: tuple[str, ...]#
fut_names: tuple[str, ...]#
sta_names: tuple[str, ...]#
mode: str#
horizon: int#
batch_size: int#
__init__(manifest_path, manifest, cfg_base, base_output_dir, scaler_info, X_train, y_train, X_val, y_val, X_test, y_test, ds_train, ds_val, ds_test, dyn_names, fut_names, sta_names, mode, horizon, batch_size)#
Parameters:
Return type:

None

geoprior.cli.sensitivity_lib.build_context(*, city=None, stage1_manifest=None, verbose=1)[source]#

One-time heavy setup: - locate Stage-1 manifest - resolve cfg (hybrid) - load NPZ arrays - build tf.data datasets (train/val/test)

Parameters:
  • city (str | None)

  • stage1_manifest (str | None)

  • verbose (int)

Return type:

SensitivityContext

geoprior.cli.sensitivity_lib.cleanup_between_runs()[source]#

Clear TF/Keras graphs between runs.

Return type:

None

geoprior.cli.sensitivity_lib.run_one(ctx, *, overrides, run_tag, stable_run_dir=True, eval_max_batches=None, cal_max_batches=None)[source]#

Run one physics sensitivity trial.

Notes

  • Reuses ctx.ds_train/ctx.ds_val/ctx.ds_test.

  • All artifacts are written to the returned run_dir.

Parameters:
  • overrides (dict[str, Any])

  • run_tag (str | None)

  • stable_run_dir (bool)

  • eval_max_batches (int | None)

  • cal_max_batches (int | None)

Return type:

str