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
Profilewith a shared index.- Parameters:
index (
ndarray[floating] |Quantity) – Index nodes (e.g., altitudes) at whichdatavalues are present. If not aQuantity,index_unitmust be set.data (
ndarray[floating] |Quantity|QTable) – Data nodes (e.g., pressure or mixing ratio) at theindexlocations. If not aQuantity,data_unitsmust be set. Ifdatais a 2D NumPy array,indexapplies to the first axis (matching theQTablelayout).index_unit (
Unit|str|None, default:None) – Unit ofindex. Ignored ifindexis aQuantity, required if it is not.data_units (
List[Unit] |Unit|str|None, default:None) – Unit(s) ofdata. Ignored ifdatais aQuantityorQTable, 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 ifdatais not aQTable, 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 toTrueif 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 (default0). Set toNoneto use the leftmost valid value (seenumpy.interp()leftparameter 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 (default0). Set toNoneto use the rightmost valid value (seenumpy.interp()rightparameter 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 aQuantity, must already be in the unit of this profile [index_unit])- Return type:
- 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 orastropy.units.Unit, theindex_unitis assumed.- Return type:
- 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 whichdatavalues are present. If not aQuantity,index_unitmust be set.data (
ndarray[floating] |Quantity) – Data nodes (e.g., pressure or mixing ratio) at theindexlocations. If not aQuantity,data_unitmust be set.index_unit (
Unit|str|None, default:None) – Unit ofindex. Ignored ifindexis aQuantity, required if it is not.data_unit (
Unit|str|None, default:None) – Unit ofindex. Ignored ifindexis aQuantity, required if it is not.scale (
float, default:1.0) – Scaling factor to apply to data (in linear space)log (
bool, default:False) – Set toTrueif the input nodes are in logarithmic space, so that the output is transformed back to linear spacelower (
float|None, default:0.0) – Set the lower (left) values outside of the interpolating range to this value (default0). Set toNoneto use the leftmost valid value (seenumpy.interp()leftparameter with different default).upper (
float|None, default:0.0) – Set the upper (right) values outside of the interpolating range to this value (default0). Set toNoneto use the rightmost valid value (seenumpy.interp()rightparameter 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 inlowerandupper.
- 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 orastropy.units.Unit, theindex_unitis assumed.- Return type:
- xvamp.profile.cast_to_np(input, unit)[source]#
Convert a
Quantityinto a NumPy array of [unit], or simply return the input if it’s not aQuantity.
- 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
physicaltype.- Parameters:
- Raises:
astropy.units.errors.UnitsError – If the data (and/or index) is of the wrong physical type