LightCurveEstimator#

class gammapy.estimators.LightCurveEstimator(time_intervals=None, atol='1e-6 s', **kwargs)[source]#

Bases: gammapy.estimators.points.sed.FluxPointsEstimator

Estimate light curve.

The estimator will apply flux point estimation on the source model component to datasets in each of the provided time intervals. The normalisation, norm, is the only parameter of the source model left free to vary. Other model components can be left free to vary with the reoptimize option.

If no time intervals are provided, the estimator will use the time intervals defined by the datasets GTIs.

To be included in the estimation, the dataset must have their GTI fully overlapping a time interval.

Time intervals without any dataset GTI fully overlapping will be dropped. They will not be stored in the final lightcurve FluxPoints object.

Parameters
time_intervalslist of astropy.time.Time

Start and stop time for each interval to compute the LC.

sourcestr or int

For which source in the model to compute the flux points. Default is 0.

atolQuantity

Tolerance value for time comparison with different scale. Default 1e-6 sec.

norm_minfloat

Minimum value for the norm used for the fit statistic profile evaluation.

norm_maxfloat

Maximum value for the norm used for the fit statistic profile evaluation.

norm_n_valuesint

Number of norm values used for the fit statistic profile.

norm_valuesnumpy.ndarray

Array of norm values to be used for the fit statistic profile.

n_sigmaint

Number of sigma to use for asymmetric error computation. Default is 1.

n_sigma_ulint

Number of sigma to use for upper limit computation. Default is 2.

selection_optionallist of str, optional

Which steps to execute. Available options are:

  • “all”: all the optional steps are executed.

  • “errn-errp”: estimate asymmetric errors.

  • “ul”: estimate upper limits.

  • “scan”: estimate fit statistic profiles.

Default is None so the optional steps are not executed.

energy_edgeslist of Quantity, optional

Edges of the lightcurve energy bins. The resulting bin edges won’t be exactly equal to the input ones, but rather the closest values to the energy axis edges of the parent dataset. Default is None: apply the estimator in each energy bin of the parent dataset. For further explanation see Estimators (DL4 to DL5, and DL6).

fitFit

Fit instance specifying the backend and fit options.

reoptimizebool

If True the free parameters of the other models are fitted in each bin independently, together with the norm of the source of interest (but the other parameters of the source of interest are kept frozen). If False only the norm of the source of interest if fitted, and all other parameters are frozen at their current values.

n_jobsint

Number of processes used in parallel for the computation. Default is one, unless N_JOBS_DEFAULT was modified. The number of jobs is limited to the number of physical CPUs.

parallel_backend{“multiprocessing”, “ray”}

Which backend to use for multiprocessing. Defaults to BACKEND_DEFAULT.

norm~gammapy.modeling.Parameter` or dict

Norm parameter used for the fit Default is None and a new parameter is created automatically, with value=1, name=”norm”, scan_min=0.2, scan_max=5, and scan_n_values = 11. By default the min and max are not set and derived from the source model, unless the source model does not have one and only one norm parameter. If a dict is given the entries should be a subset of Parameter arguments.

Examples

For a usage example see Light curves tutorial.

Attributes Summary

config_parameters

Configuration parameters.

n_jobs

Number of jobs as an integer.

norm_max

Deprecated since version 1.2.

norm_min

Deprecated since version 1.2.

norm_n_values

Deprecated since version 1.2.

norm_values

Deprecated since version 1.2.

parallel_backend

Parallel backend as a string.

selection_optional

tag

Methods Summary

copy()

Copy estimator.

estimate_best_fit(datasets, parameter)

Estimate parameter asymmetric errors.

estimate_counts(datasets)

Estimate counts for the flux point.

estimate_errn_errp(datasets, parameter)

Estimate parameter asymmetric errors.

estimate_flux_point(datasets, energy_min, ...)

Estimate flux point for a single energy group.

estimate_npred(datasets)

Estimate npred for the flux point.

estimate_npred_excess(datasets)

Estimate npred excess for the source.

estimate_scan(datasets, parameter)

Estimate parameter statistic scan.

estimate_time_bin_flux(datasets[, dataset_names])

Estimate flux point for a single energy group.

estimate_ts(datasets, parameter)

Estimate parameter ts.

estimate_ul(datasets, parameter)

Estimate parameter ul.

expand_map(m, dataset_names)

Expand map in dataset axis.

get_scale_model(models)

Set scale model.

run(datasets)

Run light curve extraction.

Attributes Documentation

config_parameters#

Configuration parameters.

n_jobs#

Number of jobs as an integer.

norm_max#

Deprecated since version 1.2: The norm_max attribute is deprecated and may be removed in a future version.

norm_min#

Deprecated since version 1.2: The norm_min attribute is deprecated and may be removed in a future version.

norm_n_values#

Deprecated since version 1.2: The norm_n_values attribute is deprecated and may be removed in a future version.

norm_values#

Deprecated since version 1.2: The norm_values attribute is deprecated and may be removed in a future version.

parallel_backend#

Parallel backend as a string.

selection_optional#
tag = 'LightCurveEstimator'#

Methods Documentation

copy()#

Copy estimator.

estimate_best_fit(datasets, parameter)#

Estimate parameter asymmetric errors.

Parameters
datasetsDatasets

Datasets.

parameterParameter

For which parameter to get the value.

Returns
resultdict

Dictionary with the various parameter estimation values. Entries are:

  • parameter.name: best fit parameter value.

  • “stat”: best fit total stat.

  • “success”: boolean flag for fit success.

  • parameter.name_err: covariance-based error estimate on parameter value.

static estimate_counts(datasets)#

Estimate counts for the flux point.

Parameters
datasetsDatasets

Datasets.

Returns
resultdict

Dictionary with an array with one entry per dataset with the sum of the masked counts.

estimate_errn_errp(datasets, parameter)#

Estimate parameter asymmetric errors.

Parameters
datasetsDatasets

Datasets.

parameterParameter

For which parameter to get the value.

Returns
resultdict

Dictionary with the parameter asymmetric errors. Entries are:

  • {parameter.name}_errp : positive error on parameter value.

  • {parameter.name}_errn : negative error on parameter value.

estimate_flux_point(datasets, energy_min, energy_max)#

Estimate flux point for a single energy group.

Parameters
datasetsDatasets

Datasets.

energy_min, energy_maxQuantity

Energy bounds to compute the flux point for.

Returns
resultdict

Dictionary with results for the flux point.

static estimate_npred(datasets)#

Estimate npred for the flux point.

Parameters
datasetsDatasets

Datasets.

Returns
resultdict

Dictionary with an array with one entry per dataset with the sum of the masked npred.

estimate_npred_excess(datasets)#

Estimate npred excess for the source.

Parameters
datasetsDatasets

Datasets.

Returns
resultdict

Dictionary with an array with one entry per dataset with the sum of the masked npred excess.

estimate_scan(datasets, parameter)#

Estimate parameter statistic scan.

Parameters
datasetsDatasets

The datasets used to estimate the model parameter.

parameterParameter

For which parameter to get the value.

Returns
resultdict

Dictionary with the parameter fit scan values. Entries are:

  • parameter.name_scan : parameter values scan.

  • “stat_scan” : fit statistic values scan.

estimate_time_bin_flux(datasets, dataset_names=None)[source]#

Estimate flux point for a single energy group.

Parameters
datasetsDatasets

List of dataset objects.

Returns
resultFluxPoints

Resulting flux points.

estimate_ts(datasets, parameter)#

Estimate parameter ts.

Parameters
datasetsDatasets

Datasets.

parameterParameter

For which parameter to get the value.

Returns
resultdict

Dictionary with the test statistic of the best fit value compared to the null hypothesis. Entries are:

  • “ts” : fit statistic difference with null hypothesis.

  • “npred” : predicted number of counts per dataset.

  • “stat_null” : total stat corresponding to the null hypothesis

estimate_ul(datasets, parameter)#

Estimate parameter ul.

Parameters
datasetsDatasets

The datasets used to estimate the model parameter.

parameterParameter

For which parameter to get the value.

Returns
resultdict

Dictionary with the parameter upper limits. Entries are:

  • parameter.name_ul : upper limit on parameter value.

static expand_map(m, dataset_names)[source]#

Expand map in dataset axis.

Parameters
mapMap

Map to expand.

dataset_nameslist of str

Dataset names.

Returns
mapMap

Expanded map.

get_scale_model(models)#

Set scale model.

Parameters
modelsModels

Models.

Returns
modelScaleSpectralModel

Scale spectral model.

run(datasets)[source]#

Run light curve extraction.

Normalize integral and energy flux between emin and emax.

Parameters
datasetslist of SpectrumDataset or MapDataset

Spectrum or Map datasets.

Returns
lightcurveFluxPoints

Light curve flux points.

Notes

The progress bar can be displayed for this function.