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

Contents

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

Configuration reference: sparse2sample plugin

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

Extract gridded adjoint sensitivities at sparse observation locations.

The adjoint of forward(): reads 'adj_out' from the gridded output DataArray at the (tstep, lev, i, j) indices of each observation and writes the result into the 'adj_out' column of the sparse input DataFrame.

Warning

The current implementation contains an active debug code.interact() call at the start of the function body that will pause execution. This must be removed before production use.

Parameters:
  • transform (Plugin) – sparse2sample instance.

  • inout_datastore (dict) – mutable datastore; 'outputs' has the gridded sensitivity array, 'inputs' has the sparse DataFrame to be updated.

  • 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.sparse2sample.forward.forward(transform, inout_datastore, controlvect, obsvect, mapper, di, df, mode, runsubdir, workdir, onlyinit=False, **kwargs)[source]#

Scatter sparse observation values onto the full model grid.

For each observation in the sparse input DataFrame, reads the spec (and incr in TL mode) column and adds its value to the (tstep, lev, i, j) cell of a zero-initialised output array using np.add.at. The output is returned as an xarray DataArray with (time, lev, lat, lon) dimensions.

Output shape is determined by the domain dimensions (nlon, nlat, nlev) and the number of time steps from the mapper’s input_dates for the current sub-simulation.

Parameters:
  • transform (Plugin) – sparse2sample instance.

  • inout_datastore (dict) – mutable datastore; 'inputs' has the sparse DataFrame, 'outputs' receives the gridded DataArray.

  • controlvect – unused.

  • obsvect – unused.

  • mapper (dict) – transform mapper (provides domain and input_dates).

  • 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) – unused (no early return; data always written).

  • **kwargs – unused.