sensorarraypoint

class pyvale.sensorarraypoint.SensorArrayPoint(sensor_data: SensorData, field: IField, descriptor: SensorDescriptor | None = None)[source]

Bases: ISensorArray

A class for creating arrays of point sensors applied to a simulated physical field. Examples include: thermocouples used to measure temperature (a scalar field) or strain gauges used to measure strain (a tensor field). Implements the ISensorArray interface.

This class uses the pyvale sensor measurement simulation model. Here a measurement is taken as: measurement = truth + random errors + systematic errors. The truth value for each sensor is interpolated from the physical field (an implementation of the IField interface, nominally a FieldScalar, FieldVector or FieldTensor object).

The random and systematic errors are calculated by a user specified error integrator (ErrIntegrator class). This class contains a chain of different types of user selected errors (implementations of the IErrCalculator interface). Further information can be found in the ErrIntegrator class and in implementations of the IErrCalculator interface.

In pyvale, function and methods with calc in their name will cause probability distributions to be resampled and any additional calculations, such as interpolation, to be performed. Functions and methods with get in the name will directly return the previously calculated values without resampling probability distributions.

Calling the class method calc_measurements() will create and return an array of simulated sensor measurements with the following shape=(num_sensors ,num_field_component,num_time_steps). When calling calc_measurements() all sensor errors that are based on probability distributions are resampled and any required interpolations are performed (e.g. a random perturbation of the sensor positions requiring interpolation at the perturbed sensor location).

Calling the class method get_measurements() just returns the previously calculated set of sensor measurements without resampling of probability. Distributions.

Without an error integrator this class can be used for interpolating simulated physical fields quickly using finite element shape functions.

Parameters:
  • sensor_data (SensorData) -- Specifies sensor array parameters including: positions, sample times , angles, and area averaging. See the SensorData dataclass for details.

  • field (IField) -- The simulated physical field that the sensors will samples from. This is normally a FieldScalar, FieldVector or FieldTensor.

  • descriptor (SensorDescriptor | None, optional) -- Contains descriptive information about the sensor array for display and visualisations, by default None.

calc_measurements() ndarray[source]

Calculates a set of sensor measurements using the specified sensor array parameters and the error intergator if specified. Calculates measurements as: measurement = truth + systematic errors + random errors . The truth is calculated once and is interpolated from the input simulation field. The errors are calculated based on the user specified error chain in the error integrator object. If no error integrator is specified then only the truth is returned. _description_ew simulated experiment for this sensor array.

Returns:

np.ndarray -- Array of sensor measurements including any simulated random and systematic errors if an error integrator is specified. shape=( num_sensors,num_field_components,num_time_steps).

calc_truth_values() ndarray[source]

Calculates the ground truth sensor values by interpolating the simulated physical field using the sensor array parameters in the SensorData object.

Returns:

np.ndarray -- Array of ground truth sensor values. shape=(num_sensors, num_field_components,num_time_steps).

get_errors_random() ndarray | None[source]

Gets the random error array from the previously calculated sensor measurements. Returns None is no error integrator has been specified.

Returns:

np.ndarray | None -- Array of random errors for this sensor array. shape=(num_sensors ,num_field_components,num_time_steps). Returns None if no error integrator has been set.

get_errors_systematic() ndarray | None[source]

Gets the systematic error array from the previously calculated sensor measurements. Returns None is no error integrator has been specified.

Returns:

np.ndarray | None -- Array of systematic errors for this sensor array. shape=(num_sensors ,num_field_components,num_time_steps). Returns None if no error integrator has been set.

get_errors_total() ndarray | None[source]

Gets the total error array from the previously calculated sensor measurements. Returns None is no error integrator has been specified.

Returns:

np.ndarray | None -- Array of total errors for this sensor array. shape=(num_sensors ,num_field_components,num_time_steps). Returns None if no error integrator has been set.

get_field() IField[source]

Gets a reference to the physical field that this sensor array is applied to.

Returns:

IField -- Reference to an IField interface.

get_measurement_shape() tuple[int, int, int][source]

Gets the shape of the sensor measurement array. shape=(num_sensors, num_field_components,num_time_steps)

Returns:

tuple[int,int,int] -- Shape of the measurement array. shape=(num_sensors, num_field_components,num_time_steps)

get_measurements() ndarray[source]

Returns the current set of simulated measurements if theses have been calculated. If these have not been calculated then 'calc_measurements()' is called and a set of measurements in then returned.

Returns:

np.ndarray -- Array of sensor measurements including any simulated random and systematic errors if an error integrator is specified. shape=( num_sensors,num_field_components,num_time_steps).

get_sample_times() ndarray[source]

Gets the times at which the sensors sample the given physical field. This is specified by the user in the SensorData object or defaults to the time steps in the underlying simulation if unspecified.

Returns:

np.ndarray -- Sample times with shape: (num_time_steps,)

get_sensor_data_perturbed() SensorData | None[source]

Gets the final sensor array parameters after all errors in the error integrator have been applied. If no error integrator is specified then None is returned.

Returns:

SensorData | None -- The accumulated sensor array parameters as a SensorData object. Returns None if no error integrator has been specified.

get_truth() ndarray[source]

Gets the ground truth sensor values that were calculated previously. If the ground truth values have not been calculated then calc_truth_values() is called first.

Returns:

np.ndarray -- Array of ground truth sensor values. shape=(num_sensors, num_field_components,num_time_steps).

set_error_integrator(err_int: ErrIntegrator) None[source]

Sets the error intergrator that will be used to calculate the sensor array measurement errors when calc_measurements() is called. See the ErrIntegrator class for further detail.

Parameters:

err_int (ErrIntegrator) -- Error integration object with a chain of user defined sensor errors.