dabench.observer

Observer module

Classes

Observer

Flexibly samples observations from generated data

Package Contents

class dabench.observer.Observer(state_vec, random_time_density=1.0, random_location_density=1.0, random_time_count=None, random_location_count=None, times=None, locations=None, stationary_observers=True, error_bias=0.0, error_sd=0.0, error_positive_only=False, random_seed=99, store_as_jax=False)

Flexibly samples observations from generated data

Parameters:
  • state_vec (xarray.Dataset) – Data generator/loader object from which to gather observations.

  • random_location_density (float | tuple[float, Ellipsis]) – Fraction of locations in system_dim to randomly select for observing, must be value between 0 and 1. Default is 1.

  • random_time_density (float) – Fraction of times to randomly select for observing must be value between 0 and 1. Default is 1.

  • random_location_count (int | tuple[int, Ellipsis] | None) – Number of locations in data_obj’s system_dim to randomly select for observing. Default is None. User should specify one of: random_location_count, random_location_density, or location_indices. If random_location_count is specified, it takes precedent over random_location_density.

  • random_time_count (int | None) – Number of times to randomly select for observing. Default is None. User should specify one of: random_time_count, random_time_density, or time_indices. If random_time_count is specified, it takes precedent over random_time_density.

  • locations (ArrayLike | None) – Manually specified indices for observing. If 1D array provided, assumed to be for flattened system_dim. If >1D, must have same dimensionality as data generator’s original_dim (e.g. (x, y, z)). If stationary_observers=False, expects leading time dimension. If not specified, will be randomly generated according to random_location_density OR random_location_count. Default is None.

  • times (ArrayLike | None) – Indices of times to gather observations from. If not specified, randomly generate according to random_time_density OR random_time_count. Default is None.

  • stationary_observers (bool) –

    If True, samples from same indices at each time step. If False, randomly generates/expects new observation indices at each timestep. Default is True. If False:

    If using random_location_count, the same number of indices

    will be randomly generated.

    If using random_location_density, indices are randomly

    generated, with the possibility of a different number of locations at each times step..

    If using location_indices, expects indices to either be 2D

    (time_dim, system_dim) or >2D (time_dim, original_dim).

  • error_bias (ArrayLike | float) – Mean of normal distribution of observation errors. If provided as an array, it is taken to be variable-specific and the length must be equal to data_obj.system_dim. Default is 0.

  • error_sd (ArrayLike | float) – Standard deviation of observation errors. observation errors. If provided as an array, it is taken to be variable-specific and the length be equal to data_obj.system_dim. Default is 0.

  • error_positive_only (bool) – Clip errors to be positive only. Default is False.

  • random_seed (int) – Random seed for sampling times and locations. Default is 99.

  • store_as_jax (bool) – Store values as jax array instead of numpy array. Default is False (store as numpy).

locations

Location indices for making observations. In system_dim (1D) or original dim (>1D) of self.state_vec.

Type:

ArrayLike

location_dim

Number of locations sampled from (max in a single time step, if non-stationary observers).

Type:

int

times

Time indices to gather observations from.

Type:

ArrayLike

time_dim

Number of times sampled from.

Type:

int

observe()

Generate observations.

Returns:

ObsVector containing observation values, times, locations, and errors

Return type:

xarray.Dataset