Utils#
Utility module containing helper functions and classes.
- xvamp.utils.complex_or_array = complex | numpy.ndarray[numpy.complexfloating]#
Either a single complex number or an array of complex numbers
- xvamp.utils.float_or_array = float | numpy.ndarray[numpy.floating]#
Either a single float number or an array of float numbers
Interpolation#
Interpolation helper functions.
- class xvamp.utils.interpolate.BoundedInterpolatingBasis(lower, upper, knots)[source]#
Smooth interpolator for models defined on bounded input. Uses sine and cosine squared as basis functions. Assumes constant values between the boundaries and the closest adjacent knots, and transitions between knots.
- Parameters:
- class xvamp.utils.interpolate.PeriodicInterpolatingBasis(lower, upper, knots, const_between_indices=<factory>)[source]#
Smooth interpolator for models defined on periodic input. Uses sine and cosine squared as basis functions. Assumes transitions between knots (including across the boundaries), except where
const_between_indicesis set.- Parameters:
Input and Output#
In- and output helper functions.
- xvamp.utils.io.read_polarization_parameters(filename=None)[source]#
Read a TOML file containing all the polarization parameters.
- Parameters:
filename (
str|Path|None, default:None) – Full file name to read the polarization parameters from. IfNone, the XVAMP defaults will be loaded.- Return type:
dict[str,HarveyLemmon2005Parameters|Pitzer1983Parameters]- Returns:
Dictionary that containes the parameter objects for each species
- xvamp.utils.io.read_unit_csv(path)[source]#
Given a path to a
.csvfile containing column names of the format “Name [Unit]”, read the data and return aQTablewith the units correctly set.
- xvamp.utils.io.read_unit_fwf(path, names, formats, widths, units, converters={})[source]#
Given a path to a fixed-width text file and lists describing the column names, widths, and units, return a
QTablematching data with units.- Parameters:
path (
Path) – Path to the fileformats (
list[str]) – NumPy-readable format strings for each columnconverters (
dict, default:{}) – Column data converter functions passed on togenfromtxt()
- Return type:
- Returns:
Table with quantities and units
- xvamp.utils.io.read_unit_fwf_desc(path, desc, converters={})[source]#
Wrapper around
read_unit_fwf()if the names, units, formats, and widths are given in a list of tuples.- Parameters:
path (
Path) – Path to the filedesc (
list[tuple[str,str,str,int]]) – Description as a list, where each entry corresponds to a column in the data and is a tuple with the four entries name, format, width and unitconverters (
dict, default:{}) – Column data converter functions passed on togenfromtxt()
- Return type:
- xvamp.utils.io.write_polarization_parameters(polarization_parameters, filename)[source]#
Write a TOML file containing all the polarization parameters.
- Parameters:
polarization_parameters (
dict[str,HarveyLemmon2005Parameters|Pitzer1983Parameters]) – Dictionary that containes the parameter objects for each speciesfilename (
str|Path) – Full file name to write the polarization parameters to.
Parameter Sets#
Module containing classes which enable a convenient and well-documented way to store and compare parameter sets.
- class xvamp.utils.parametersets.HarveyLemmon2005Parameters(a0=0, a1=0, b0=0, b1=0, c0=0, c1=0, D=0, T0=273.16, A_mu=0)[source]#
Parameters for mixture components from Harvey and Lemmon [2005], as represented in Duan et al. [2010], Table 1 for eq. (8). Parameters are NOT converted to astropy
Quantitybecause of the unknown exponent.
- class xvamp.utils.parametersets.LineShapeParameters(T_0, gamma_min_min, gamma_min_maj=<Quantity 0. MHz / Torr>, zeta_min_min=<Quantity 0. MHz / Torr>, zeta_min_maj=<Quantity 0. MHz / Torr>, delta_min=<Quantity 0. MHz / Torr>, m=0.0, n=0.0)[source]#
Line shape parameters compatible with the Ben-Reuven line shape function, following the notation from Duan et al. [2010], eqs. (27-32) on p. 10f. Can be used for Lorentzian line shapes if only specifying
gamma_min_min.- T_0: Annotated[Quantity, PhysicalType('temperature')]#
Reference temperature of broadening coefficients [K]