The ObsData Class¶
- class stat_fem.ObsData(coords, data, unc)¶
Class representing Observational Data and discrepancy between model and observations
This class holds information on observational data and uncertainties. It also serves as a wrapper to compute the model discrepancy (since the data coordinates and uncertainties are stored here). At the moment, it only implements the squared exponential kernel and assumes that data is not time varying.
- Variables
coords – Array holding coordinate locations of measurements. Must be 1D or 2D where the first axis represents the different coordinate points and the second axis represents the cartesian axis directions. If 1D, assumes the second axis has length 1.
data – Sensor measurements at all of the given coordinate locations. Length must be the same as the first axis of
coords.unc – Uncertainty on data measurements as a standard deviation. Can be a single float, or an array of floats with the same length as the number of sensors. Must be non-negative.
- __init__(coords, data, unc)¶
Create a new ObsData object
Creates a new
ObsDataobject given coordinates, data values, and uncertainties. Performs re-shaping of inputs and some checks on values.- Parameters
coords (ndarray) – Array holding coordinate locations of measurements. Must be 1D or 2D where the first axis represents the different coordinate points and the second axis represents the cartesian axis directions. If 1D, assumes the second axis has length 1.
data (ndarray) – Sensor measurements at all of the given coordinate locations. Length must be the same as the first axis of
coords.unc (float or ndarray) – Uncertainty on data measurements as a standard deviation. Can be a single float, or an array of floats with the same length as the number of sensors. Must be non-negative.
- calc_K(params)¶
Returns model discrepancy covariance matrix
Computes the model discrepancy covariance matrix for the given parameters. Assumes that the discrepancy is a multivariate normal distribution with zero mean and a squared exponential covariance matrix. Params are given on a logarithmic scale to enforce positivity, the first parameter is the overall covariance scale (actual covariance is found by taking exp(2.*params[0]) and the second is the spatial correlation length scale (actual correlation length is exp(params[1])). Returns a numpy array with shape
(n_obs, n_obs).- Parameters
params (ndarray) – Covariance function parameters on a logarithmic scale. Must be a numpy array of length 2 (first parameter is the overall covariance scale, second determines the correlation length scale).
- Returns
Model discrepancy covariance matrix, shape is
(n_obs, n_obs).- Return type
ndarray
- calc_K_deriv(params)¶
Returns derivative of model discrepancy covariance matrix wrt parameters
Computes the derivative of the model discrepancy covariance matrix with respect to the input parameters. Assumes that the discrepancy is a multivariate normal distribution with zero mean and a squared exponential covariance matrix. Params are given on a logarithmic scale to enforce positivity, the first parameter is the overall covariance scale (actual covariance is found by taking exp(2.*params[0]) and the second is the spatial correlation length scale (actual correlation length is exp(params[1])). Returns a numpy array with shape
(2, n_obs, n_obs).- Parameters
params (ndarray) – Covariance function parameters on a logarithmic scale. Must be a numpy array of length 2 (first parameter is the overall covariance scale, second determines the correlation length scale).
- Returns
Model discrepancy covariance matrix derivative with respect to the parameters, shape is
(2, n_obs, n_obs).- Return type
ndarray
- calc_K_plus_sigma(params)¶
Returns model discrepancy covariance matrix plus observation error
Computes the model discrepancy covariance matrix for the given parameters plus the observational error. Assumes that the discrepancy is a multivariate normal distribution with zero mean and a squared exponential covariance matrix. Params are given on a logarithmic scale to enforce positivity, the first parameter is the overall covariance scale (actual covariance is found by taking exp(2.*params[0]) and the second is the spatial correlation length scale (actual correlation length is exp(params[1])). Returns a numpy array with shape
(n_obs, n_obs).- Parameters
params (ndarray) – Covariance function parameters on a logarithmic scale. Must be a numpy array of length 2 (first parameter is the overall covariance scale, second determines the correlation length scale).
- Returns
Model discrepancy covariance matrix plus observational error, shape is
(n_obs, n_obs).- Return type
ndarray
- get_coords()¶
Returns coordinate points as a numpy array
Returns coordinate points where sensor measurements have been made as a numpy array. 2D array with the first axis representing the different sensors, and the second axis represents the different spatial dimensions.
- Returns
Coordinate array, a 2D numpy array
- Return type
ndarray
- get_data()¶
Returns sensor observations as a numpy array
Returns sensor observations as a 1D numpy array. Length is the same as the number of sensors.
- Returns
Coordinate array, a 1D numpy array
- Return type
ndarray
- get_n_dim()¶
Returns number of dimensions in FEM model
Returns the number of spatial dimensions in FEM model as an integer.
- Returns
Number of spatial dimensions
- Return type
int
- get_n_obs()¶
Returns number of observations
Returns the number of sensor observations as an integer.
- Returns
Number of sensor measurements
- Return type
int
- get_unc()¶
Returns uncertainties
Returns data measurement uncertainty as a standard deviation, either a float or a numpy array if uncertainties differ across sensors.
- Returns
Uncertainty as a standard deviation, either a float or a numpy array
- Return type
float or ndarray