Parametric fit features
light_curve.BazinFit
Bases: light_curve.light_curve_ext._FeatureEvaluator
Bazin function fit
Five fit parameters and goodness of fit (reduced \(\chi^2\)) of the Bazin function developed for core-collapsed supernovae:
Note, that the Bazin function is developed to be used with fluxes, not magnitudes. Also note a typo in the Eq. (1) of the original paper, the minus sign is missed in the "rise" exponent.
- Depends on: time, magnitude, magnitude error
- Minimum number of observations: 6
- Number of features: 6
Bazin et al. 2009 DOI:10.1051/0004-6361/200911847
Names and description of the output features: - bazin_fit_amplitude: half amplitude of the Bazin function (A) - bazin_fit_baseline: baseline of the Bazin function (B) - bazin_fit_reference_time: reference time of the Bazin fit (t0) - bazin_fit_rise_time: rise time of the Bazin function (tau_rise) - bazin_fit_fall_time: fall time of the Bazin function (tau_fall) - bazin_fit_reduced_chi2: Bazin fit quality (reduced chi2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
str
|
Non-linear least-square algorithm, supported values are: mcmc, ceres, mcmc-ceres, lmsder, mcmc-lmsder, nuts, nuts-ceres, nuts-lmsder. |
required |
mcmc_niter
|
int
|
Number of MCMC iterations, default is 128 |
required |
ceres_niter
|
int
|
Number of Ceres iterations, default is 10 |
required |
ceres_loss_reg
|
float
|
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to descriminate outlier residuals larger than this value. Default is None which means no regularization. |
required |
lmsder_niter
|
int
|
Number of LMSDER iterations, default is 10 |
required |
init
|
list or None
|
Initial conditions, must be |
required |
bounds
|
list of tuples or None
|
Boundary conditions, must be |
required |
ln_prior
|
str or list of ln_prior.LnPrior1D or None
|
Prior for MCMC, None means no prior. It is specified by a string literal
or a list of 5 |
required |
transform
|
bool or None
|
If |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
names |
list of str
|
Feature names |
descriptions |
list of str
|
Feature descriptions |
supported_algorithms |
list of str
|
Available argument values for the constructor |
Methods:
| Name | Description |
|---|---|
__call__ |
Extract features and return them as a numpy array Parameterst : numpy.ndarray of np.float32 or np.float64 dtype
Time moments
m : numpy.ndarray
Signal in magnitude or fluxes. Refer to the feature description to
decide which would work better in your case
sigma : numpy.ndarray, optional
Observation error, if None it is assumed to be unity
fill_value : float or None, optional
Value to fill invalid feature values, for example if count of
observations is not enough to find a proper value.
None causes exception for invalid features
sorted : bool or None, optional
Specifies if input array are sorted by time moments.
True is for certainly sorted, False is for unsorted.
If None is specified than sorting is checked and an exception is
raised for unsorted ndarray of np.float32 or np.float64 Extracted feature array |
many |
Parallel light curve feature extraction It is a parallel executed equivalent of
Parameterslcs : list of (t, m, sigma) or Arrow array
Either a list of light curves packed into three-tuples (all numpy.ndarray
of the same dtype), or an Arrow array/chunked array of type
List<Struct<...>> where the selected fields share the same float dtype
(float32 or float64). Arrow input is auto-detected via the
arrow_c_array / arrow_c_stream protocol and enables zero-copy
data access from pyarrow, polars, and other Arrow-compatible libraries.
arrow_fields : list of (str or int)
Required when lcs is an Arrow array. Field names or indices specifying
which struct fields to use as t, m, and optionally sigma. Must contain
2 elements [t, m] or 3 elements [t, m, sigma]. Each element may be a
field name (str) or a zero-based positional index (int); all elements
must be of the same type. Ignored for non-Arrow input.
fill_value : float or None, optional
Fill invalid values by this or raise an exception if None
sorted : bool or None, optional
Specifies if input array are sorted by time moments, see call
documentation for details
check : bool, optional
Check all input arrays for NaNs, |
model |
Underlying parametric model function Parameterst : np.ndarray of np.float32 or np.float64 Time moments, can be unsorted params : np.ndaarray of np.float32 or np.float64 Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. cast : bool, optional Cast inputs to np.ndarray of the same dtype Returnsnp.ndarray of np.float32 or np.float64 Array of model values corresponded to the given time moments |
Examples:
>>> import numpy as np
>>> from light_curve import BazinFit
>>>
>>> fit = BazinFit('mcmc')
>>> t = np.linspace(0, 10, 101)
>>> flux = 1 + (t - 3) ** 2
>>> fluxerr = np.sqrt(flux)
>>> result = fit(t, flux, fluxerr, sorted=True)
>>> # Result is built from a model parameters and reduced chi^2
>>> # So we can use as a `params` array of the static `.model()` method
>>> model = BazinFit.model(t, result)
supported_algorithms = ['mcmc', 'ceres', 'mcmc-ceres', 'lmsder', 'mcmc-lmsder', 'nuts', 'nuts-ceres', 'nuts-lmsder']
class-attribute
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
model
staticmethod
model(t, params, *, cast=False) Underlying parametric model function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
np.ndarray of np.float32 or np.float64
|
Time moments, can be unsorted |
required |
params
|
np.ndaarray of np.float32 or np.float64
|
Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. |
required |
cast
|
bool
|
Cast inputs to np.ndarray of the same dtype |
False
|
Returns:
| Type | Description |
|---|---|
np.ndarray of np.float32 or np.float64
|
Array of model values corresponded to the given time moments |
light_curve.LinexpFit
Bases: light_curve.light_curve_ext._FeatureEvaluator
Linexp function fit
Four fit parameters and goodness of fit (reduced \(\chi^2\)) of the Linexp function developed for core-collapsed supernovae:
Note, that the Linexp function is developed to be used with fluxes, not magnitudes.
- Depends on: time, flux, flux error
- Minimum number of observations: 5
- Number of features: 5
Names and description of the output features: - linexp_fit_amplitude: Amplitude of the Linexp function (A) - linexp_fit_reference_time: reference time of the Linexp fit (t0) - linexp_fit_fall_time: fall time of the Linexp function (tau) - linexp_fit_baseline: baseline of the Linexp function (B) - linexp_fit_reduced_chi2: Linexp fit quality (reduced chi2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
str
|
Non-linear least-square algorithm, supported values are: mcmc, ceres, mcmc-ceres, lmsder, mcmc-lmsder, nuts, nuts-ceres, nuts-lmsder. |
required |
mcmc_niter
|
int
|
Number of MCMC iterations, default is 128 |
required |
ceres_niter
|
int
|
Number of Ceres iterations, default is 10 |
required |
ceres_loss_reg
|
float
|
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to descriminate outlier residuals larger than this value. Default is None which means no regularization. |
required |
lmsder_niter
|
int
|
Number of LMSDER iterations, default is 10 |
required |
init
|
list or None
|
Initial conditions, must be |
required |
bounds
|
list of tuples or None
|
Boundary conditions, must be |
required |
ln_prior
|
str or list of ln_prior.LnPrior1D or None
|
Prior for MCMC, None means no prior. It is specified by a string literal
or a list of 4 |
required |
transform
|
bool or None
|
If |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
names |
list of str
|
Feature names |
descriptions |
list of str
|
Feature descriptions |
supported_algorithms |
list of str
|
Available argument values for the constructor |
Methods:
| Name | Description |
|---|---|
__call__ |
Extract features and return them as a numpy array Parameterst : numpy.ndarray of np.float32 or np.float64 dtype
Time moments
m : numpy.ndarray
Signal in magnitude or fluxes. Refer to the feature description to
decide which would work better in your case
sigma : numpy.ndarray, optional
Observation error, if None it is assumed to be unity
fill_value : float or None, optional
Value to fill invalid feature values, for example if count of
observations is not enough to find a proper value.
None causes exception for invalid features
sorted : bool or None, optional
Specifies if input array are sorted by time moments.
True is for certainly sorted, False is for unsorted.
If None is specified than sorting is checked and an exception is
raised for unsorted ndarray of np.float32 or np.float64 Extracted feature array |
many |
Parallel light curve feature extraction It is a parallel executed equivalent of
Parameterslcs : list of (t, m, sigma) or Arrow array
Either a list of light curves packed into three-tuples (all numpy.ndarray
of the same dtype), or an Arrow array/chunked array of type
List<Struct<...>> where the selected fields share the same float dtype
(float32 or float64). Arrow input is auto-detected via the
arrow_c_array / arrow_c_stream protocol and enables zero-copy
data access from pyarrow, polars, and other Arrow-compatible libraries.
arrow_fields : list of (str or int)
Required when lcs is an Arrow array. Field names or indices specifying
which struct fields to use as t, m, and optionally sigma. Must contain
2 elements [t, m] or 3 elements [t, m, sigma]. Each element may be a
field name (str) or a zero-based positional index (int); all elements
must be of the same type. Ignored for non-Arrow input.
fill_value : float or None, optional
Fill invalid values by this or raise an exception if None
sorted : bool or None, optional
Specifies if input array are sorted by time moments, see call
documentation for details
check : bool, optional
Check all input arrays for NaNs, |
model |
Underlying parametric model function Parameterst : np.ndarray of np.float32 or np.float64 Time moments, can be unsorted params : np.ndaarray of np.float32 or np.float64 Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. cast : bool, optional Cast inputs to np.ndarray of the same dtype Returnsnp.ndarray of np.float32 or np.float64 Array of model values corresponded to the given time moments |
Examples:
>>> import numpy as np
>>> from light_curve import LinexpFit
>>>
>>> fit = LinexpFit('mcmc')
>>> t = np.linspace(0, 10, 101)
>>> flux = 1 + (t - 3) ** 2
>>> fluxerr = np.sqrt(flux)
>>> result = fit(t, flux, fluxerr, sorted=True)
>>> # Result is built from a model parameters and reduced chi^2
>>> # So we can use as a `params` array of the static `.model()` method
>>> model = LinexpFit.model(t, result)
supported_algorithms = ['mcmc', 'ceres', 'mcmc-ceres', 'lmsder', 'mcmc-lmsder', 'nuts', 'nuts-ceres', 'nuts-lmsder']
class-attribute
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
model
staticmethod
model(t, params, *, cast=False) Underlying parametric model function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
np.ndarray of np.float32 or np.float64
|
Time moments, can be unsorted |
required |
params
|
np.ndaarray of np.float32 or np.float64
|
Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. |
required |
cast
|
bool
|
Cast inputs to np.ndarray of the same dtype |
False
|
Returns:
| Type | Description |
|---|---|
np.ndarray of np.float32 or np.float64
|
Array of model values corresponded to the given time moments |
light_curve.VillarFit
Bases: light_curve.light_curve_ext._FeatureEvaluator
Villar function fit
Seven fit parameters and goodness of fit (reduced \(\chi^2\)) of the Villar function developed for supernovae classification:
$$ f(t) = c + \frac{A}{ 1 + \exp{\frac{-(t - t_0)}{\tau_\mathrm{rise}}}} \left{ \begin{array}{ll} 1 - \frac{\nu (t - t_0)}{\gamma}, &t < t_0 + \gamma \ (1 - \nu) \exp{\frac{-(t-t_0-\gamma)}{\tau_\mathrm{fall}}}, &t \geq t_0 + \gamma \end{array} \right. $$ where \(A, \gamma, \tau_\mathrm{rise}, \tau_\mathrm{fall} > 0\), \(\nu \in [0; 1)\).
Here we introduce a new dimensionless parameter \(\nu\) instead of the plateau slope \(\beta\) from the orioginal paper: \(\nu \equiv -\beta \gamma / A\).
Note, that the Villar function is developed to be used with fluxes, not magnitudes.
- Depends on: time, magnitude, magnitude error
- Minimum number of observations: 8
- Number of features: 8
Villar et al. 2019 DOI:10.3847/1538-4357/ab418c
Names and description of the output features: - villar_fit_amplitude: half amplitude of the Villar function (A) - villar_fit_baseline: baseline of the Villar function (c) - villar_fit_reference_time: reference time of the Villar function (t_0) - villar_fit_rise_time: rise time of the Villar function (tau_rise) - villar_fit_fall_time: decline time of the Villar function (tau_fall) - villar_fit_plateau_rel_amplitude: relative plateau amplitude of the Villar function (nu = beta gamma / A) - villar_fit_plateau_duration: plateau duration of the Villar function (gamma) - villar_fit_reduced_chi2: Villar fit quality (reduced chi2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
str
|
Non-linear least-square algorithm, supported values are: mcmc, ceres, mcmc-ceres, lmsder, mcmc-lmsder, nuts, nuts-ceres, nuts-lmsder. |
required |
mcmc_niter
|
int
|
Number of MCMC iterations, default is 128 |
required |
ceres_niter
|
int
|
Number of Ceres iterations, default is 10 |
required |
ceres_loss_reg
|
float
|
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to descriminate outlier residuals larger than this value. Default is None which means no regularization. |
required |
lmsder_niter
|
int
|
Number of LMSDER iterations, default is 10 |
required |
init
|
list or None
|
Initial conditions, must be |
required |
bounds
|
list of tuples or None
|
Boundary conditions, must be |
required |
ln_prior
|
str or list of ln_prior.LnPrior1D or None
|
Prior for MCMC, None means no prior. It is specified by a string literal
or a list of 7 |
required |
transform
|
bool or None
|
If |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
names |
list of str
|
Feature names |
descriptions |
list of str
|
Feature descriptions |
supported_algorithms |
list of str
|
Available argument values for the constructor |
Methods:
| Name | Description |
|---|---|
__call__ |
Extract features and return them as a numpy array Parameterst : numpy.ndarray of np.float32 or np.float64 dtype
Time moments
m : numpy.ndarray
Signal in magnitude or fluxes. Refer to the feature description to
decide which would work better in your case
sigma : numpy.ndarray, optional
Observation error, if None it is assumed to be unity
fill_value : float or None, optional
Value to fill invalid feature values, for example if count of
observations is not enough to find a proper value.
None causes exception for invalid features
sorted : bool or None, optional
Specifies if input array are sorted by time moments.
True is for certainly sorted, False is for unsorted.
If None is specified than sorting is checked and an exception is
raised for unsorted ndarray of np.float32 or np.float64 Extracted feature array |
many |
Parallel light curve feature extraction It is a parallel executed equivalent of
Parameterslcs : list of (t, m, sigma) or Arrow array
Either a list of light curves packed into three-tuples (all numpy.ndarray
of the same dtype), or an Arrow array/chunked array of type
List<Struct<...>> where the selected fields share the same float dtype
(float32 or float64). Arrow input is auto-detected via the
arrow_c_array / arrow_c_stream protocol and enables zero-copy
data access from pyarrow, polars, and other Arrow-compatible libraries.
arrow_fields : list of (str or int)
Required when lcs is an Arrow array. Field names or indices specifying
which struct fields to use as t, m, and optionally sigma. Must contain
2 elements [t, m] or 3 elements [t, m, sigma]. Each element may be a
field name (str) or a zero-based positional index (int); all elements
must be of the same type. Ignored for non-Arrow input.
fill_value : float or None, optional
Fill invalid values by this or raise an exception if None
sorted : bool or None, optional
Specifies if input array are sorted by time moments, see call
documentation for details
check : bool, optional
Check all input arrays for NaNs, |
model |
Underlying parametric model function Parameterst : np.ndarray of np.float32 or np.float64 Time moments, can be unsorted params : np.ndaarray of np.float32 or np.float64 Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. cast : bool, optional Cast inputs to np.ndarray of the same dtype Returnsnp.ndarray of np.float32 or np.float64 Array of model values corresponded to the given time moments |
Examples:
>>> import numpy as np
>>> from light_curve import VillarFit
>>>
>>> fit = VillarFit('mcmc')
>>> t = np.linspace(0, 10, 101)
>>> flux = 1 + (t - 3) ** 2
>>> fluxerr = np.sqrt(flux)
>>> result = fit(t, flux, fluxerr, sorted=True)
>>> # Result is built from a model parameters and reduced chi^2
>>> # So we can use as a `params` array of the static `.model()` method
>>> model = VillarFit.model(t, result)
supported_algorithms = ['mcmc', 'ceres', 'mcmc-ceres', 'lmsder', 'mcmc-lmsder', 'nuts', 'nuts-ceres', 'nuts-lmsder']
class-attribute
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
model
staticmethod
model(t, params, *, cast=False) Underlying parametric model function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
np.ndarray of np.float32 or np.float64
|
Time moments, can be unsorted |
required |
params
|
np.ndaarray of np.float32 or np.float64
|
Parameters of the model, this array can be longer than actual parameter list, the beginning part of the array will be used in this case, see Examples section in the class documentation. |
required |
cast
|
bool
|
Cast inputs to np.ndarray of the same dtype |
False
|
Returns:
| Type | Description |
|---|---|
np.ndarray of np.float32 or np.float64
|
Array of model values corresponded to the given time moments |