Profile#

Provides the Profile class which allows convenient definition and flexible inter- and extrapolation of any type of profile.

class xvamp.profile.MultiProfile(index, data, index_unit=None, data_units=None, data_names=None, scales=1.0, log=False, lower=0.0, upper=0.0)[source]#

Class providing an interface to define multiple Profile with a shared index.

Parameters:
  • index (ndarray[floating] | Quantity) – Index nodes (e.g., altitudes) at which data values are present. If not a Quantity, index_unit must be set.

  • data (ndarray[floating] | Quantity | QTable) – Data nodes (e.g., pressure or mixing ratio) at the index locations. If not a Quantity, data_units must be set. If data is a 2D NumPy array, index applies to the first axis (matching the QTable layout).

  • index_unit (Unit | str | None, default: None) – Unit of index. Ignored if index is a Quantity, required if it is not.

  • data_units (List[Unit] | Unit | str | None, default: None) – Unit(s) of data. Ignored if data is a Quantity or QTable, required if it is not. If a single unit and the data is 2D, the unit is applied to all.

  • data_names (List[str] | None, default: None) – List of names of the data column(s). Required if data is not a QTable, otherwise it is optional and would override the column names.

  • scales (List[float] | float, default: 1.0) – Scaling factor to apply to data (in linear space). If a single factor and the data is 2D, the factor is applied to all.

  • log (List[bool] | bool, default: False) – Set to True if the input data nodes are in logarithmic space, so that the output is transformed back to linear space. If a single flag and the data is 2D, the flag is applied to all.

  • lower (List[float] | float | None, default: 0.0) – Set the lower (left) values outside of the interpolating range to this value (default 0). Set to None to use the leftmost valid value (see numpy.interp() left parameter with different default). If a single flag and the data is 2D, the flag is applied to all.

  • upper (List[float] | float | None, default: 0.0) – Set the upper (right) values outside of the interpolating range to this value (default 0). Set to None to use the rightmost valid value (see numpy.interp() right parameter with different default). If a single flag and the data is 2D, the flag is applied to all.

evaluate(new_index)[source]#

Inter- or extrapolate all subprofiles onto a new index, respecting their data space and continuation settings.

Parameters:

new_index (ndarray[floating] | Quantity) – New index values (if not a Quantity, must already be in the unit of this profile [index_unit])

Return type:

QTable

Returns:

New data values in their respective units, where each column corresponds to the individual subprofiles as ordered in data_names

index_to(unit=None)[source]#

Return the index as as an array in a given unit.

Parameters:

unit (Unit | str | None, default: None) – If not a string or astropy.units.Unit, the index_unit is assumed.

Return type:

ndarray[floating]

data_names: List[str]#

Names of the individual profiles

index: ndarray[floating]#

Index nodes of data

property index_as_quantity: Quantity#

Return the index as a Quantity.

index_unit: Unit#

Unit of index

property shape: tuple[int, int]#

Equivalent shape of the data subprofile, i.e. (length of index, number of data columns)

property size: int#

Equivalent size of the data subprofile, i.e. (length of index * number of data columns)

class xvamp.profile.Profile(index, data, index_unit=None, data_unit=None, scale=1.0, log=False, lower=0.0, upper=0.0, check=True)[source]#

Class providing interfaces to loading and interpolating generic atmospheric profiles.

Parameters:
  • index (ndarray[floating] | Quantity) – Index nodes (e.g., altitudes) at which data values are present. If not a Quantity, index_unit must be set.

  • data (ndarray[floating] | Quantity) – Data nodes (e.g., pressure or mixing ratio) at the index locations. If not a Quantity, data_unit must be set.

  • index_unit (Unit | str | None, default: None) – Unit of index. Ignored if index is a Quantity, required if it is not.

  • data_unit (Unit | str | None, default: None) – Unit of index. Ignored if index is a Quantity, required if it is not.

  • scale (float, default: 1.0) – Scaling factor to apply to data (in linear space)

  • log (bool, default: False) – Set to True if the input nodes are in logarithmic space, so that the output is transformed back to linear space

  • lower (float | None, default: 0.0) – Set the lower (left) values outside of the interpolating range to this value (default 0). Set to None to use the leftmost valid value (see numpy.interp() left parameter with different default).

  • upper (float | None, default: 0.0) – Set the upper (right) values outside of the interpolating range to this value (default 0). Set to None to use the rightmost valid value (see numpy.interp() right parameter with different default).

  • check (bool, default: True) – Check the input shapes and index monotonicity.

evaluate(new_index)[source]#

Linearly inter- or extrapolates the profile data (either in linear or logarithmic space, depending on how it is stored, see log) onto a new index given the down- and upward continuation settings in lower and upper.

Parameters:

new_index (ndarray[floating] | Quantity) – New index values (if not a Quantity, must already be in the unit of this profile [index_unit])

Return type:

Quantity

Returns:

New data values in [data_unit]

index_to(unit=None)[source]#

Return the index as as an array in a given unit.

Parameters:

unit (Unit | str | None, default: None) – If not a string or astropy.units.Unit, the index_unit is assumed.

Return type:

ndarray[floating]

to(unit=None)[source]#

Return the data as as an array in a given unit.

Parameters:

unit (Unit | str | None, default: None) – If not a string or astropy.units.Unit, the data_unit is assumed.

Return type:

ndarray[floating]

property as_quantity: Quantity#

Return the data as a Quantity.

data: ndarray[floating]#

Data values at the indices

data_unit: Unit#

Unit of data

index: ndarray[floating]#

Index nodes of data

property index_as_quantity: Quantity#

Return the index as a Quantity.

index_unit: Unit#

Unit of index

log: bool#

Whether data is saved in logarithmic space

lower: float | None#

Sets downward continuation to this value or last valid one

property shape: tuple[int, int]#

Shape of index and data

property size: int#

Number of elements in index and data (each)

upper: float | None#

Sets downward continuation to this value or last valid one

xvamp.profile.cast_to_np(input, unit)[source]#

Convert a Quantity into a NumPy array of [unit], or simply return the input if it’s not a Quantity.

Return type:

Any | ndarray[floating]

xvamp.profile.check_physical_type(p, data_physical_type, index_physical_type=None, name=None)[source]#

Check whether a Profile has data (and optionally, index) of the desired physical type.

Parameters:
  • p (Profile) – Profile to check

  • data_physical_type (str) – Desired physical type of the data

  • index_physical_type (str | None, default: None) – Desired physical type of the index

  • name (str | None, default: None) – Add this name to the raised error if a check fails

Raises:

astropy.units.errors.UnitsError – If the data (and/or index) is of the wrong physical type