threeML.utils package
Subpackages
- threeML.utils.OGIP package
- Submodules
- threeML.utils.OGIP.pha module
- threeML.utils.OGIP.response module
EBOUNDS
GapInCoverageIntervals
InstrumentResponse
InstrumentResponse.arf_filename
InstrumentResponse.clone()
InstrumentResponse.convolve()
InstrumentResponse.coverage_interval
InstrumentResponse.create_dummy_response()
InstrumentResponse.ebounds
InstrumentResponse.energy_to_channel()
InstrumentResponse.first_channel
InstrumentResponse.matrix
InstrumentResponse.monte_carlo_energies
InstrumentResponse.plot_matrix()
InstrumentResponse.replace_matrix()
InstrumentResponse.rsp_filename
InstrumentResponse.set_function()
InstrumentResponse.to_fits()
InstrumentResponseSet
IntervalOfInterestNotCovered
MATRIX
NoCoverageIntervals
NoMatrixForInterval
NonContiguousCoverageIntervals
OGIPResponse
RMF
RSP
SPECRESP_MATRIX
- Module contents
- threeML.utils.data_builders package
- Subpackages
- Submodules
- threeML.utils.data_builders.time_series_builder module
BinningMethodError
TimeSeriesBuilder
TimeSeriesBuilder.background_counts_per_interval
TimeSeriesBuilder.background_poly_order
TimeSeriesBuilder.bins
TimeSeriesBuilder.create_time_bins()
TimeSeriesBuilder.fit_polynomial()
TimeSeriesBuilder.from_gbm_cspec_or_ctime()
TimeSeriesBuilder.from_gbm_tte()
TimeSeriesBuilder.from_konus_pha()
TimeSeriesBuilder.from_lat_lle()
TimeSeriesBuilder.from_phaII()
TimeSeriesBuilder.from_polar_polarization()
TimeSeriesBuilder.from_polar_spectrum()
TimeSeriesBuilder.get_background_parameters()
TimeSeriesBuilder.read_bins()
TimeSeriesBuilder.save_background()
TimeSeriesBuilder.set_active_time_interval()
TimeSeriesBuilder.set_background_interval()
TimeSeriesBuilder.significance_per_interval
TimeSeriesBuilder.time_series
TimeSeriesBuilder.to_polarlike()
TimeSeriesBuilder.to_spectrumlike()
TimeSeriesBuilder.total_counts_per_interval
TimeSeriesBuilder.tstart
TimeSeriesBuilder.tstop
TimeSeriesBuilder.view_lightcurve()
TimeSeriesBuilder.write_pha_from_binner()
- Module contents
TimeSeriesBuilder
TimeSeriesBuilder.background_counts_per_interval
TimeSeriesBuilder.background_poly_order
TimeSeriesBuilder.bins
TimeSeriesBuilder.create_time_bins()
TimeSeriesBuilder.fit_polynomial()
TimeSeriesBuilder.from_gbm_cspec_or_ctime()
TimeSeriesBuilder.from_gbm_tte()
TimeSeriesBuilder.from_konus_pha()
TimeSeriesBuilder.from_lat_lle()
TimeSeriesBuilder.from_phaII()
TimeSeriesBuilder.from_polar_polarization()
TimeSeriesBuilder.from_polar_spectrum()
TimeSeriesBuilder.get_background_parameters()
TimeSeriesBuilder.read_bins()
TimeSeriesBuilder.save_background()
TimeSeriesBuilder.set_active_time_interval()
TimeSeriesBuilder.set_background_interval()
TimeSeriesBuilder.significance_per_interval
TimeSeriesBuilder.time_series
TimeSeriesBuilder.to_polarlike()
TimeSeriesBuilder.to_spectrumlike()
TimeSeriesBuilder.total_counts_per_interval
TimeSeriesBuilder.tstart
TimeSeriesBuilder.tstop
TimeSeriesBuilder.view_lightcurve()
TimeSeriesBuilder.write_pha_from_binner()
TransientLATDataBuilder
- threeML.utils.data_download package
- threeML.utils.fitted_objects package
- Submodules
- threeML.utils.fitted_objects.fitted_point_sources module
- threeML.utils.fitted_objects.fitted_source_handler module
- Module contents
- threeML.utils.photometry package
- Submodules
- threeML.utils.photometry.filter_library module
- threeML.utils.photometry.filter_set module
- threeML.utils.photometry.photometric_observation module
PhotometericObservation
PhotometericObservation.from_dict()
PhotometericObservation.from_hdf5()
PhotometericObservation.from_kwargs()
PhotometericObservation.get_mask_from_filter_sequence()
PhotometericObservation.is_compatible_with_filter_set()
PhotometericObservation.items()
PhotometericObservation.keys()
PhotometericObservation.to_hdf5()
- Module contents
- threeML.utils.polarization package
- threeML.utils.spectrum package
- Submodules
- threeML.utils.spectrum.binned_spectrum module
BinnedSpectrum
BinnedSpectrum.INTERVAL_TYPE
BinnedSpectrum.add_inverse_variance_weighted()
BinnedSpectrum.clone()
BinnedSpectrum.count_errors
BinnedSpectrum.counts
BinnedSpectrum.exposure
BinnedSpectrum.from_pandas()
BinnedSpectrum.from_time_series()
BinnedSpectrum.instrument
BinnedSpectrum.is_poisson
BinnedSpectrum.mission
BinnedSpectrum.n_channel
BinnedSpectrum.n_channels
BinnedSpectrum.quality
BinnedSpectrum.rate_errors
BinnedSpectrum.rates
BinnedSpectrum.scale_factor
BinnedSpectrum.sys_errors
BinnedSpectrum.to_pandas()
BinnedSpectrum.total_count
BinnedSpectrum.total_count_error
BinnedSpectrum.total_rate
BinnedSpectrum.total_rate_error
BinnedSpectrum.tstart
BinnedSpectrum.tstop
BinnedSpectrumWithDispersion
Channel
ChannelSet
Quality
- threeML.utils.spectrum.binned_spectrum_set module
BinnedSpectrumSet
BinnedSpectrumSet.count_errors_per_bin
BinnedSpectrumSet.counts_per_bin
BinnedSpectrumSet.exposure_per_bin
BinnedSpectrumSet.n_channels
BinnedSpectrumSet.quality_per_bin
BinnedSpectrumSet.rate_errors_per_bin
BinnedSpectrumSet.rates_per_bin
BinnedSpectrumSet.reference_time
BinnedSpectrumSet.sort()
BinnedSpectrumSet.sys_errors_per_bin
BinnedSpectrumSet.time_intervals
BinnedSpectrumSet.time_to_index()
- threeML.utils.spectrum.pha_spectrum module
- threeML.utils.spectrum.share_spectrum module
- threeML.utils.spectrum.spectrum_likelihood module
BinnedStatistic
GaussianObservedGaussianBackgroundStatistic
GaussianObservedStatistic
NotAvailableStatistic
PoissonObservedGaussianBackgroundStatistic
PoissonObservedIdealBackgroundStatistic
PoissonObservedModeledBackgroundStatistic
PoissonObservedNoBackgroundStatistic
PoissonObservedPoissonBackgroundStatistic
- Module contents
- threeML.utils.statistics package
- threeML.utils.time_series package
- Submodules
- threeML.utils.time_series.binned_spectrum_series module
BinnedSpectrumSeries
BinnedSpectrumSeries.binned_spectrum_set
BinnedSpectrumSeries.bins
BinnedSpectrumSeries.count_per_channel_over_interval()
BinnedSpectrumSeries.counts_over_interval()
BinnedSpectrumSeries.dead_time_over_interval()
BinnedSpectrumSeries.exposure_over_interval()
BinnedSpectrumSeries.set_active_time_intervals()
BinnedSpectrumSeries.view_lightcurve()
- threeML.utils.time_series.event_list module
EventList
EventList.arrival_times
EventList.bin_by_bayesian_blocks()
EventList.bin_by_constant()
EventList.bin_by_custom()
EventList.bin_by_significance()
EventList.bins
EventList.count_per_channel_over_interval()
EventList.counts_over_interval()
EventList.measurement
EventList.n_events
EventList.set_active_time_intervals()
EventList.view_lightcurve()
EventListWithDeadTime
EventListWithDeadTimeFraction
EventListWithLiveTime
OverLappingIntervals
ReducingNumberOfSteps
ReducingNumberOfThreads
ceildiv()
- threeML.utils.time_series.polynomial module
- threeML.utils.time_series.time_series module
OverLappingIntervals
ReducingNumberOfSteps
ReducingNumberOfThreads
TimeSeries
TimeSeries.bins
TimeSeries.bkg_intervals
TimeSeries.count_per_channel_over_interval()
TimeSeries.counts_over_interval()
TimeSeries.exposure_over_interval()
TimeSeries.fit_polynomial()
TimeSeries.get_information_dict()
TimeSeries.get_poly_info()
TimeSeries.get_total_poly_count()
TimeSeries.get_total_poly_error()
TimeSeries.n_channels
TimeSeries.poly_fit_exists
TimeSeries.poly_order
TimeSeries.polynomials
TimeSeries.restore_fit()
TimeSeries.save_background()
TimeSeries.set_active_time_intervals()
TimeSeries.set_background_interval()
TimeSeries.set_polynomial_fit_interval()
TimeSeries.time_intervals
TimeSeries.view_lightcurve()
ceildiv()
- Module contents
Submodules
threeML.utils.bayesian_blocks module
- threeML.utils.bayesian_blocks.bayesian_blocks(tt, ttstart, ttstop, p0, bkg_integral_distribution=None)[source]
Divide a series of events characterized by their arrival time in blocks of perceptibly constant count rate. If the background integral distribution is given, divide the series in blocks where the difference with respect to the background is perceptibly constant.
- Parameters:
tt – arrival times of the events
ttstart – the start of the interval
ttstop – the stop of the interval
p0 – the false positive probability. This is used to decide the penalization on the likelihood, so this
parameter affects the number of blocks :param bkg_integral_distribution: (default: None) If given, the algorithm account for the presence of the background and finds changes in rate with respect to the background :return: the np.array containing the edges of the blocks
threeML.utils.binner module
- class threeML.utils.binner.Rebinner(vector_to_rebin_on, min_value_per_bin, mask=None)[source]
Bases:
object
A class to rebin vectors keeping a minimum value per bin. It supports array with a mask, so that elements excluded through the mask will not be considered for the rebinning
- property grouping
- property n_bins
Returns the number of bins defined.
- Returns:
- class threeML.utils.binner.TemporalBinner(list_of_intervals=())[source]
Bases:
TimeIntervalSet
An extension of the TimeInterval set that includes binning capabilities
- classmethod bin_by_bayesian_blocks(arrival_times, p0, bkg_integral_distribution=None)[source]
Divide a series of events characterized by their arrival time in blocks of perceptibly constant count rate. If the background integral distribution is given, divide the series in blocks where the difference with respect to the background is perceptibly constant.
- Parameters:
arrival_times – An iterable (list, numpy.array…) containing the arrival time of the events. NOTE: the input array MUST be time-ordered, and without duplicated entries. To ensure this, you may execute the following code: tt_array = numpy.asarray(self._arrival_times) tt_array = numpy.unique(tt_array) tt_array.sort() before running the algorithm.
p0 – The probability of finding a variations (i.e., creating a new block) when there is none. In other words, the probability of a Type I error, i.e., rejecting the null-hypothesis when is true. All found variations will have a post-trial significance larger than p0.
- :param bkg_integral_distributionthe integral distribution for the
background counts. It must be a function of the form f(x), which must return the integral number of counts expected from the background component between time 0 and x.
- classmethod bin_by_constant(arrival_times, dt)[source]
Create bins with a constant dt
- Parameters:
dt – temporal spacing of the bins
- Returns:
None
- classmethod bin_by_custom(starts, stops)[source]
Simplicity function to make custom bins. This form keeps introduction of custom bins uniform for other binning methods
- Parameters:
start – start times of the bins
stop – stop times of the bins
- Returns:
- classmethod bin_by_significance(arrival_times, background_getter, background_error_getter=None, sigma_level=10, min_counts=1, tstart=None, tstop=None)[source]
Bin the data to a given significance level for a given background method and sigma method. If a background error function is given then it is assumed that the error distribution is gaussian. Otherwise, the error distribution is assumed to be Poisson.
- Parameters:
background_getter – function of a start and stop time that returns background counts
background_error_getter – function of a start and stop time that returns background count errors
sigma_level – the sigma level of the intervals
min_counts – the minimum counts per bin
- Returns:
threeML.utils.cartesian module
threeML.utils.differentiation module
threeML.utils.fermi_relative_mission_time module
- threeML.utils.fermi_relative_mission_time.compute_fermi_relative_mission_times(trigger_time)[source]
If the user has the requests library, this function looks online to the HEASARC xtime utility and computes other mission times relative to the input MET
- Parameters:
trigger_time – a fermi MET
- Returns:
mission time in a python dictionary
threeML.utils.histogram module
- class threeML.utils.histogram.Histogram(list_of_intervals, contents=None, errors=None, sys_errors=None, is_poisson=False)[source]
Bases:
IntervalSet
- bin_entries(entires)[source]
add the entries into the proper bin
- Parameters:
entires – list of events
- Returns:
- property contents
- property errors
- classmethod from_entries(list_of_intervals, entries)[source]
create a histogram from a list of intervals and entries to bin
- Parameters:
list_of_intervals
entries
- Returns:
- classmethod from_numpy_histogram(hist, errors=None, sys_errors=None, is_poisson=False, **kwargs)[source]
create a Histogram from a numpy histogram. .. rubric:: Example
r = np.random.randn(1000) np_hist = np.histogram(r) hist = Histogram.from_numpy_histogram(np_hist)
- Parameters:
hist – a np.histogram tuple
errors – list of errors for each bin in the numpy histogram
sys_errors – list of systematic errors for each bin in the numpy histogram
is_poisson – if the data is Poisson distributed or not
kwargs – any kwargs to pass along
- Returns:
a Histogram object
- property is_poisson
- property sys_errors
- property total
- property total_error
threeML.utils.interval module
- class threeML.utils.interval.Interval(start: float, stop: float, swap_if_inverted: bool = False)[source]
Bases:
object
- intersect(interval: Interval) Interval [source]
Returns a new time interval corresponding to the intersection between this interval and the provided one.
- Parameters:
interval (Interval) – a TimeInterval instance
- Returns:
new interval covering the intersection
:raise IntervalsDoNotOverlap : if the intervals do not overlap
- merge(interval: Interval) Interval [source]
Returns a new interval corresponding to the merge of the current and the provided time interval. The intervals must overlap.
- Parameters:
interval – a TimeInterval instance :type interval : Interval
- Returns:
a new TimeInterval instance
- property mid_point: float
- overlaps_with(interval: Interval) bool [source]
Returns whether the current time interval and the provided one overlap or not
- Parameters:
interval (Interval) – a TimeInterval instance
- Returns:
True or False
- property start: float
- property stop: float
- class threeML.utils.interval.IntervalSet(list_of_intervals=())[source]
Bases:
object
A set of intervals
- property absolute_start
the minimum of the start times :return:
- property absolute_stop
the maximum of the stop times :return:
- property bin_stack
- get a stacked view of the bins [[start_1,stop_1 ],
[start_2,stop_2 ]]
- Returns:
- containing_interval(start, stop, inner=True, as_mask=False)[source]
returns either a mask of the intervals contained in the selection or a new set of intervals within the selection. NOTE: no sort is performed
- Parameters:
start – start of interval
stop – stop of interval
inner – if True, returns only intervals strictly contained within bounds, if False, returns outer bounds as well
as_mask – if you want a mask or the intervals
- Returns:
- property edges
return an array of time edges if contiguous :return:
- classmethod from_list_of_edges(edges)[source]
Builds a IntervalSet from a list of time edges:
edges = [-1,0,1] -> [-1,0], [0,1]
- Parameters:
edges
- Returns:
- classmethod from_starts_and_stops(starts, stops)[source]
Builds a TimeIntervalSet from a list of start and stop times:
start = [-1,0] -> [-1,0], [0,1] stop = [0,1]
- Parameters:
starts
stops
- Returns:
- classmethod from_strings(*intervals)[source]
These are intervals specified as “-10 – 5”, “0-10”, and so on
- Parameters:
intervals
- Returns:
- is_contiguous(relative_tolerance=1e-05)[source]
Check whether the time intervals are all contiguous, i.e., the stop time of one interval is the start time of the next
- Returns:
True or False
- property is_sorted
Check whether the time intervals are sorted :return: True or False
- merge_intersecting_intervals(in_place=False)[source]
merges intersecting intervals into a contiguous intervals
- Returns:
- property mid_points
- classmethod new(*args, **kwargs)[source]
Create a new interval set of this type :param args: :param kwargs: :return: interval set
- classmethod new_interval(*args, **kwargs)[source]
Create a new interval of INTERVAL_TYPE :param args: :param kwargs: :return: interval
- sort()[source]
Returns a sorted copy of the set (sorted according to the tstart of the time intervals)
- Returns:
- property starts
Return the starts fo the set
- Returns:
list of start times
- property stops
Return the stops of the set
- Returns:
- property widths
threeML.utils.numba_utils module
- threeML.utils.numba_utils.Vector(numba_type)[source]
Generates an instance of a dynamically resized vector numba jitclass.
- threeML.utils.numba_utils.VectorComplex128
alias of
_Vector
- threeML.utils.numba_utils.VectorComplex64
alias of
_Vector
- threeML.utils.numba_utils.VectorFloat32
alias of
_Vector
- threeML.utils.numba_utils.VectorFloat64
alias of
_Vector
- threeML.utils.numba_utils.VectorInt16
alias of
_Vector
- threeML.utils.numba_utils.VectorInt32
alias of
_Vector
- threeML.utils.numba_utils.VectorInt64
alias of
_Vector
- threeML.utils.numba_utils.VectorInt8
alias of
_Vector
- threeML.utils.numba_utils.VectorUint16
alias of
_Vector
- threeML.utils.numba_utils.VectorUint32
alias of
_Vector
- threeML.utils.numba_utils.VectorUint64
alias of
_Vector
- threeML.utils.numba_utils.VectorUint8
alias of
_Vector
threeML.utils.power_of_two_utils module
threeML.utils.progress_bar module
threeML.utils.step_parameter_generator module
- threeML.utils.step_parameter_generator.step_generator(intervals, parameter)[source]
Generates sum of step or dirac delta functions for the given intervals and parameter. This can be used to link time-independent parameters of a model to time.
If the intervals provided are 1-D, i.e, they are the means of time bins or the TOA of photons, then a sum of dirac deltas is returned with their centers at the times provided
If the intervals are 2-D (start, stop), sum of step functions is created with the bounds at the start and stop times of the interval.
The parameter is used to set the bounds and initial value, min, max of the non-zero points of the functions
- Parameters:
intervals – an array of the 1- or 2-D intervals to be used
parameter – astromodels parameter
threeML.utils.string_utils module
threeML.utils.time_interval module
- class threeML.utils.time_interval.TimeInterval(start: float, stop: float, swap_if_inverted: bool = False)[source]
Bases:
Interval
- property duration
- property half_time
- property start_time
- property stop_time
- class threeML.utils.time_interval.TimeIntervalSet(list_of_intervals=())[source]
Bases:
IntervalSet
A set of time intervals
- INTERVAL_TYPE
alias of
TimeInterval
- property absolute_start_time
the minimum of the start times :return:
- property absolute_stop_time
the maximum of the stop times :return:
- property start_times
Return the starts fo the set
- Returns:
list of start times
- property stop_times
Return the stops of the set
- Returns:
- property time_edges
return an array of time edges if contiguous :return: