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:
knots: ndarray[floating]#
lower: float#
upper: float#
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_indices is set.

Parameters:
  • lower (float) – Lower boundary

  • upper (float) – Upper boundary, wraps to lower one

  • knots (ndarray[floating]) – Array of knot values

  • const_between_indices (list[tuple], default: <factory>) – Force a constant value between these knot indices (reduces the number of basis functions created)

const_between_indices: list[tuple]#
knots: ndarray[floating]#
lower: float#
output_columns: list[tuple]#
period: float#
upper: float#

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. If None, 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 .csv file containing column names of the format “Name [Unit]”, read the data and return a QTable with the units correctly set.

Parameters:

path (Path) – Path to the file

Return type:

QTable

Returns:

Table with quantities and units

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 QTable matching data with units.

Parameters:
  • path (Path) – Path to the file

  • names (list[str]) – List of column names

  • formats (list[str]) – NumPy-readable format strings for each column

  • widths (list[int]) – List of column widths

  • units (list[str]) – List of astropy-readable unit strings

  • converters (dict, default: {}) – Column data converter functions passed on to genfromtxt()

Return type:

QTable

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 file

  • desc (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 unit

  • converters (dict, default: {}) – Column data converter functions passed on to genfromtxt()

Return type:

QTable

xvamp.utils.io.write_polarization_parameters(polarization_parameters, filename)[source]#

Write a TOML file containing all the polarization parameters.

Parameters:

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 Quantity because of the unknown exponent.

static get_A_mu(mu)[source]#

Compute the dipolar term in the dielectric virial expansion, assuming CGS units in the input, but SI in the output.

Parameters:

mu (Quantity) – Permanent dipole moment [esu cm]

Return type:

float | ndarray[floating]

Returns:

Dipolar term in the virial expansion [cm^3 K/mol]

A_mu: float = 0#

Dipolar term in the virial expansion [cm^3 K/mol]

D: float = 0#

[-]

T0: float = 273.16#

Temperature [K]

a0: float = 0#

[cm^3/mol]

a1: float = 0#

[cm^3/mol]

b0: float = 0#

[cm^6/mol^2]

b1: float = 0#

[cm^6/mol^2]

c0: float = 0#

[cm^(3(D+1))/mol^-(D+1)]

c1: float = 0#

[cm^(3(D+1))/mol^-(D+1)]

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]

delta_min: Quantity = <Quantity 0. MHz / Torr>#

Frequency shift parameter [MHz/torr]

gamma_min_maj: Quantity = <Quantity 0. MHz / Torr>#

Foreign-broadened linewidth parameter [MHz/torr]

gamma_min_min: Quantity#

Self-broadened linewidth parameter [MHz/torr]

m: float = 0.0#

Temperature dependence of the coupling [-]

n: float = 0.0#

Temperature dependence of the linewidth [-]

zeta_min_maj: Quantity = <Quantity 0. MHz / Torr>#

Foreign-coupling parameter [MHz/torr]

zeta_min_min: Quantity = <Quantity 0. MHz / Torr>#

Self-coupling linewidth parameter [MHz/torr]

class xvamp.utils.parametersets.Pitzer1983Parameters(mu, alpha_T)[source]#

Parameters for the Pitzer [1983] model to calculate the polarization per molar volume as given by Duan et al. [2010] on p. 5, eq. (14).

alpha_T: Annotated[Quantity, PhysicalType('volume')]#

Molecular polarizability [cm^3]

mu: Quantity#

Molecular dipole moment [esu cm = 1e18 D]