threeML.utils package
Subpackages
-
threeML.utils.OGIP package
- Submodules
- threeML.utils.OGIP.pha module
-
threeML.utils.OGIP.response module
EBOUNDSGapInCoverageIntervals-
InstrumentResponseInstrumentResponse.arf_filenameInstrumentResponse.clone()InstrumentResponse.convolve()InstrumentResponse.coverage_intervalInstrumentResponse.create_dummy_response()InstrumentResponse.eboundsInstrumentResponse.energy_to_channel()InstrumentResponse.first_channelInstrumentResponse.matrixInstrumentResponse.monte_carlo_energiesInstrumentResponse.plot_matrix()InstrumentResponse.replace_matrix()InstrumentResponse.rsp_filenameInstrumentResponse.set_function()InstrumentResponse.to_fits()
-
InstrumentResponseSet IntervalOfInterestNotCoveredMATRIXNoCoverageIntervalsNoMatrixForIntervalNonContiguousCoverageIntervals-
OGIPResponse RMFRSPSPECRESP_MATRIX
- Module contents
-
threeML.utils.data_builders package
- Subpackages
- Submodules
-
threeML.utils.data_builders.time_series_builder module
BinningMethodError-
TimeSeriesBuilderTimeSeriesBuilder.background_counts_per_intervalTimeSeriesBuilder.background_poly_orderTimeSeriesBuilder.binsTimeSeriesBuilder.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_intervalTimeSeriesBuilder.time_seriesTimeSeriesBuilder.to_polarlike()TimeSeriesBuilder.to_spectrumlike()TimeSeriesBuilder.total_counts_per_intervalTimeSeriesBuilder.tstartTimeSeriesBuilder.tstopTimeSeriesBuilder.view_lightcurve()TimeSeriesBuilder.write_pha_from_binner()
-
Module contents
-
TimeSeriesBuilderTimeSeriesBuilder.background_counts_per_intervalTimeSeriesBuilder.background_poly_orderTimeSeriesBuilder.binsTimeSeriesBuilder.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_intervalTimeSeriesBuilder.time_seriesTimeSeriesBuilder.to_polarlike()TimeSeriesBuilder.to_spectrumlike()TimeSeriesBuilder.total_counts_per_intervalTimeSeriesBuilder.tstartTimeSeriesBuilder.tstopTimeSeriesBuilder.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
-
PhotometericObservationPhotometericObservation.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
-
BinnedSpectrumBinnedSpectrum.INTERVAL_TYPEBinnedSpectrum.add_inverse_variance_weighted()BinnedSpectrum.clone()BinnedSpectrum.count_errorsBinnedSpectrum.countsBinnedSpectrum.exposureBinnedSpectrum.from_pandas()BinnedSpectrum.from_time_series()BinnedSpectrum.instrumentBinnedSpectrum.is_poissonBinnedSpectrum.missionBinnedSpectrum.n_channelBinnedSpectrum.n_channelsBinnedSpectrum.qualityBinnedSpectrum.rate_errorsBinnedSpectrum.ratesBinnedSpectrum.scale_factorBinnedSpectrum.sys_errorsBinnedSpectrum.to_pandas()BinnedSpectrum.total_countBinnedSpectrum.total_count_errorBinnedSpectrum.total_rateBinnedSpectrum.total_rate_errorBinnedSpectrum.tstartBinnedSpectrum.tstop
-
BinnedSpectrumWithDispersion -
Channel -
ChannelSet -
Quality
-
-
threeML.utils.spectrum.binned_spectrum_set module
-
BinnedSpectrumSetBinnedSpectrumSet.count_errors_per_binBinnedSpectrumSet.counts_per_binBinnedSpectrumSet.exposure_per_binBinnedSpectrumSet.n_channelsBinnedSpectrumSet.quality_per_binBinnedSpectrumSet.rate_errors_per_binBinnedSpectrumSet.rates_per_binBinnedSpectrumSet.reference_timeBinnedSpectrumSet.sort()BinnedSpectrumSet.sys_errors_per_binBinnedSpectrumSet.time_intervalsBinnedSpectrumSet.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
-
BinnedSpectrumSeriesBinnedSpectrumSeries.binned_spectrum_setBinnedSpectrumSeries.binsBinnedSpectrumSeries.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
-
EventListEventList.arrival_timesEventList.bin_by_bayesian_blocks()EventList.bin_by_constant()EventList.bin_by_custom()EventList.bin_by_significance()EventList.binsEventList.count_per_channel_over_interval()EventList.counts_over_interval()EventList.measurementEventList.n_eventsEventList.set_active_time_intervals()EventList.view_lightcurve()
-
EventListWithDeadTime -
EventListWithDeadTimeFraction -
EventListWithLiveTime OverLappingIntervalsReducingNumberOfStepsReducingNumberOfThreadsceildiv()
-
- threeML.utils.time_series.polynomial module
-
threeML.utils.time_series.time_series module
OverLappingIntervalsReducingNumberOfStepsReducingNumberOfThreads-
TimeSeriesTimeSeries.binsTimeSeries.bkg_intervalsTimeSeries.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_channelsTimeSeries.poly_fit_existsTimeSeries.poly_orderTimeSeries.polynomialsTimeSeries.restore_fit()TimeSeries.save_background()TimeSeries.set_active_time_intervals()TimeSeries.set_background_interval()TimeSeries.set_polynomial_fit_interval()TimeSeries.time_intervalsTimeSeries.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
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
- Returns:
-
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:
objectA 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:
TimeIntervalSetAn 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 :return: 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:
objectA set of intervals.
- property absolute_start
-
return:
- Type:
-
The minimum of the start times
- property absolute_stop
-
return:
- Type:
-
The maximum of the stop times
- 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:
- Type:
-
Return an array of time edges if contiguous
- 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
-
True or False.
- Type:
-
Check whether the time intervals are sorted
- Type:
-
return
- 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:
- Parameters:
-
kwargs
- Returns:
-
interval set
- classmethod new_interval(*args, **kwargs)[source]
-
Create a new interval of INTERVAL_TYPE :param args:
- Parameters:
-
kwargs
- Returns:
-
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:
IntervalSetA set of time intervals.
- INTERVAL_TYPE
-
alias of
TimeInterval
- property absolute_start_time
-
return:
- Type:
-
The minimum of the start times
- property absolute_stop_time
-
return:
- Type:
-
The maximum of the stop times
- 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:
- Type:
-
Return an array of time edges if contiguous