threeML.utils.time_series package

Submodules

threeML.utils.time_series.binned_spectrum_series module

class threeML.utils.time_series.binned_spectrum_series.BinnedSpectrumSeries(binned_spectrum_set, first_channel=1, ra=None, dec=None, mission=None, instrument=None, verbose=True)[source]

Bases: threeML.utils.time_series.time_series.TimeSeries

property binned_spectrum_set

returns the spectrum set :return: binned_spectrum_set

property bins

the time bins of the spectrum set :return: TimeIntervalSet

count_per_channel_over_interval(start, stop)[source]

return the number of counts in the selected interval :param start: start of interval :param stop: stop of interval :return:

counts_over_interval(start, stop)[source]

return the number of counts in the selected interval :param start: start of interval :param stop: stop of interval :return:

exposure_over_interval(start, stop)[source]

calculate the exposure over the given interval

Parameters
  • start – start time

  • stop – stop time

Returns

set_active_time_intervals(*args)[source]

Set the time interval(s) to be used during the analysis. Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_active_time_intervals(“0.0-10.0”)

which will set the time range 0-10. seconds.

view_lightcurve(start: float = - 10, stop: float = 20.0, dt: float = 1.0, use_binner: bool = False) → None[source]
Parameters
  • start

  • stop

  • dt

  • use_binner

threeML.utils.time_series.event_list module

class threeML.utils.time_series.event_list.EventList(arrival_times, measurement, n_channels, start_time=None, stop_time=None, native_quality=None, first_channel=0, ra=None, dec=None, mission=None, instrument=None, verbose=True, edges=None)[source]

Bases: threeML.utils.time_series.time_series.TimeSeries

property arrival_times
bin_by_bayesian_blocks(start, stop, p0, use_background=False)[source]
bin_by_constant(start, stop, dt=1)[source]

Interface to the temporal binner’s constant binning mode

Parameters
  • start – start time of the bins

  • stop – stop time of the bins

  • dt – temporal spacing of the bins

Returns

bin_by_custom(start, stop)[source]

Interface to temporal binner’s custom bin mode

Parameters
  • start – start times of the bins

  • stop – stop times of the bins

Returns

bin_by_significance(start, stop, sigma, mask=None, min_counts=1)[source]

Interface to the temporal binner’s significance binning model

param start

start of the interval to bin on

param stop

stop of the interval ot bin on

param sigma

sigma-level of the bins

param mask

(bool) use the energy mask to decide on ,significance

param min_counts

minimum number of counts per bin

return

property bins
count_per_channel_over_interval(start, stop)[source]
Parameters
  • start

  • stop

Returns

counts_over_interval(start, stop)[source]

return the number of counts in the selected interval :param start: start of interval :param stop: stop of interval :return:

property measurement
property n_events
view_lightcurve(start: float = - 10, stop: float = 20.0, dt: float = 1.0, use_binner: bool = False) → None[source]
Parameters
  • start

  • stop

  • dt

  • use_binner

class threeML.utils.time_series.event_list.EventListWithDeadTime(arrival_times, measurement, n_channels, start_time=None, stop_time=None, dead_time=None, first_channel=0, quality=None, ra=None, dec=None, mission=None, instrument=None, verbose=True, edges=None)[source]

Bases: threeML.utils.time_series.event_list.EventList

exposure_over_interval(start, stop)[source]

calculate the exposure over the given interval

Parameters
  • start – start time

  • stop – stop time

Returns

set_active_time_intervals(*args)[source]

Set the time interval(s) to be used during the analysis.

Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_active_time_intervals(“0.0-10.0”)

which will set the energy range 0-10. seconds.

class threeML.utils.time_series.event_list.EventListWithDeadTimeFraction(arrival_times, measurement, n_channels, start_time=None, stop_time=None, dead_time_fraction=None, first_channel=0, quality=None, ra=None, dec=None, mission=None, instrument=None, verbose=True, edges=None)[source]

Bases: threeML.utils.time_series.event_list.EventList

exposure_over_interval(start, stop)[source]

calculate the exposure over the given interval

Parameters
  • start – start time

  • stop – stop time

Returns

set_active_time_intervals(*args)[source]

Set the time interval(s) to be used during the analysis.

Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_active_time_intervals(“0.0-10.0”)

which will set the energy range 0-10. seconds.

class threeML.utils.time_series.event_list.EventListWithLiveTime(arrival_times, measurement, n_channels, live_time, live_time_starts, live_time_stops, start_time=None, stop_time=None, quality=None, first_channel=0, rsp_file=None, ra=None, dec=None, mission=None, instrument=None, verbose=True, edges=None)[source]

Bases: threeML.utils.time_series.event_list.EventList

exposure_over_interval(start, stop)[source]
Parameters
  • start – start time of interval

  • stop – stop time of interval

Returns

exposure

set_active_time_intervals(*args)[source]

Set the time interval(s) to be used during the analysis.

Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_active_time_intervals(“0.0-10.0”)

which will set the energy range 0-10. seconds.

exception threeML.utils.time_series.event_list.OverLappingIntervals[source]

Bases: RuntimeError

exception threeML.utils.time_series.event_list.ReducingNumberOfSteps[source]

Bases: Warning

exception threeML.utils.time_series.event_list.ReducingNumberOfThreads[source]

Bases: Warning

threeML.utils.time_series.event_list.ceildiv(a, b)[source]

threeML.utils.time_series.polynomial module

exception threeML.utils.time_series.polynomial.CannotComputeCovariance[source]

Bases: RuntimeWarning

class threeML.utils.time_series.polynomial.PolyBinnedLogLikelihood(x, y, model, exposure)[source]

Bases: threeML.utils.time_series.polynomial.PolyLogLikelihood

Implements a Poisson likelihood (i.e., the Cash statistic). Mind that this is not the Castor statistic (Cstat). The difference between the two is a constant given a dataset. I kept Cash instead of Castor to make easier the comparison with ROOT during tests, since ROOT implements the Cash statistic.

class threeML.utils.time_series.polynomial.PolyLogLikelihood(model, exposure)[source]

Bases: object

class threeML.utils.time_series.polynomial.PolyUnbinnedLogLikelihood(events, model, t_start, t_stop, exposure)[source]

Bases: threeML.utils.time_series.polynomial.PolyLogLikelihood

Implements a Poisson likelihood (i.e., the Cash statistic). Mind that this is not the Castor statistic (Cstat). The difference between the two is a constant given a dataset. I kept Cash instead of Castor to make easier the comparison with ROOT during tests, since ROOT implements the Cash statistic.

class threeML.utils.time_series.polynomial.Polynomial(coefficients, is_integral=False)[source]

Bases: object

property coefficients

Gets or sets the coefficients of the polynomial.

compute_covariance_matrix(function, best_fit_parameters)[source]

Compute the covariance matrix of this fit :param function: the loglike for the fit :param best_fit_parameters: the best fit parameters :return:

property covariance_matrix
property degree

the polynomial degree :return:

property error

the error on the polynomial coefficients :return:

classmethod from_previous_fit(coefficients, covariance)[source]
integral(xmin, xmax)[source]

Evaluate the integral of the polynomial between xmin and xmax

integral_error(xmin, xmax)[source]

computes the integral error of an interval :param xmin: start of the interval :param xmax: stop of the interval :return: interval error

threeML.utils.time_series.polynomial.polyfit(x, y, grade, exposure)[source]

function to fit a polynomial to event data. not a member to allow parallel computation

threeML.utils.time_series.polynomial.unbinned_polyfit(events, grade, t_start, t_stop, exposure, initial_amplitude=1)[source]

function to fit a polynomial to event data. not a member to allow parallel computation

threeML.utils.time_series.time_series module

exception threeML.utils.time_series.time_series.OverLappingIntervals[source]

Bases: RuntimeError

exception threeML.utils.time_series.time_series.ReducingNumberOfSteps[source]

Bases: Warning

exception threeML.utils.time_series.time_series.ReducingNumberOfThreads[source]

Bases: Warning

class threeML.utils.time_series.time_series.TimeSeries(start_time, stop_time, n_channels, native_quality=None, first_channel=1, ra=None, dec=None, mission=None, instrument=None, verbose=True, edges=None)[source]

Bases: object

property bins
count_per_channel_over_interval(start, stop)[source]
Parameters
  • start

  • stop

Returns

counts_over_interval(start, stop)[source]

return the number of counts in the selected interval :param start: start of interval :param stop: stop of interval :return:

exposure_over_interval(tmin, tmax)[source]

calculate the exposure over a given interval

get_information_dict(use_poly=False, extract=False)[source]

Return a PHAContainer that can be read by different builders

Parameters

use_poly – (bool) choose to build from the polynomial fits

get_poly_info()[source]

Return a pandas panel frame with the polynomial coeffcients and errors Returns:

a DataFrame

get_total_poly_count(start, stop, mask=None)[source]

Get the total poly counts

Parameters
  • start

  • stop

Returns

get_total_poly_error(start, stop, mask=None)[source]

Get the total poly error

Parameters
  • start

  • stop

Returns

property n_channels
property poly_fit_exists
property poly_intervals
property poly_order

Get or set the polynomial order

property polynomials

Returns polynomial is they exist

restore_fit(filename)[source]
save_background(filename, overwrite=False)[source]

save the background to an HD5F

Parameters

filename

Returns

set_active_time_intervals(*args)[source]
set_polynomial_fit_interval(*time_intervals, **options)[source]

Set the time interval to fit the background. Multiple intervals can be input as separate arguments Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_polynomial_fit_interval(“-10.0-0.0”,”10.-15.”)

Parameters
  • time_intervals – intervals to fit on

  • options

property time_intervals

the time intervals of the events

Returns

view_lightcurve(start=- 10, stop=20.0, dt=1.0, use_binner=False)[source]
threeML.utils.time_series.time_series.ceildiv(a, b)[source]

Module contents