baldaquin.egu
— Engineering units#
Module documentation#
Engineering units and converters.
- class baldaquin.egu.LinearConversion(slope: float, intercept: float = 0)[source]#
Linear conversion.
- 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()