Source code for gdt.missions.gifts.phaii

#
# 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.
#
from gdt.core.phaii import Phaii
from gdt.missions.fermi.gbm.phaii import GbmPhaii
from .detectors import GiftsDetectors
from .headers import PhaiiHeaders, PhaiiTriggerHeaders
from .time import Time

__all__ = ['GiftsPhaii', 'Ctime', 'Cspec']


[docs] class GiftsPhaii(GbmPhaii): """PHAII class for GIFTS time history spectra. """ # TODO: this is duplicated in multiple places e.g. GiftsTte @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] @classmethod def open(cls, file_path, **kwargs): """Open a GIFTS PHAII FITS file and return the GiftsPhaii object Args: file_path (str): The file path of the FITS file Returns: (:class:`GiftsPhaii`) """ # 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 = Phaii.open(file_path, **kwargs) gbm_phaii = GbmPhaii.open(file_path, **kwargs) hdrs = [hdu.header for hdu in obj.hdulist] # This is the reason why GbmPhaii.open() can't solely be used, # need to explicitly specify the header classes phaii_headers = PhaiiTriggerHeaders.from_headers(hdrs) if gbm_phaii.trigtime else PhaiiHeaders.from_headers(hdrs) obj.close() if phaii_headers[0]['DATATYPE'] == 'CSPEC': class_ = Cspec elif phaii_headers[0]['DATATYPE'] == 'CTIME': class_ = Ctime else: class_ = cls return class_.from_data(gbm_phaii.data, gti=gbm_phaii.gti, trigger_time=gbm_phaii.trigtime, filename=obj.filename, headers=phaii_headers)
[docs] class Cspec(GiftsPhaii): """Class for GIFTS CSPEC data. """
[docs] class Ctime(GiftsPhaii): """Class for GIFTS CTIME data. """