cosmogrb.utils package¶
Subpackages¶
- cosmogrb.utils.plotting package
Submodules¶
cosmogrb.utils.array_to_cmap module¶
-
cosmogrb.utils.array_to_cmap.
array_to_cmap
(values, cmap, use_log=False)[source]¶ Generates a color map and color list that is normalized to the values in an array. Allows for adding a 3rd dimension onto a plot
Parameters: - values – a list a values to map into a cmap
- cmap – the mpl colormap to use
- use_log – if the mapping should be done in log space
cosmogrb.utils.file_utils module¶
cosmogrb.utils.fits_file module¶
cosmogrb.utils.hdf5_utils module¶
cosmogrb.utils.logging module¶
cosmogrb.utils.package_utils module¶
cosmogrb.utils.response_file module¶
-
class
cosmogrb.utils.response_file.
MATRIX
(mc_energies, channel_energies, matrix)[source]¶ Bases:
cosmogrb.utils.fits_file.FITSExtension
Represents the MATRIX extension of a response FITS file following the OGIP format :param mc_energies_lo: lower bound of MC energies (in keV) :param mc_energies_hi: hi bound of MC energies (in keV) :param channel_energies_lo: lower bound of channel energies (in keV) :param channel_energies_hi: hi bound of channel energies (in keV :param matrix: the redistribution matrix, representing energy dispersion effects
-
class
cosmogrb.utils.response_file.
RMF
(mc_energies, ebounds, matrix, telescope_name, instrument_name)[source]¶ Bases:
responsum.utils.fits_file.FITSFile
A RMF file, the OGIP format for a matrix representing energy dispersion effects.
-
class
cosmogrb.utils.response_file.
RSP
(mc_energies, ebounds, matrix, telescope_name, instrument_name)[source]¶ Bases:
responsum.utils.fits_file.FITSFile
A response file, the OGIP format for a matrix representing both energy dispersion effects and effective area, in the same matrix.
-
class
cosmogrb.utils.response_file.
SPECRESP_MATRIX
(mc_energies, channel_energies, matrix)[source]¶ Bases:
cosmogrb.utils.response_file.MATRIX
Represents the SPECRESP_MATRIX extension of a response FITS file following the OGIP format :param mc_energies_lo: lower bound of MC energies (in keV) :param mc_energies_hi: hi bound of MC energies (in keV) :param channel_energies_lo: lower bound of channel energies (in keV) :param channel_energies_hi: hi bound of channel energies (in keV :param matrix: the redistribution matrix, representing energy dispersion effects and effective area information
cosmogrb.utils.time_interval module¶
-
class
cosmogrb.utils.time_interval.
TimeInterval
(start, stop, counts=None, dead_time=0, swap_if_inverted=False)[source]¶ Bases:
object
-
counts
¶
-
dead_time
¶
-
exposure
¶
-
intersect
(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)[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
-
mid_point
¶
-
overlaps_with
(interval)[source]¶ Returns whether the current time interval and the provided one overlap or not
Parameters: interval (Interval) – a TimeInterval instance Returns: True or False
-
rate
¶
-
start
¶
-
stop
¶
-
to_string
()[source]¶ returns a string representation of the time interval that is like the argument of many interval reading funcitons
Returns:
-
width
¶
-
-
class
cosmogrb.utils.time_interval.
TimeIntervalSet
(list_of_intervals=())[source]¶ Bases:
object
A set of intervals
-
absolute_start
¶ the minimum of the start times :return:
-
absolute_stop
¶ the maximum of the stop times :return:
-
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:
-
counts
¶
-
edges
¶ return an array of time edges if contiguous :return:
-
exposures
¶
-
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, counts=None, dead_time=None)[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:
-
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
-
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:
-
mid_points
¶
-
plot_intervals
(as_rates=True, ax=None, **kwargs)[source]¶ plot the intervals as rates or counts
Parameters: - as_rates –
- ax –
Returns: Return type:
-
rates
¶
-
sort
()[source]¶ Returns a sorted copy of the set (sorted according to the tstart of the time intervals)
Returns:
-
starts
¶ Return the starts fo the set
Returns: list of start times
-
stops
¶ Return the stops of the set
Returns:
-
widths
¶
-
cosmogrb.utils.tte_file module¶
-
class
cosmogrb.utils.tte_file.
EBOUNDS
(det_name, tstart, tstop, trigger_time, ra, dec, channel, emin, emax)[source]¶
-
class
cosmogrb.utils.tte_file.
EVENTS
(det_name, tstart, tstop, trigger_time, ra, dec, pha, time)[source]¶