@@ -574,19 +574,25 @@ def load_events_and_gtis(
574
574
from astropy .io import fits as pf
575
575
576
576
hdulist = pf .open (fits_file )
577
+ probe_header = hdulist [0 ].header
578
+ # Let's look for TELESCOP here. This is the most common keyword to be
579
+ # found in well-behaved headers. If it is not in header 0, I take this key
580
+ # and the remaining information from header 1.
581
+ if "TELESCOP" not in probe_header :
582
+ probe_header = hdulist [1 ].header
577
583
mission_key = "MISSION"
578
- if mission_key not in hdulist [ 0 ]. header :
584
+ if mission_key not in probe_header :
579
585
mission_key = "TELESCOP"
580
- mission = hdulist [ 0 ]. header [mission_key ].lower ()
586
+ mission = probe_header [mission_key ].lower ()
581
587
db = read_mission_info (mission )
582
588
instkey = get_key_from_mission_info (db , "instkey" , "INSTRUME" )
583
589
instr = mode = None
584
- if instkey in hdulist [ 0 ]. header :
585
- instr = hdulist [ 0 ]. header [instkey ].strip ()
590
+ if instkey in probe_header :
591
+ instr = probe_header [instkey ].strip ()
586
592
587
593
modekey = get_key_from_mission_info (db , "dmodekey" , None , instr )
588
- if modekey is not None and modekey in hdulist [ 0 ]. header :
589
- mode = hdulist [ 0 ]. header [modekey ].strip ()
594
+ if modekey is not None and modekey in probe_header :
595
+ mode = probe_header [modekey ].strip ()
590
596
591
597
gtistring = get_key_from_mission_info (db , "gti" , "GTI,STDGTI" , instr , mode )
592
598
if hduname is None :
0 commit comments