NEDAS.core.transform module

class NEDAS.core.transform.Transform(c: Context, **kwargs)[source]

Bases: ABC

Base class for miscellaneous transform functions

is_identity: bool = False

Whether forward_state/forward_obs are true no-ops given the current config (e.g. a ScaleBandpass transform with only 1 scale). When True for every active transform_func, code that needs H(X) (e.g. computing obs_prior/obs_post) may safely shortcut by reading cached state fields instead of re-reading the raw, untransformed model state – otherwise it must always re-read the raw state, since the cached fields no longer represent it. Subclasses must set this correctly (statically or in __init__ based on config), not the caller – only the transform itself knows whether its own forward_state is a no-op.

abstractmethod forward_state(c: Context, rec: FieldRecord, field: ndarray) ndarray[source]

Forward transform for the model state variables.

Parameters:
  • c (Context) – the runtime context.

  • rec (FieldRecord) – State information record for the variable.

  • field (np.ndarray) – The state variable.

Returns:

The transformed state variable.

Return type:

np.ndarray

abstractmethod backward_state(c: Context, rec: FieldRecord, field: ndarray) ndarray[source]

Backward (inverse) transform for the model state variables.

Parameters:
  • c (Context) – the runtime context.

  • rec (FieldRecord) – State information record for the variable.

  • field (np.ndarray) – The transformed state variable.

Returns:

The state variable transformed back to the original space.

Return type:

np.ndarray

abstractmethod forward_obs(c: Context, obs_rec: ObsRecord, obs_seq: dict[str, ndarray]) dict[str, ndarray][source]

Forward transform for the observation sequence.

Parameters:
  • c (Context) – the runtime context.

  • obs_rec (ObsRecord) – Observation information record.

  • obs_seq (dict[str, np.ndarray]) – The observation sequence. With keys 'obs' the observation; 'x', 'y', 'z', 't' the space/time coordinates; and 'err_std' the observation errors.

Returns:

The transformed observation sequence.

Return type:

dict[str, np.ndarray]

abstractmethod backward_obs(c: Context, obs_rec: ObsRecord, obs_seq: dict[str, ndarray]) dict[str, ndarray][source]

Backward (inverse) transform for the observation sequence.

Parameters:
  • c (Context) – the runtime context.

  • obs_rFieldRecord)ict) – Observation information record.

  • obs_seq (dict) – The transformed observation sequence. With keys 'obs' the observation; 'x', 'y', 'z', 't' the space/time coordinates; and 'err_std' the observation errors.

Returns:

The observation sequence transformed back to the original space.

Return type:

dict