Source code for gdt.missions.gifts.tte

#
# Copyright 2026 by University College Dublin. All rights reserved.
#
# Developed by: Derek O'Callaghan
#               University College Dublin
#               https://www.ucd.ie/
#
# Builds on:
#               Gamma-ray Data Tools - Core Components (https://github.com/USRA-STI/gdt-core)
#               Gamma-ray Data Tools - Fermi mission components (https://github.com/USRA-STI/gdt-fermi/)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and limitations under the
# License.
#
import os

from gdt.core.tte import PhotonList
from gdt.missions.fermi.gbm.tte import GbmTte
from .detectors import GiftsDetectors
from .headers import TteHeaders, TteTriggerHeaders, PhaiiHeaders, \
                     PhaiiTriggerHeaders
from .time import Time
from .phaii import GiftsPhaii

__all__ = ['GiftsTte']


[docs] class GiftsTte(GbmTte): """Class for Time-Tagged Event data. """ # TODO: this is duplicated in multiple places e.g. GiftsPhaii @property def detector(self): """(str): The detector name""" try: return GiftsDetectors.from_full_name(self.headers[0]['DETNAM']).name except: return self.headers[0]['DETNAM']
[docs] def to_phaii(self, bin_method, *args, time_range=None, energy_range=None, channel_range=None, **kwargs): """ Based on GbmTte.to_phaii() """ headers_cls = PhaiiTriggerHeaders if self.trigtime is not None else PhaiiHeaders headers = headers_cls.from_file_headers(self.headers) return super(GbmTte, self).to_phaii(bin_method, *args, time_range=time_range, energy_range=energy_range, channel_range=channel_range, phaii_class=GiftsPhaii, headers=headers, **kwargs)
[docs] @classmethod def open(cls, file_path, **kwargs): """Open a TTE FITS file and return the TTE object Args: file_path (str): The file path of the FITS file Returns: (:class:`GiftsTte`) """ # Currently impossible to access the FITS HDUs without opening twice, not ideal # This could be avoided if the original HDUs were retained during opening, but # they're rebuilt by each FITS subclass that uses its own headers obj = PhotonList.open(file_path, **kwargs) gbm_tte = GbmTte.open(file_path, **kwargs) hdrs = [hdu.header for hdu in obj.hdulist] # This is the reason why GbmTte.open() can't solely be used, # need to explicitly specify the header classes tte_headers = TteTriggerHeaders.from_headers(hdrs) if gbm_tte.trigtime else TteHeaders.from_headers(hdrs) obj.close() gifts_tte = cls.from_data(data=gbm_tte.data, gti=gbm_tte.gti, trigger_time=gbm_tte.trigtime, filename=os.path.basename(file_path), headers=tte_headers, event_deadtime=gbm_tte.event_deadtime, overflow_deadtime=gbm_tte.overflow_deadtime) return gifts_tte