phot_class.fit_func_wraps¶
The fit_funcs
module provides wrappers that combine the the various
minimization routines from sncosmo
. Importantly, the fitting functions
in this module guarantee that arguments will not be mutated, which is not
true for sncosmo
in general (at least for sncosmo 2.0.0 and earlier).
Usage Example¶
>>> import sncosmo
>>> from matplotlib import pyplot as plt
>>>
>>> from phot_class import fit_func_wraps
>>>
>>> model = sncosmo.Model('salt2')
>>> data = sncosmo.load_example_data()
>>>
>>> # Here you can use the functions simple_fit, nest_fit, or mcmc_fit
>>> result, fitted_model = fit_func_wraps.simple_fit(
>>> data, model,
>>> ['z', 't0', 'x0', 'x1', 'c'], # parameters of model to vary
>>> bounds={'z':(0.3, 0.7)}) # bounds on parameters (if any)
>>>
>>> # Plot results
>>> fig = sncosmo.plot_lc(data, model=fitted_model, errors=result.errors)
>>> plt.show()
Function Documentation¶
-
phot_class.fit_func_wraps.
mcmc_fit
(data, model, vparam_names, **kwargs)[source]¶ Fit light curves Monte Carlo sampling
Parameters: - data (Table) – Table of photometric data
- model (Model) – The model to fit
- vparam_names (iterable) – Model parameters to vary
- other parameters for sncosmo.mcmc_lc (Any) –
Returns: - A dictionary like object with fit results
- A fitted
Model
instance
-
phot_class.fit_func_wraps.
nest_fit
(data, model, vparam_names, **kwargs)[source]¶ Fit light curves using nested sampling
Parameters: - data (Table) – Table of photometric data
- model (Model) – The model to fit
- vparam_names (iterable) – Model parameters to vary
- other parameters for sncosmo.nest_lc (Any) –
Returns: - A dictionary like object with fit results
- A fitted
Model
instance
-
phot_class.fit_func_wraps.
simple_fit
(data, model, vparam_names, **kwargs)[source]¶ Fit light curves using the basic
fit_lc
functionality insncosmo
Parameters: - data (Table) – Table of photometric data
- model (Model) – The model to fit
- vparam_names (iterable) – Model parameters to vary
- other parameters for sncosmo.fit_lc (Any) –
Returns: - A dictionary like object with fit results
- A fitted
Model
instance