pycif.plugins.transforms.system.array2sampled — API reference

Contents

pycif.plugins.transforms.system.array2sampled — API reference#

Configuration reference: array2sampled plugin

pycif.plugins.transforms.system.array2sampled.adjoint.adjoint(transform, inout_datastore, controlvect, obsvect, mapper, di, df, mode, runsubdir, workdir, onlyinit=False, **kwargs)[source]#

Scatter observation-space adjoint sensitivities back onto the model grid.

The adjoint of forward(): for each observation, reads the 'adj_out' value from the sparse output DataFrame and adds it to the corresponding (tstep, lev, i, j) cell of the gridded 'adj_out' array via np.add.at (atomic accumulation for multiple observations mapping to the same cell).

Initialises xmod_in["adj_out"] as a zero array shaped like xmod_in["spec"] if not already present.

Parameters:
  • transform (Plugin) – array2sampled instance.

  • inout_datastore (dict) – mutable datastore; 'inputs' has the gridded arrays, 'outputs' has the observation DataFrame with 'adj_out' column.

  • controlvect – unused.

  • obsvect – unused.

  • mapper (dict) – transform mapper.

  • di (datetime) – sub-simulation start date.

  • df (datetime) – sub-simulation end date.

  • mode (str) – 'adj'.

  • runsubdir (str) – unused.

  • workdir (str) – unused.

  • onlyinit (bool) – if True, return immediately.

  • **kwargs – unused.

pycif.plugins.transforms.system.array2sampled.forward.forward(transform, inout_datastore, controlvect, obsvect, mapper, di, df, mode, runsubdir, workdir, onlyinit=False, **kwargs)[source]#

Extract point-observation values from a gridded model output field.

For each (input tracer, output tracer) pair in the mapper, reads the gridded field xmod_in["spec"] and uses the pre-computed grid indices (i, j, level, tstep) stored in the output observation DataFrame’s metadata to extract the corresponding model values via xarray label-based indexing.

In TL mode (mode = 'tl') the 'incr' field is sampled in the same way.

Single-level fields are handled by setting lev = 0 for all observations.

Parameters:
  • transform (Plugin) – array2sampled instance (unused directly).

  • inout_datastore (dict) – mutable datastore; 'inputs' has the gridded field, 'outputs' has the sparse observation DataFrame to be populated.

  • controlvect – unused.

  • obsvect – unused.

  • mapper (dict) – transform mapper.

  • di (datetime) – sub-simulation start date.

  • df (datetime) – sub-simulation end date.

  • mode (str) – 'fwd' or 'tl'.

  • runsubdir (str) – unused.

  • workdir (str) – unused.

  • onlyinit (bool) – if True, return immediately.

  • **kwargs – unused.