sensorspoint.py

class SensorsPoint(sensor_data, field, descriptor=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 IErrSimulator interface). Further information can be found in the ErrIntegrator class and in implementations of the IErrSimulator interface.

In pyvale, function and methods with sim or 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 any computationally intensive calculations.

Calling the class method sim_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 sim_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 or mesh-free linear interpolation based on Delaunay triangulation.

__init__(sensor_data, field, descriptor=None)[source]
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.

get_descriptor()[source]

Gets the sensor descriptor data class which contains a series of strings used to describe the sensor array.

Returns:

SensorDescriptor – Data class containing strings used to describe the sensor array for visualisations and plots.

get_sample_times()[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_measurement_shape()[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_field()[source]

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

Returns:

IField – Reference to an IField interface.

calc_truth()[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_truth()[source]

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

Returns:

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

get_error_integrator()[source]

Gets the error integrator allowing the user to interpret error sources in the error chain and to separate random and systematic error contributions.

Returns:

ErrIntegrator | None – The error integrator.

set_error_chain(err_chain, err_int_opts=None)[source]

Sets the error chain that will be used to calculate the sensor array measurement errors when sim_measurements() is called. See the ErrIntegrator class for further details as to how errors are calculated.

Parameters:
  • err_chain (list[IErrSimulator] | None) – Chain of user defined errors that will be evaluated in order as part of the sensor simulation. Set to None to remove error calculation and perform direct interpolation of the simulation to the virtual sensor locations.

  • err_int_opts (ErrIntOpts | None, optional) – Sets the options of virtual sensor error integration, by default None. If None default options are used.

get_errors_systematic()[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_random()[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_total()[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.

sim_measurements()[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.

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_measurements()[source]

Returns the current set of simulated measurements if theses have been calculated. If these have not been calculated then ‘sim_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).