USRA-STI / gdt-fermi

Gamma-ray Data Tools - Fermi mission components
Apache License 2.0
3 stars 7 forks source link

Get error when writing the sliced daily data #51

Open xiesl97 opened 1 month ago

xiesl97 commented 1 month ago

hello, when I slice a daily tte data and write out

from gdt.missions.fermi.gbm.tte import GbmTte

tte = GbmTte.open('/mnt/d/temp/glg_tte_n0_240101_06z_v01.fit.gz')
tte.time_range
time_sliced_tte = tte.slice_time((725781880, 725781900))
time_sliced_tte.write('./', filename='my_first_custom_tte.fit')

get error

{
    "name": "KeyError",
    "message": "\"Keyword 'TZERO1' not found.\"",
    "stack": "---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[2], line 6
      4 tte.time_range
      5 time_sliced_tte = tte.slice_time((725781880, 725781900))
----> 6 time_sliced_tte.write('./', filename='my_first_custom_tte.fit')

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/gdt/core/file.py:186, in FitsFileContextManager.write(self, directory, filename, **kwargs)
    184 # write to file
    185 full_path = dir_path / filename
--> 186 self.hdulist.writeto(full_path, checksum=True, **kwargs)

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/gdt/core/file.py:76, in FitsFileContextManager.hdulist(self)
     74     return self._hdulist
     75 else:
---> 76     return self._build_hdulist()

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/gdt/missions/fermi/gbm/tte.py:143, in GbmTte._build_hdulist(self)
    140 hdulist.append(ebounds_hdu)
    142 # the events extension
--> 143 events_hdu = self._events_table()
    144 hdulist.append(events_hdu)        
    146 # the GTI extension

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/gdt/missions/fermi/gbm/tte.py:195, in GbmTte._events_table(self)
    193 for key, val in self.headers['EVENTS'].items():
    194     hdu.header[key] = val
--> 195 hdu.header.comments['TZERO1'] = 'Offset, equal to TRIGTIME'
    196 return hdu

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/astropy/io/fits/header.py:2173, in _HeaderComments.__setitem__(self, item, comment)
   2169     return
   2171 # In this case, key/index errors should be raised; don't update
   2172 # comments of nonexistent cards
-> 2173 idx = self._header._cardindex(item)
   2174 value = self._header[idx]
   2175 self._header[idx] = (value, comment)

File ~/anaconda3/envs/gdt/lib/python3.11/site-packages/astropy/io/fits/header.py:1725, in Header._cardindex(self, key)
   1722         indices = self._rvkc_indices.get(keyword, None)
   1724 if not indices:
-> 1725     raise KeyError(f\"Keyword {keyword!r} not found.\")
   1727 try:
   1728     return indices[n]

KeyError: \"Keyword 'TZERO1' not found.\""
}