Core (taurex.core
)¶
Retrieval¶
This module relates to defining fitting parameters in TauREx3
-
class
Fittable
[source]¶ Bases:
object
A 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_fittable_param
(param_name, param_latex, fget, fset, default_mode, default_fit, default_bounds)[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 (
linear
orlog
) – Defines how the optimizer should read and write the parameter.linear
reads/write everything as is.log
informs 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
()[source]¶ Loops through and finds all fitting parameters in the class and adds it to the internal dictionary
-
find_derivedparams
()[source]¶ Finds and returns fitting parameters
- Yields
method (function) – class method that is defined with the
fitparam()
decorator
-
find_fitparams
()[source]¶ Finds and returns fitting parameters
- Yields
method (function) – class method that is defined with the
fitparam()
decorator
-
fitting_parameters
()[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, new_bounds)[source]¶ Modifies the fitting boundary of a parameter
- Parameters
parameter (str) – Name of parameter (given by
param_name
infitparam()
)new_bounds (
list
) – New minimum and maximum fitting boundaries.
-
-
derivedparam
(f=None, param_name=None, param_latex=None, compute=False)[source]¶ A decorator used in conjunction with
Fittable
to 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=None, param_name=None, param_latex=None, default_mode='linear', default_fit=False, default_bounds=[0.0, 1.0])[source]¶ A decorator used in conjunction with
Fittable
to inform which parameters can be fit and its properties. On its own it acts like theproperty
decorator. When used within aFittable
class 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 (
linear
orlog
) – Defines how the optimizer should read and write the parameter.linear
reads/write everything as is.log
informs 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
Priors (taurex.core.priors
)¶
-
class
Gaussian
(mean=0.5, std=0.25)[source]¶ Bases:
taurex.core.priors.Prior
-
class
LogGaussian
(mean=0.5, std=0.25, lin_mean=None, lin_std=None)[source]¶ Bases:
taurex.core.priors.Gaussian
-
class
LogUniform
(bounds=[0.0, 1.0], lin_bounds=None)[source]¶ Bases:
taurex.core.priors.Uniform
-
class
Prior
[source]¶ Bases:
taurex.log.logger.Logger
Defines a prior function
-
property
priorMode
¶
-
property