lcfit.fit_salt

lcfit.fit_salt#

This module provides utilities for fitting SALT models to lightcurves.

skysurvey.lcfit.fit_salt.fit_salt(dataset, free_param=['t0', 'x0', 'x1', 'c'], modelcov=True, keymap={}, indexes=None, phase_range=[-10, 40], progress_bar=False, client=None, as_future=False, **kwargs)[source]#

Fit a salt model on a given dataset.

Parameters:
  • dataset (skysurvey.dataset.Dataset) – Dataset containing targets and their lightcurves.

  • free_param (list) – Model parameters to vary in the fit. Default is [‘t0’, ‘x0’, ‘x1’, ‘c’].

  • modelcov (bool) – Include model covariance when calculating chisq. If True, the fit is performed multiple times until convergence. Default is True.

  • keymap (dict) – Change the key naming convention for lightcurve columns.

  • indexes (iterable or None) – Subset of target indices to fit. If None, uses dataset.obs_index. Default is None.

  • phase_range (list, None, optional) – Rest-frame phase range to be used for simulating the lightcurves. If None, no cut is applied on time range for the logs. Default is [-10, +40].

  • progress_bar (bool) – If True, display a progress bar over the target indices. Default is False.

  • client (dask.distributed.Client or None) – If provided, submit fits to the Dask client for parallel execution. Default is None.

  • as_future (bool) – If True and a Dask client is provided, return a dictionary of futures instead of waiting for completion. Default is False.

  • **kwargs – Additional keyword arguments passed to fit_salt_single.

Returns:

If client is None or as_future is False, returns a DataFrame of flattened salt fit results. If client is provided and as_future is True, returns a dict.

Return type:

pandas.DataFrame or dict

skysurvey.lcfit.fit_salt.fit_salt_single(dataset, index, free_param=['t0', 'x0', 'x1', 'c'], client=None, phase_range=[-10, 40], modelcov=True, keymap={}, bounds={'c': 0.2, 't0': 3, 'x1': 0.4}, in_scatter={'c': 0.05, 't0': 0.5, 'x1': 0.1}, warn=True, **kwargs)[source]#

This is a wrapper of sncosmo_fit_single() that get data and model for a skysurvey.dataset.Dataset target.

Parameters:
  • dataset (skysurvey.dataset.Dataset) – Dataset containing the target and its lightcurves.

  • index (hashable) – Target index identifying which lightcurve to fit.

  • free_param (list) – Model parameters to vary in the fit. Default is [‘t0’, ‘x0’, ‘x1’, ‘c’].

  • client (dask.distributed.Client or None) – If provided, submit the fit to the Dask client. Default is None.

  • phase_range (list, None, optional) – Rest-frame phase range to be used for simulating the lightcurves. If None, no cut is applied on time range for the logs. Default is [-10, +40].

  • modelcov (bool) – Include model covariance when calculating chisq. If True, the fit is performed multiple times until convergence. Default is True.

  • keymap (dict) – Change the key naming convention for lightcurve columns.

  • bounds (dict) – Half-width bounds around the initial parameter values. Default is {“t0”: 3, “x1”: 0.4, “c”: 0.2}.

  • in_scatter (dict) – Gaussian scatter added to initial parameter guesses. Default is {“t0”: .5, “x1”: 0.1, “c”: 0.05}.

  • warn (bool) – If True, emit warnings when rejecting a target. Default is True.

  • **kwargs – Additional keyword arguments passed to sncutils.sncosmo_fit_single.

Returns:

Flattened salt fit results for the target, a Dask future if client is provided, or None if the target is rejected.

Return type:

pandas.Series or dask.distributed.Future or None