Skip to content

ensemble_base⚓︎

Ensemble container for ensemble-based data assimilation.

The PIPT counterpart to :mod:popt.ensembles.ensemble_base: holds the state realisations, observed data, localization and forward simulator for an assimilation run.

Previously pipt.loop.ensemble.Ensemble; that module has been removed.

AssimilationEnsemble ⚓︎

Bases: ForecastMixin, OutlierMixin, LocalAnalysisMixin, BaseEnsemble

Class for organizing/initializing misc. variables and simulator for an ensemble-based inversion run. Inherits the PET ensemble structure

RESTART_ATTRIBUTES = ('enX', 'prior_enX', 'pred_data', 'member_outputs', 'member_adjoints', 'adjoints', 'scale_data', 'Am', 'proj', 'iteration', 'sparse_data', 'scale_val') ⚓︎

What a resume must restore on the ensemble: what iterations change (the state, its forecast), and what construction drew or derived from a draw (the prior, the observation scaling, the scaled prior's SVD), so a resumed run continues the interrupted one whatever the random state was when the resuming process built its ensemble.

__init__(keys_da, keys_en, sim) ⚓︎

Parameters:

Name Type Description Default
keys_da dict

Options for the data assimilation class

  • scheme: name of the assimilation algorithm (e.g., "esmda", "lmenrml", "gnenrml")
  • analysis: update flavour ("approx", "full" or "subspace")
  • energy: percent of singular values kept after SVD
  • obsvarsave: save the observations as a file (default false)
  • restart, restartsave, restart_file: checkpointing, read by the scheme (see pipt.update_schemes.core.restart_options); the ensemble contributes restart_state() to the checkpoint.
  • savedata: names of scheme attributes to write to one file per iteration, assimilation_result_{i}.npz. Iteration 0 is the prior. "state" expands to one array per state variable; anything else is looked up on the scheme and then on the ensemble, so e.g. "ensemble_misfit", "pred_data", "data_misfit" and "lam" all resolve. A name that resolves nowhere is reported and skipped. Omitting the key disables the saving, so there is no separate on/off switch. (Was analysisdebug, still honoured with a warning.)
  • savefolder (or save_folder): where run artifacts go (default Results)
  • logit: enable run logging (default true). When false, no log file is created and self.logger(...) calls become no-ops.
  • logger_name: log file name (default ASSIM.log)
  • nosave: present in the config disables artifact saving entirely
  • truedataindex: order of the simulated data (for timeseries this is points in time)
  • obsname: unit for truedataindex (for timeseries this is days or hours or seconds, etc.)
  • truedata: the data, e.g., provided as a .csv file
  • assimindex: index for the data that will be used for assimilation
  • datatype: list with the name of the datatypes
  • staticvar: name of the static variables
  • dynamicvar: name of the dynamic variables
  • datavar: data variance, e.g., provided as a .csv file
required
keys_en dict

Options for the ensemble class

  • ne: number of perturbations used to compute the gradient
  • state: name of state variables passed to the .mako file
  • prior_: the prior information the state variables, including mean, variance and variable limits

NB: If keys_en is empty dict, it is assumed that the prior info is contained in keys_da. The merged dict keys_da|keys_en is what is sent to the parent class.

required
sim callable

The forward simulator (e.g. flow)

required

check_assimindex_simultaneous() ⚓︎

Check if assim. indices is given as a 1D list as is needed in simultaneous updating. If not, make it a 2D list with one row.

perturb_observations(vecObs) ⚓︎

Generate the perturbed observed data ensemble

restart_state() ⚓︎

What a checkpoint carries for this ensemble: RESTART_ATTRIBUTES plus the random stream's state.

restore_restart_state(state) ⚓︎

Overlay a checkpoint's ensemble state and mark the ensemble as resumed.

NoLocalization ⚓︎

Stands in for a localization when the config asks for none.

Analyses branch on localization.name; None means no localization. A module-level class rather than an anonymous one so the ensemble that holds it can be pickled -- emergency_dump and the restart file both pickle the ensemble, and an anonymous class made that fail exactly when a run had crashed.