Mixin (taurex.mixin)¶
Core mixin functions.
- class AnyMixin(**kwargs)[source]¶
Bases:
Mixin[Any]Can enhance any class.
- KLASS_COMPAT¶
alias of
object
- class ContributionMixin(**kwargs)[source]¶
Bases:
Mixin[Contribution],objectEnhances
Contribution.- KLASS_COMPAT¶
alias of
Contribution
- class ForwardModelMixin(**kwargs)[source]¶
Bases:
Mixin[ForwardModel],objectEnhances
ForwardModel.- KLASS_COMPAT¶
alias of
ForwardModel
- class InstrumentMixin(**kwargs)[source]¶
Bases:
Mixin[Instrument],objectEnhances
Instrument.- KLASS_COMPAT¶
alias of
Instrument
- class Mixin(**kwargs)[source]¶
Bases:
MixinProtocol,Fittable,Citable,Generic[T]Base mixin class.
- KLASS_COMPAT: Type[T] = None¶
- class ObservationMixin(**kwargs)[source]¶
Bases:
SpectrumMixinEnhances
Spectrum.
- class PlanetMixin(**kwargs)[source]¶
Bases:
Mixin[Planet],objectEnhances
Planet.- KLASS_COMPAT¶
alias of
Planet
- class PressureMixin(**kwargs)[source]¶
Bases:
Mixin[PressureProfile],objectEnhances
PressureProfile.- KLASS_COMPAT¶
alias of
PressureProfile
- class SpectrumMixin(**kwargs)[source]¶
Bases:
Mixin[BaseSpectrum],objectEnhances
Spectrum.- KLASS_COMPAT¶
alias of
BaseSpectrum
- class TemperatureMixin(**kwargs)[source]¶
Bases:
Mixin[TemperatureProfile],objectEnhances
TemperatureProfile.- KLASS_COMPAT¶
alias of
TemperatureProfile
- build_new_mixed_class(base_klass: Type[T], mixins: Sequence[Type[M]]) Type[T | M][source]¶
Build a new mixed class.
- Parameters:
base_klass – Base class to mix with
mixins – Sequence of mixin classes
- determine_mixin_args(klasses: Sequence[Type[T] | Type[M]]) Tuple[Dict[str, Any], bool][source]¶
Determine all arguments for a mixin class.
- enhance_class(base_klass: Type[T], mixins: Sequence[Type[M]], **kwargs: Dict[str, Any]) T | M[source]¶
Build and initialise a new enhanced class.
- Parameters:
base_klass – Base class to mix with
mixins – Sequence of mixin classes
kwargs – Keyword arguments to pass to the constructor
- Returns:
A new class that is a subclass of base_klass and all mixins
- Return type:
t.Union[T, M]
- Raises:
KeyError: – If a keyword argument is not available in the new class
- find_mapped_mixin(klass: Type[T]) Type[Mixin][source]¶
Find a mapped mixin class.
- Parameters:
klass – Class to find the map.
Some implemented mixins.
- class MakeFreeMixin(**kwargs)[source]¶
Bases:
ChemistryMixinProvides a
addGas()method to any chemistryThis class will either inject or force a molecule to become a
Gasobject. Allowing them to be freely changed or retrieved.For example lets enhance ACE:
>>> from acepython.taurex import ACEChemistry >>> from taurex.mixin import enhance_class, MakeFreeMixin >>> old_ace = ACEChemistry() >>> new_ace = enhance_class(ACEChemistry, MakeFreeMixin)
new_acebehaves the same asold_ace:>>> new_ace.ace_metallicity 1.0
And we see the same molecules and fitting parameters exist:
>>> old_ace.gases == new_ace.gases True >>> new_ace.gases ['CH3COOOH', 'C4H9O', ... 'HNC', 'HON', 'NCN'] >>> new_ace.fitting_parameters().keys() dict_keys(['ace_metallicity', 'metallicity', 'ace_co', 'C_O_ratio'])
new_aceis embued with the>>> from taurex.chemistry import ConstantGas >>> new_ace.addGas(ConstantGas('TiO',1e-8)).addGas(ConstantGas('VO',1e-8)) >>> new_ace.gases == old_ace.gases False >>> new_ace.gases ['CH3COOOH', 'C4H9O', ... 'HNC', 'HON', 'NCN', 'TiO', 'VO']
And indeed see that they are included. We can also retrieve them:
>>> new_ace.fitting_parameters().keys() dict_keys(['TiO', 'VO', 'ace_metallicity', 'metallicity', 'ace_co', 'C_O_ratio'])
Finally we can force an existing molecule like CH4 into becoming a Gas:
>>> new_ace.addGas(ConstantGas('CH4',1e-5))
And see that it is now a retrieval parameter as well.
>>> new_ace.fitting_parameters().keys() dict_keys(['TiO', 'VO', 'CH4', 'ace_metallicity', 'metallicity', 'ace_co', 'C_O_ratio'])
- property activeGasMixProfile: ndarray[tuple[int, ...], dtype[float64]]¶
Active gas layer by layer mix profile.
- Returns:
active_mix_profile
- Return type:
array
- property activeGases: List[str]¶
Active gases in the atmosphere + injected.
- addGas(gas: Gas) MakeFreeMixin[source]¶
Adds a gas in the atmosphere.
- Parameters:
gas (
Gas) – Gas to add into the atmosphere. Only takes effect on next initialization call.
- compute_mu_profile(nlayers: int)[source]¶
Computes molecular weight of atmosphere for each layer.
- Parameters:
nlayers (int) – Number of layers, deprecated
- fitting_parameters() Dict[str, Tuple[str, str, Callable[[], float], Callable[[float], None], Literal['linear', 'log'], bool, Tuple[float, float]]][source]¶
Adds fitting parameters for injected gases.
Overrides the fitting parameters to return one with all the gas profile parameters as well
- Returns:
fit_param
- Return type:
dict
- property gases: List[str]¶
Gases in the atmosphere + injected.
- property inactiveGasMixProfile: ndarray[tuple[int, ...], dtype[float64]]¶
Inactive gas layer by layer mix profile
- Returns:
inactive_mix_profile
- Return type:
array
- property inactiveGases: List[str]¶
Inactive gases in the atmosphere + injected.
- initialize_chemistry(nlayers: int, temperature_profile: ndarray[tuple[int, ...], dtype[float64]], pressure_profile: ndarray[tuple[int, ...], dtype[float64]], altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]¶
Initialize the chemistry.
- Parameters:
nlayers (int) – number of layers
temperature_profile (np.ndarray) – temperature profile
pressure_profile (np.ndarray) – pressure profile
altitude_profile (np.ndarray , optional) – altitude profile, deprecated
- property muProfile: ndarray[tuple[int, ...], dtype[float64]]¶
Molecular weight profile.
- Returns:
mu_profile
- Return type:
array
- class TempScaler(**kwargs)[source]¶
Bases:
TemperatureMixinScales the temperature profile by a factor.
Mostly a proof of concept class for mixins. Not particularly useful in practice.
- property profile: ndarray[tuple[int, ...], dtype[float64]]¶
Scaled temperature profile.
- property scaleFactor: float¶
Scale factor for temperature profile.