joseki.accessor

Accessor module.

Attributes

Classes

JosekiAccessor

Joseki accessor.

Functions

molecular_mass(m)

Return the average molecular mass of a molecule.

Module Contents

class joseki.accessor.JosekiAccessor(xarray_obj)[source]

Joseki accessor.

drop_molecules(molecules)[source]

Drop molecules from dataset.

Parameters:

molecules (List[str]) – List of molecules to drop.

Returns:

Dataset with molecules dropped.

Return type:

xarray.Dataset

rescale(factors, check_x_sum=False)[source]

Rescale molecules concentration in atmospheric profile.

Parameters:
  • factors (MutableMapping[str, float]) – A mapping of molecule and scaling factor.

  • check_x_sum (bool) – if True, check that mole fraction sums are never larger than one.

Raises:

ValueError – if check_x_sum is True and the dataset is not valid.

Returns:

Rescaled dataset (new object).

Return type:

xarray.Dataset

rescale_to(target, check_x_sum=False)[source]

Rescale mole fractions to match target molecular total column densities.

Parameters:
  • target (Mapping[str, pint.Quantity | dict | xarray.DataArray]) – Mapping of molecule and target total column density. Total column must be either a column number density [length^-2], a column mass density [mass * length^-2], a number density at sea level [length^-3], a mass density at sea level [mass * length^-3], a mole fraction at sea level [dimensionless].

  • check_x_sum (bool) – if True, check that mole fraction sums are never larger than one.

Returns:

Rescaled dataset (new object).

Return type:

xarray.Dataset

scaling_factors(target)[source]

Compute scaling factor(s) to reach specific target amount(s).

Parameters:

target (MutableMapping[str, pint.Quantity | dict | xarray.DataArray]) – Mapping of molecule and target amount.

Raises:

ValueError – If a target amount has dimensions that are not supported.

Returns:

Mapping of molecule and scaling factors.

Return type:

MutableMapping[str, float]

Notes

For each molecule in the target mapping, the target amount is interpreted, depending on its dimensions (indicated in square brackets), as:

  • a column number density [length^-2],

  • a column mass density [mass * length^-2],

  • a number density at sea level [length^-3],

  • a mass density at sea level [mass * length^-3],

  • a mole fraction at sea level [dimensionless]

The scaling factor is then evaluated as the ratio of the target amount with the original amount, for each molecule.

See also

rescale

validate(check_x_sum=False, ret_true_if_valid=False)[source]

Validate atmosphere thermophysical profile dataset schema.

Returns:

True if the dataset complies with the schema, else False.

Parameters:
  • check_x_sum (bool)

  • ret_true_if_valid (bool)

Return type:

bool

property air_molar_mass: xarray.DataArray

Compute air molar mass as a function of altitude.

Returns:

Air molar mass.

Return type:

xarray.DataArray

Notes

The air molar mass is given by:

\[M_{\mathrm{air}} = \frac{ \sum_{\mathrm{M}} x_{\mathrm{M}} \, m_{\mathrm{M}} }{ \sum_{\mathrm{M}} x_{\mathrm{M}} }\]

where

  • \(x_{\mathrm{M}}\) is the mole fraction of molecule M,

  • \(m_{\mathrm{M}}\) is the molar mass of molecule M.

To compute the air molar mass accurately, the mole fraction of molecular nitrogen (N2), molecular oxygen (O2), and argon (Ar) are required. If these are not present in the dataset, they are computed using the assumption that the mole fraction of these molecules are constant with altitude and set to the following values:

  • molecular nitrogen (N2): 0.78084

  • molecular oxygen (O2): 0.209476

  • argon (Ar): 0.00934

are independent of altitude.

Since nothing guarantees that the mole fraction sum is equal to one, the air molar mass is computed as the sum of the mole fraction weighted molar mass divided by the sum of the mole fraction.

property air_number_density: xarray.DataArray
Return type:

xarray.DataArray

property column_mass_density: Dict[str, pint.Quantity]

Compute column mass density.

Returns:

A mapping of molecule and column mass density.

Return type:

Dict[str, pint.Quantity]

Notes

The column mass density is given by:

\[\sigma_{\mathrm{M}} = N_{\mathrm{M}} \, m_{\mathrm{M}}\]

where

  • \(N_{\mathrm{M}}\) is the column number density of molecule M,

  • \(m_{\mathrm{M}}\) is the molecular mass of molecule M.

property column_number_density: Dict[str, pint.Quantity]

Compute column number density.

Returns:

A mapping of molecule and column number density.

Return type:

Dict[str, pint.Quantity]

Notes

The column number density is given by:

\[N_{\mathrm{M}} = \int n_{\mathrm{M}}(z) \, \mathrm{d} z\]

with

\[n_{\mathrm{M}}(z) = x_{\mathrm{M}}(z) \, n(z)\]

where

  • \(z\) is the altitude,

  • \(x_{\mathrm{M}}(z)\) is the mole fraction of molecule M at altitude \(z\),

  • \(n(z)\) is the air number density at altitude \(z\),

  • \(n_{\mathrm{M}}(z)\) is the number density of molecule M at altitude \(z\).

The integration is performed using the trapezoidal rule.

property is_valid

Return True if the dataset complies with the schema, else False.

property mass_density_at_sea_level: Dict[str, pint.Quantity]

Compute mass density at sea level.

Returns:

A mapping of molecule and mass density at sea level.

Return type:

Dict[str, pint.Quantity]

property mass_fraction: xarray.DataArray

Extract mass fraction and tabulate as a function of (m, z).

Returns:

Mass fraction.

Return type:

xarray.DataArray

property mole_fraction: xarray.DataArray

Extract mole fraction and tabulate as a function of (m, z).

Returns:

Mole fraction.

Return type:

xarray.DataArray

property mole_fraction_at_sea_level: Dict[str, pint.Quantity]

Compute mole fraction at sea level.

Returns:

A mapping of molecule and mole fraction at sea level.

Return type:

Dict[str, pint.Quantity]

property molecules: List[str]

Return list of molecules.

Return type:

List[str]

property number_density: xarray.DataArray

Compute number densities for each species as a function of altitude and return them as a data array.

Return type:

xarray.DataArray

property number_density_at_sea_level: Dict[str, pint.Quantity]

Compute number density at sea level.

Returns:

A mapping of molecule and number density at sea level.

Return type:

Dict[str, pint.Quantity]

joseki.accessor.molecular_mass(m)[source]

Return the average molecular mass of a molecule.

Parameters:

m (str) – Molecule formula.

Returns:

Average molecular mass.

Return type:

pint.Quantity

joseki.accessor.logger