Core (taurex.core)¶
Retrieval¶
This module relates to defining fitting parameters in TauREx3.
- class DerivedCallable(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for derived callables.
- compute: bool¶
Compute by default?
- decorated: Literal['derivedparam'] = 'derivedparam'¶
Decorated type.
- fget: Callable[[], float]¶
Getter.
- param_latex: str¶
Parameter name in latex.
- param_name: str¶
Parameter name.
- class DerivedPropertyType[source]¶
Bases:
object- fget: DerivedCallable¶
- class Fittable[source]¶
Bases:
objectA class that manages fitting parameters.
Not really used on its own it should really be inherited from to be used properly. It also provides class with the ability to read and write fitting parameters using their params names, for example, if we create a class like this:
class Foo(Fittable): def __init__(self): self.value = 10 @fitparam(param_name='foobar',param_latex='$Foo^{bar}$',default_bounds=[1,12]) def bar(self): return self.value @bar.setter def bar(self,value): self.value = value
We can read and write data in the standard python way like so:
>>> foo = Foo() >>> foo.bar 10 >>> foo.bar = 20 >>> foo.bar 20
but we also get this functionality for free:
>>> foo['foobar'] 20 >>> foo['foobar'] = 30 >>> foo['foobar'] 30
- add_derived_param(param_name: str, param_latex: str, fget: Callable[[], float], compute: bool) None[source]¶
- add_fittable_param(param_name: str, param_latex: str, fget: Callable[[], float], fset: Callable[[float], None], default_mode: Literal['linear', 'log'], default_fit: bool, default_bounds: Tuple[float, float]) None[source]¶
Adds a fittable parameter to the internal dictionary.
Used during init to add all
fitparam()decorated methods and can also be utilized by a user to manually add new fitting parameters. This is useful for giving fitting parameters names that depend on certain attributes (e.g. molecule name in a gas profile seeConstantGas) or when converting lists into fitting parameters (e.g. Normalization factor in light curves see:LightCurveModel)- Parameters:
param_name (str) – Nicer name of the parameter. Referenced by the optimizer.
param_latex (str) – Latex version of the parameter name, useful in plotting and making figures
fget (function) – a function that returns the value of the parameter
fset (function) – a function the writes the value of the parameter
default_mode (
linearorlog) – Defines how the optimizer should read and write the parameter.linearreads/write everything as is.loginforms the optimizer to transform from native->log space when read and to transfrom log->native when writing. This also applies to the boundariesdefault_fit (bool) – Whether this is included in the fit without the user explicity saying so (Default: False)
default_bounds (
list) – Default minimum and maximum fitting boundary. Must always be defined in the native space
- compile_fitparams() None[source]¶
Loops through and finds all fitting parameters.
These are defined through the decorator in the class and adds it to the internal dictionary
- derived_parameters() Dict[str, Tuple[str, str, Callable[[], float], bool]][source]¶
Returns all derived fitting parameters.
- find_derivedparams() Generator[DerivedPropertyType, None, None][source]¶
Finds and returns fitting parameters.
- Yields:
method (function) – class method that is defined with the
derivedparam()decorator
- find_fitparams() Generator[FitPropertyType, None, None][source]¶
Finds and returns fitting parameters.
- Yields:
method (function) – class method that is defined with the
fitparam()decorator
- fitting_parameters() Dict[str, Tuple[str, str, Callable[[], float], Callable[[float], None], Literal['linear', 'log'], bool, Tuple[float, float]]][source]¶
Returns all fitting parameters found as a dictionary.
- Returns:
params – Dictionary with key as the parameter name (
param_name) and value as a tuple with:parameter name
parameter name in Latex form
get function
set function
fitting scale
fit as default
fitting boundaries
- Return type:
dict
- modify_bounds(parameter: str, new_bounds: Tuple[float, float])[source]¶
Modifies the fitting boundary of a parameter
- Parameters:
parameter (str) – Name of parameter (given by
param_nameinfitparam())new_bounds (
list) – New minimum and maximum fitting boundaries.
- class FittingCallable(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for fitting callables.
- decorated: Literal['fitparam'] = 'fitparam'¶
Decorated type.
- default_bounds: List[float]¶
Default fitting boundaries.
- default_fit: bool¶
Fit by default?
- default_mode: Literal['linear', 'log']¶
Default fitting mode.
- doc: str | None = None¶
Docstring.
- fdel: Callable[[], None] | None = None¶
- fget: Callable[[], float]¶
Getter.
- fset: Callable[[float], None]¶
Setter.
- param_latex: str¶
Parameter name in latex.
- param_name: str¶
Parameter name.
- class T¶
Generic type.
alias of TypeVar(‘T’)
- derivedparam(f: Callable[[], float] | None = None, param_name: str | None = None, param_latex: str | None = None, compute: bool | None = False) DerivedCallable[source]¶
Dectorator to mark derivable parameters.
A decorator used in conjunction with
Fittableto inform which parameters should be derived during retrieval. This allows for posteriors of parameters such as log(g) and mu- Parameters:
f (function) – Function being passed. Automatically done when used as a decorator
param_name (str) – Nicer name of the parameter. Referenced by the optimizer.
param_latex (str) – Latex version of the parameter name, useful in plotting and making figures
compute (bool) – By default, is this computed?
- fitparam(f: Callable[[float], T] | None = None, param_name: str | None = None, param_latex: str | None = None, default_mode: Literal['linear', 'log'] | None = 'linear', default_fit: bool | None = False, default_bounds: List[float] | None = None) FittingCallable[source]¶
Decorator to mark fittable parameters.
A decorator used in conjunction with
Fittableto inform which parameters can be fit and its properties. On its own it acts like thepropertydecorator. When used within aFittableclass it serves to tag a property as able to fit and allows the class to compile all parameters that can be fit.Its usage is simple, simply wrap a method and define its properties:
class Foo(Fittable): @fitparam(param_name='foobar',param_latex='$Foo^{bar}$') def bar(self): return 'Foobar' @bar.setter def bar(self,value): self.value = value
- Parameters:
f (function) – Function being passed. Automatically done when used as a decorator
param_name (str) – Nicer name of the parameter. Referenced by the optimizer.
param_latex (str) – Latex version of the parameter name, useful in plotting and making figures
default_mode (
linearorlog) – Defines how the optimizer should read and write the parameter.linearreads/write everything as is.loginforms the optimizer to transform from native->log space when read and to transfrom log->native when writing. This also applies to the boundariesdefault_fit (bool) – Whether this is included in the fit without the user explicity saying so (Default: False)
default_bounds (
list) – Default minimum and maximum fitting boundary. Must always be defined in linear space
- Raises:
ValueError – If no parameter name is given
Bibliography¶
Handles citation information for Taurex.
- class Citable[source]¶
Bases:
objectDefines a class that contains citation information.
- BIBTEX_ENTRIES = []¶
List of bibtex entries.
- nice_citation(prefix: str | None = '', start_idx: int | None = 0, indent: int | None = 0) str[source]¶
Returns a nice printable string of citations.
- Parameters:
prefix (str, optional) – Prefix to add to each citation
start_idx (int, optional) – Starting index of citation
indent (int, optional) – Indentation of citation
- construct_nice_printable_string(entry: str, indent: int = 0) str[source]¶
Constructs a nice printable string for each entry.
- doi_to_bibtex(doi: str) str | None[source]¶
Converts a doi to bibtex.
- Parameters:
doi (str) – DOI to convert
Priors (taurex.core.priors)¶
Handles how priors are defined for retrievals.
- class Gaussian(mean: float | None = 0.5, std: float | None = 0.25)[source]¶
Bases:
PriorDefines a gaussian prior.
- class LogGaussian(mean: float | None = 0.5, std: float | None = 0.25, lin_mean: float | None = None, lin_std: float | None = None)[source]¶
Bases:
GaussianDefines a log-gaussian prior.
- class LogUniform(bounds: Tuple[float, float] | None = (0.0, 1.0), lin_bounds=None)[source]¶
Bases:
UniformDefines a log-uniform prior.
- class Prior[source]¶
Bases:
LoggableDefines a prior function
- boundaries() Tuple[float, float][source]¶
Return the (rough) boundaries of the prior.
- Raises:
NotImplementedError – [description]
- class Uniform(bounds: Tuple[float, float] | None = (0.0, 1.0))[source]¶
Bases:
PriorDefines a uniform prior.
- params()[source]¶
Return the parameters of the prior in string form.
- Returns:
String representation of the prior.
- Return type:
str