sensordescriptor.py¶
This module is used to create sensor descriptors which are strings used to label plots and visualisations for virtual sensor simulations.
- class SensorDescriptor(name='Measured Value', units='-', time_units='s', symbol='m', tag='S', components=None)[source]¶
Bases:
object
Dataclass for storing string descriptors for sensor array vis2ualisation. Used for labelling matplotlib and pyvista plots with the sensor name, physical units and other descriptors.
- name¶
String describing the field that the sensor measures e.g. temperature , strain etc. Defaults to ‘Measured Value’.
- units¶
String describing the sensor measurement units. Defaults to ‘-’. Latex symbols can be used with a raw string.
- time_units¶
String describing time units. Defaults to ‘s’.
- symbol¶
Symbol for describing the field the sensor measures. For example ‘T’ for temperature of r’epsilon’ for strain. Latex symbols can be used with a raw string.
- tag¶
String shorthand tag used to label sensors on pyvista plots. Defaults to ‘S’.
- components¶
Tuple of strings describing the field components. Defaults to None which is used for scalar fields. For vector fields use (‘x’,’y’,’z’) for 3D and for tensor fields use (‘xx’,’yy’,’zz’,’xy’,’yz’,’xz’).
- create_label(comp_ind=None)[source]¶
Creates an axis label for a matplotlib plot based on the sensor descriptor string. The axis label takes the form: ‘name, symbol [units]’ This version creates a label with line breaks which is useful for vertical colourbars.
- Parameters:
comp_ind (
int | None
, optional) – Index of the field component to create a label for, by default None. If None the first field component is used.- Returns:
str
– Axis label for field component in the form: ‘name, symbol [units]’.
- __init__(name='Measured Value', units='-', time_units='s', symbol='m', tag='S', components=None)¶
- create_label_flat(comp_ind=None)[source]¶
Creates an axis label for a matplotlib plot based on the sensor descriptor string. The axis label takes the form: ‘name, symbol [units]’ This version creates a label with no line breaks which is useful for axis labels on plots.
- Parameters:
comp_ind (
int | None
, optional) – Index of the field component to create a label for, by default None. If None the first field component is used.- Returns:
str
– Axis label for field component in the form: ‘name, symbol [units]’.
- create_sensor_tags(n_sensors)[source]¶
Creates a list of numbered sensor tags for labelling sensor locations or for graph legends. Tags are shorthand names for sensors such as TC for thermocouples or SG for strain gauges.
- Parameters:
n_sensors (
int
) – The number of sensors to create tags for.- Returns:
list[str]
– A list of sensor tags
- class SensorDescriptorFactory[source]¶
Bases:
object
A factory for building common sensor descriptors for scalar, vector and tensor fields. Builds descriptors for thermcouples, displacement sensors and strain sensors.
- static temperature_descriptor()[source]¶
Creates a generic temperature sensor descriptor. Assumes the sensor is measuring a temperature in degrees C.
- Returns:
SensorDescriptor
– The default temperature sensor descriptor.
- static displacement_descriptor()[source]¶
Creates a generic displacement sensor descriptor. Assumes units of mm and vector components of x,y,z.
- Returns:
SensorDescriptor
– The default displacement sensor descriptor.
- static strain_descriptor(spat_dims=3)[source]¶
Creates a generic strain sensor descriptor. Assumes strain is unitless and that the components are xx,yy,xy for 2D and xx,yy,zz,xy,yz, xz for 3D.
- Parameters:
spat_dims (
int
, optional) – Number of spatial dimensions used for setting the components of the tensor strain field, by default 3.- Returns:
SensorDescriptor
– The default strain sensor descriptor.