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.Polynomial(coefficients: Iterable[float], is_integral: bool = False)[source]

Bases: object

property coefficients

Gets or sets the coefficients of the polynomial.

property covariance_matrix
property degree

the polynomial degree :return:

property error

the error on the polynomial coefficients :return:

classmethod from_previous_fit(coefficients, covariance)threeML.utils.time_series.polynomial.Polynomial[source]
integral(xmin, xmax) → float[source]

Evaluate the integral of the polynomial between xmin and xmax

integral_error(xmin, xmax) → float[source]

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

set_covariace_matrix(matrix) → None[source]
threeML.utils.time_series.polynomial.polyfit(x: Iterable[float], y: Iterable[float], grade: int, exposure: Iterable[float], bayes: bool = False) → Tuple[threeML.utils.time_series.polynomial.Polynomial, float][source]

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

Parameters
  • x – the x coord of the data

  • y – teh y coord of the data

  • grade – the polynomical order or grade

  • expousure – the exposure of the interval

  • bayes – to do a bayesian fit or not

threeML.utils.time_series.polynomial.unbinned_polyfit(events: Iterable[float], grade: int, t_start: float, t_stop: float, exposure: float, bayes: bool) → Tuple[threeML.utils.time_series.polynomial.Polynomial, float][source]

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

Parameters
  • events – the events to fit

  • grade – the polynomical order or grade

  • t_start – the start time to fit over

  • t_stop – the end time to fit over

  • expousure – the exposure of the interval

  • bayes – to do a bayesian fit or not

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: float, stop_time: float, n_channels: int, native_quality=None, first_channel: int = 1, ra: Optional[float] = None, dec: Optional[float] = None, mission: Optional[str] = None, instrument: Optional[str] = None, verbose: bool = 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) → int[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) → float[source]

calculate the exposure over a given interval

get_information_dict(use_poly: bool = False, extract: bool = False) → dict[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() → dict[source]

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

a DataFrame

get_total_poly_count(start: float, stop: float, mask=None) → int[source]

Get the total poly counts

Parameters
  • start

  • stop

Returns

get_total_poly_error(start: float, stop: float, mask=None) → float[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, **kwargs) → None[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

  • unbinned

  • bayes

  • kwargs

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