source_localization.obs module

class source_localization.obs.Obs(t_obs, X_obs, d_obs, msh, dt_obs_operator=0.0)[source]

Bases: object

Class containing all the features related to the sensors and the observations. This includes:

  • the observations \(m_{obs}\), the observation times \(t_{obs}\) and the observation positions \(X_{obs}=(x_{obs}, y_{obs})\),

  • the estimation of the observed variable \(m(c(s))\),

  • the concentration of pheromone \(c(s)\) at the time and positions required to compute the observed variable,

  • the observation operator \(c\mapsto m(c)\)

  • the adjoint operator of its derivative with respect of the state variable \(\phi\mapsto (d_cm(c))^*\cdot\phi\),

  • the covariance matrix of the observation error \(\mathbf{R}\).

In this class, the observations are the accumulation of pheromone over a given time window. Therefore, the observation operator is the integral of the pheromone concentration over this time window:

\[m(c)_{i}=\int_{t_{obs, i}-\delta t}^{t_{obs, i}}c(x_{obs, i}, y_{obs, i}, \tau)d\tau\]
msh

The geometry of the domain.

Type:

MeshRect2D

t_obs

The observation times \(t_{obs}\).

Type:

ndarray

X_obs

The locations of the observations \(X_{obs}=(x_{obs}, y_{obs})\).

Type:

ndarray

d_obs

The observations data \(m_{obs}\).

Type:

ndarray

N_obs

The number of observations.

Type:

int

nb_sensors

The number of sensors.

Type:

int

X_sensors

The positions of the sensors.

Type:

ndarray

dt_obs_operator

Length of the time window of accumulation \(\delta t\). If the observation is instantaneous, set to 0.

Type:

float

nb_dt_in_obs_time_window

Number of time steps covering the time window of accumulation \([t_{obs, i}-\delta t; t_{obs, i}]\).

Type:

int

index_obs_to_index_time_est

The indexes of the times at which the state variable is required to compute the observation variable given the index of an observation.

Type:

ndarray

index_time_est_to_index_obs

Dictionary where each key is a time index, and the value is an array of indexes of the observations that require the estimate of the state variable at this time to estimate the observed variable.

Type:

dict

c_est

The estimation the concentration of pheromone \(c(s;x,y,t)\) at the times \(t\) and positions \((x,y)\) required to compute the observed variable \(m(c(s))\).

Type:

ndarray

d_est

The estimation of the accumulation of pheromone (observed variable) computed using the pheromone propagation model \(m(c(s))\).

Type:

ndarray

R_inv

The inverse of the covariance matrix of the observation error \(\mathbf{R}^{-1}\).

Type:

sparse matrix, default: identity() matrix

__init__(t_obs, X_obs, d_obs, msh, dt_obs_operator=0.0)[source]

Constructor method.

Parameters:
  • t_obs (ndarray) – The observation times \(t_{obs}\).

  • X_obs (ndarray) – The locations of the observations \(X_{obs}=(x_{obs}, y_{obs})\).

  • d_obs (ndarray) – The observations data \(m_{obs}\).

  • msh (MeshRect2D) – The geometry of the domain.

  • dt_obs_operator (float, default: 0) – Length of the time window of accumulation \(\delta t\). If set to 0, the observation is instantaneous.

Raises:
  • ValueError – if the time array has not been initialized using the methods calc_dt_explicit_solver() or calc_dt_implicit_solver().

  • ValueError – if the sizes of the arrays containing the observation times \(t_{obs}\), the observation positions \(X_{obs}\) and the observations data \(m_{obs}\) do not coincide.

  • ValueError – if one observation time \(t_{obs}\) or one observation position \(X_{obs}\) is out of the time window \([0;T]\) or domain \(\Omega\).

adjoint_derivative_obs_operator(t, phi)[source]

compute the spatial map of the adjoint of the derivative of the observation operator with respect to the state variable \(\phi\mapsto (d_cm(c))^*\cdot\phi\), at a given time \(t\) and for an element of the observation space \(\phi\).

Parameters:
  • t (float or integer) – The current time \(t\).

  • phi (ndarray) – The element of the observation space \(\phi\) at current time \(t\).

Returns:

The spatial map of the image of the adjoint of the derivative of the observation operator \((d_cm(c))^*\cdot\phi(x,y)\) at the given time raveled into a vector.

Return type:

ndarray

obs_operator()[source]

The observation operator \(c\mapsto m(c)\).

In this class, the observation operator is, for the \(i^{th}\) observation time and position, \(m(c)_{i}=\int_{t_{obs, i}-\delta t}^{t_{obs, i}}c(x_{obs, i}, y_{obs, i}, \tau)d\tau\). Moreover, it is assumed that the integration time window for different data of a same sensor are not overlapping

Notes

This method computes the observed variable and store the values in the attribute d_est using the attribute c_est that contains the estimation the concentration of pheromone \(c(s;x,y,t)\) computed by the pheromone propagation model at the times \(t\) and positions \((x,y)\) required to compute the observed variable. To get these \(c(s;x,y,t)\), the attribute c_est should be computed in a first time using the method solver_est_at_obs_times() of the class DiffusionConvectionReaction2DEquation().

Raises:

ValueError – if the attribute c_est has not been computed in a first time.

onesensor_adjoint_derivative_obs_operator(t, phi, index_sensor)[source]

compute the spatial map of the adjoint of the derivative of the one-sensor observation operator with respect to the state variable \(\phi\mapsto (d_cm_i(c))^*\cdot\phi\), at a given time \(t\), for the \(i^{th}\) sensor and for an element of the observation space \(\phi\).

Parameters:
  • t (float or integer) – The current time \(t\).

  • phi (ndarray) – The element of the observation space \(\phi\) at current time \(t\).

  • index_sensor (int) – The index of the sensor \(i\).

Returns:

The spatial map of the image of the adjoint of the derivative of the one-sensor observation operator \((d_cm_i(c))^*\cdot\phi(x,y)\) at the given time raveled into a vector.

Return type:

ndarray