baldaquin.egu — Engineering units#

Module documentation#

Engineering units and converters.

class baldaquin.egu.ConversionBase[source]#

Abstract base class for a generic conversion.

_conversion_function(raw) None[source]#

Conversion function, to be reimplemented in derived classes.

class baldaquin.egu.LinearConversion(slope: float, intercept: float = 0)[source]#

Linear conversion.

_conversion_function(raw)[source]#

Overloaded method.

class baldaquin.egu.SplineConversion(raw: array, physical: array, k: int = 3)[source]#

Spline conversion.

This is performing a simple spline interpolation of the physical values vs. the raw values.

Parameters:
  • raw (array_like) – The array of raw values.

  • physical (array_like) – The array of physical values

  • k (int (default 3)) – The degree of the interpolating spline.

static _process_input(raw, physical) tuple[array, array][source]#

Sort and remove duplicates from the input arrays.

In order for us to be able to build the spline, the x (raw) values must be passed in ascending order, and the y (physical) values must be (potentially) shuffled accordingly.

Looking around on the internet, it seems like simply checking if an array is sorted is almost as expensive as calling argsort or unique, see, e.g., numpy/numpy#8392 and therefore we just go ahead and re-sort everything and remove duplicates even when there is nothing to do.

static read_data(file_path: str, col_raw: int = 0, col_physical: int = 1, **kwargs)[source]#

Read data from file.

Parameters:
  • file_path (str) – The path to the input text file containing the data.

  • col_raw (int) – The index of the column containing the raw values.

  • col_physical (int) – The index of the column containing the physical values.

  • kwrargs (dict) – optional keyword arguments passed to np.loadtxt()

classmethod from_file(file_path: str, col_raw: int = 0, col_physical: int = 1, k: int = 3) None[source]#

Read the data points for the spline from a file.

plot()[source]#

Plot the interpolating spline.

_conversion_function(raw)[source]#

Overloaded method.

class baldaquin.egu.ThermistorConversion(temperature: array, resistance: array, shunt_resistance: float, adc_num_bits: int, k: int = 3)[source]#

Specific conversion for a thermistor.

classmethod from_file(file_path: str, shunt_resistance: float, adc_num_bits: int, col_temperature: int = 0, col_resistance: int = 1, k: int = 3) None[source]#

Read the data points for the spline from file.