joseki.profiles.core

Core module for atmosphere thermophysical profiles.

The Profile abstract class defines the interface for atmosphere thermophysical profiles. The interp() function is used to interpolate an atmosphere thermophysical profile on new altitude values.

Attributes

Classes

Profile

Abstract class for atmosphere thermophysical profiles.

Functions

extrapolate(ds, z_extra, direction[, method, ...])

Extrapolate an atmospheric profile to new altitude(s).

interp(ds, z_new[, method, conserve_column])

Interpolate atmospheric profile on new altitudes.

regularize(ds[, method, conserve_column, options])

Regularize the profile's altitude grid.

rescale_to_column(reference, ds)

Rescale mole fraction to ensure that column densities are conserved.

select_molecules(ds, molecules)

Select specified molecules in the profile.

Module Contents

class joseki.profiles.core.Profile[source]

Bases: abc.ABC

Abstract class for atmosphere thermophysical profiles.

abstract to_dataset(z=None, interp_method=None, conserve_column=False, **kwargs)[source]

Return the profile as a dataset.

Parameters:
  • z (Optional[pint.Quantity]) – Altitude grid. If the profile can be evaluated at arbitrary altitudes, this parameter is passed to the evaluating method for that profile. If the profile is defined on a fixed altitude grid, this parameter is used to interpolate the profile on the specified altitude grid.

  • interp_method (Optional[Mapping[str, str]]) – Interpolation method for each variable. If None, the default interpolation method is used. Interpolation may be required if the profile is defined on a fixed altitude grid, and the altitude grid is not the same as the one used to define the profile. Interpolation may also not be required, e.g. if the profile is defined by analytical function(s) of the altitude variable.

  • conserve_column (bool) – If True, ensure that column densities are conserved during interpolation.

  • kwargs (Any) – Parameters passed to lower-level methods.

Returns:

Atmospheric profile.

Return type:

xarray.Dataset

joseki.profiles.core.extrapolate(ds, z_extra, direction, method=DEFAULT_METHOD, conserve_column=False)[source]

Extrapolate an atmospheric profile to new altitude(s).

Parameters:
  • ds (xarray.Dataset) – Initial atmospheric profile.

  • z_extra (pint.Quantity) – Altitude(s) to extrapolate to.

  • direction (str) – Direction of the extrapolation, either “up” or “down”.

  • method (Dict[str, str]) – Mapping of variable and interpolation method. If a variable is not in the mapping, the linear interpolation is used. By default, linear interpolation is used for all variables.

  • conserve_column (bool) – If True, ensure that column densities are conserved.

Raises:

ValueError – If the extrapolation direction is not “up” or “down”.

Returns:

Extrapolated atmospheric profile.

Return type:

xarray.Dataset

joseki.profiles.core.interp(ds, z_new, method=DEFAULT_METHOD, conserve_column=False, **kwargs)[source]

Interpolate atmospheric profile on new altitudes.

Parameters:
  • ds (xarray.Dataset) – Atmospheric profile to interpolate.

  • z_new (pint.Quantity) – Altitudes values at which to interpolate the atmospheric profile.

  • method (Dict[str, str]) – Mapping of variable and interpolation method. If a variable is not in the mapping, the linear interpolation is used. By default, linear interpolation is used for all variables.

  • conserve_column (bool) – If True, ensure that column densities are conserved.

  • kwargs (Any) – Parameters passed to scipy.interpolate.interp1d() (except ‘kind’ and ‘bounds_error’).

Returns:

Interpolated atmospheric profile.

Return type:

xarray.Dataset

joseki.profiles.core.regularize(ds, method=DEFAULT_METHOD, conserve_column=False, options=DEFAULT_OPTIONS, **kwargs)[source]

Regularize the profile’s altitude grid.

Parameters:
  • ds (xarray.Dataset) – Initial atmospheric profile.

  • method (Dict[str, str]) – Mapping of variable and interpolation method. If a variable is not in the mapping, the linear interpolation is used. By default, linear interpolation is used for all variables.

  • conserve_column (bool) – If True, ensure that column densities are conserved.

  • options (Dict[str, Union[int, str, pint.Quantity]]) –

    Options for the regularization. Mapping with possible keys:

    • ”num”: Number of points in the new altitude grid.

    • ”zstep”: Altitude step in the new altitude grid. If “auto”, the minimum altitude step is used.

  • kwargs (Any) – Keyword arguments passed to the interpolation function.

Returns:

Regularized atmospheric profile.

Return type:

xarray.Dataset

joseki.profiles.core.rescale_to_column(reference, ds)[source]

Rescale mole fraction to ensure that column densities are conserved.

Parameters:
Returns:

Rescaled profile.

Return type:

xarray.Dataset

joseki.profiles.core.select_molecules(ds, molecules)[source]

Select specified molecules in the profile.

Parameters:
  • ds (xarray.Dataset) – Initial atmospheric profile.

  • molecules (List[str]) – List of molecules to select.

Returns:

Atmospheric profile with exactly the specified molecules.

Return type:

xarray.Dataset

joseki.profiles.core.DEFAULT_METHOD
joseki.profiles.core.DEFAULT_OPTIONS
joseki.profiles.core.logger