lcfit.sncutils#
This module provides utilities for executing single lightcurve fits and converting sncosmo results into structured pandas DataFrames or Series.
- skysurvey.lcfit.sncutils.sncosmo_results_to_dataframe(result, flatten=True)[source]#
Convert a sncosmo fit result into a pandas DataFrame or flattened Series.
- Parameters:
result (result object returned by
sncosmo.fit_lc().) –dict subclass with attribute access. It must provide:
result.param_names
result.vparam_names
result.parameters
result[“errors”]
result[“covariance”]
flatten (bool, default is True.) – If False, return a DataFrame. If True, return a flattened pandas.Series.
- Return type:
pandas.DataFrame or pandas.Series
- skysurvey.lcfit.sncutils.sncosmo_fit_single(target_data, target_model, free_param, modelcov=True, keymap={}, **kwargs)[source]#
Fit a sncosmo model to a single lightcurve dataset and return the fit results as a pandas.Series.
- Parameters:
target_data (pandas.DataFrame) – dataframe containing the lightcurve data. It must contain [“time”, “band”, “flux”, “fluxerr”,”zp”, “zpsys”] (but see keymap).
target_model (sncosmo.Model) – The model to fit.
free_param (list) – model parameters to vary in the fit. (all if None)
modelcov (bool) – Include model covariance when calculating chisq. If true, the fit is performed multiple times until convergence.
keymap (dict) – Change the key naming convention. For instance to use fluxerr_tot for fluxerr use: keymap = {“fluxerr”: “fluxerr_tot”}
sncosmo.fit_lc() (kwargs goes to)
- Return type:
pandas.Series