GTI#

class gammapy.data.GTI(table, reference_time=None)[source]#

Bases: object

Good time intervals (GTI) Table.

Data format specification: GTI.

Note: at the moment dead-time and live-time is in the EVENTS header … the GTI header just deals with observation times.

Parameters:
tableTable

GTI table.

reference_timeTime, optional

The reference time. Default is None. If None, use TIME_REF_DEFAULT.

Examples

Load GTIs for a H.E.S.S. event list:

>>> from gammapy.data import GTI
>>> gti = GTI.read('$GAMMAPY_DATA/hess-dl3-dr1//data/hess_dl3_dr1_obs_id_023523.fits.gz')
>>> print(gti)
GTI info:
- Number of GTIs: 1
- Duration: 1687.0000000000016 s
- Start: 123890826.00000001 s MET
- Start: 2004-12-04T22:08:10.184 (time standard: TT)
- Stop: 123892513.00000001 s MET
- Stop: 2004-12-04T22:36:17.184 (time standard: TT)

Load GTIs for a Fermi-LAT event list:

>>> gti = GTI.read("$GAMMAPY_DATA/fermi-3fhl-gc/fermi-3fhl-gc-events.fits.gz")
>>> print(gti)
GTI info:
- Number of GTIs: 39042
- Duration: 183139597.9032163 s
- Start: 239557417.49417615 s MET
- Start: 2008-08-04T15:44:41.678 (time standard: TT)
- Stop: 460249999.99999994 s MET
- Stop: 2015-08-02T23:14:24.184 (time standard: TT)

Attributes Summary

met_start

GTI start time difference with reference time in seconds, MET as a Quantity.

met_stop

GTI start time difference with reference time in seconds, MET as a Quantity.

time_delta

GTI durations in seconds as a Quantity.

time_intervals

List of time intervals.

time_ref

Time reference as a Time object.

time_start

GTI start times as a Time object.

time_stop

GTI end times as a Time object.

time_sum

Sum of GTIs in seconds as a Quantity.

Methods Summary

copy()

Deep copy of the GIT object.

create(start, stop[, reference_time])

Create a GTI table from start and stop times.

delete_interval(time_interval)

Select and crop GTIs in time interval.

from_stack(gtis, **kwargs)

Stack (concatenate) list of GTIs.

from_table_hdu(table_hdu[, format])

Read from table HDU.

from_time_intervals(time_intervals[, ...])

From list of time intervals.

group_table(time_intervals[, atol])

Compute the table with the info on the group to which belong each time interval.

read(filename[, hdu, format, checksum])

Read from FITS file.

select_time(time_interval)

Select and crop GTIs in time interval.

stack(other)

Stack with another GTI in place.

to_table_hdu([format])

Convert this GTI instance to a astropy.io.fits.BinTableHDU.

union([overlap_ok, merge_equal])

Union of overlapping time intervals.

write(filename, **kwargs)

Write to file.

Attributes Documentation

met_start#

GTI start time difference with reference time in seconds, MET as a Quantity.

met_stop#

GTI start time difference with reference time in seconds, MET as a Quantity.

time_delta#

GTI durations in seconds as a Quantity.

time_intervals#

List of time intervals.

time_ref#

Time reference as a Time object.

time_start#

GTI start times as a Time object.

time_stop#

GTI end times as a Time object.

time_sum#

Sum of GTIs in seconds as a Quantity.

Methods Documentation

copy()[source]#

Deep copy of the GIT object.

classmethod create(start, stop, reference_time=None)[source]#

Create a GTI table from start and stop times.

Parameters:
startTime or Quantity

Start times, if a quantity then w.r.t. reference time.

stopTime or Quantity

Stop times, if a quantity then w.r.t. reference time.

reference_timeTime, optional

The reference time to use in GTI definition. Default is None. If None, use TIME_REF_DEFAULT.

delete_interval(time_interval)[source]#

Select and crop GTIs in time interval.

Parameters:
time_interval[astropy.time.Time, astropy.time.Time]

Start and stop time for the selection.

Returns:
gtiGTI

Copy of the GTI table with the bad time interval deleted.

classmethod from_stack(gtis, **kwargs)[source]#

Stack (concatenate) list of GTIs.

Calls vstack.

Parameters:
gtislist of GTI

List of good time intervals to stack.

**kwargsdict, optional

Keywords passed on to vstack.

Returns:
gtiGTI

Stacked good time intervals.

classmethod from_table_hdu(table_hdu, format='gadf')[source]#

Read from table HDU.

Parameters:
table_hduBinTableHDU

table hdu.

format{“gadf”}

Input format, currently only “gadf” is supported. Default is “gadf”.

classmethod from_time_intervals(time_intervals, reference_time=None)[source]#

From list of time intervals.

Parameters:
time_intervalslist of Time objects

Time intervals.

reference_timeTime, optional

Reference time to use in GTI definition. Default is None. If None, use TIME_REF_DEFAULT.

Returns:
gtiGTI

GTI table.

group_table(time_intervals, atol='1e-6 s')[source]#

Compute the table with the info on the group to which belong each time interval.

The t_start and t_stop are stored in MJD from a scale in “utc”.

Parameters:
time_intervalslist of astropy.time.Time

Start and stop time for each interval to compute the LC.

atolQuantity

Tolerance value for time comparison with different scale. Default is “1e-6 s”.

Returns:
group_tableTable

Contains the grouping info.

classmethod read(filename, hdu='GTI', format='gadf', checksum=False)[source]#

Read from FITS file.

Parameters:
filenamepathlib.Path or str

Filename

hdustr

hdu name. Default is “GTI”.

format: str

Input format, currently only “gadf” is supported. Default is “gadf”.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

select_time(time_interval)[source]#

Select and crop GTIs in time interval.

Parameters:
time_intervalastropy.time.Time

Start and stop time for the selection.

Returns:
gtiGTI

Copy of the GTI table with selection applied.

stack(other)[source]#

Stack with another GTI in place.

This simply changes the time reference of the second GTI table and stack the two tables. No logic is applied to the intervals.

Parameters:
otherGTI

GTI to stack to self.

to_table_hdu(format='gadf')[source]#

Convert this GTI instance to a astropy.io.fits.BinTableHDU.

Parameters:
formatstr, optional

Output format, currently only “gadf” is supported. Default is “gadf”.

Returns:
hduastropy.io.fits.BinTableHDU

GTI table converted to FITS representation.

union(overlap_ok=True, merge_equal=True)[source]#

Union of overlapping time intervals.

Returns a new GTI object.

Parameters:
overlap_okbool, optional

Whether to raise an error when overlapping time bins are found. Default is True.

merge_equalbool; optional

Whether to merge touching time bins e.g. (1, 2) and (2, 3) will result in (1, 3). Default is True.

write(filename, **kwargs)[source]#

Write to file.

Parameters:
filenamestr or Path

Filename.

**kwargsdict, optional

Keyword arguments passed to writeto.