sensordescriptor

This module is used to create sensor descriptors which are strings used to label plots and visualisations for virtual sensor simulations.

class pyvale.sensordescriptor.SensorDescriptor(name: str = 'Measured Value', units: str = '-', time_units: str = 's', symbol: str = 'm', tag: str = 'S', components: tuple[str, ...] | None = 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.

components: tuple[str, ...] | None

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: int | None = None) str[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]'.

create_label_flat(comp_ind: int | None = None) str[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: int) list[str][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

name: str

String describing the field that the sensor measures e.g. temperature , strain etc. Defaults to 'Measured Value'.

symbol: str

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: str

String shorthand tag used to label sensors on pyvista plots. Defaults to 'S'.

time_units: str

String describing time units. Defaults to 's'.

units: str

String describing the sensor measurement units. Defaults to '-'. Latex symbols can be used with a raw string.

class pyvale.sensordescriptor.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 displacement_descriptor() SensorDescriptor[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: int = 3) SensorDescriptor[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.

static temperature_descriptor() SensorDescriptor[source]

Creates a generic temperature sensor descriptor. Assumes the sensor is measuring a temperature in degrees C.

Returns:

SensorDescriptor -- The default temperature sensor descriptor.