@@ -374,7 +374,7 @@ def apply_rmf(self, spec):
374374        vector, there exists one or more sets of channels that this 
375375        flux is redistributed into. The additional arrays `n_grp`, 
376376        `f_chan` and `n_chan` store this information: 
377-          
377+ 
378378            * `n_group` stores the number of channel groups for each 
379379              energy bin 
380380
@@ -508,13 +508,26 @@ def __init__(self, filename):
508508        self .exposure  =  None 
509509        self ._load_arf (filename )
510510
511-     def  _load_arf (self , filename ):
512-         # open the FITS file and extract the MATRIX extension 
513-         # which contains the redistribution matrix and 
514-         # anxillary information 
511+     def  _load_arf (self , filename , extension = None ):
512+         # open the FITS file and extract the SPECRESP extension 
513+         # which contains the spectral response for the telescope 
515514        hdulist  =  fits .open (filename )
516515
517-         h  =  hdulist ["SPECRESP" ]
516+         # get all the extension names 
517+         extnames  =  np .array ([h .name  for  h  in  hdulist ])
518+ 
519+         # figure out the right extension to use 
520+         if  extension  is  not   None :
521+             h  =  hdulist [extension ]
522+ 
523+         elif  'SPECRESP'  in  extnames :
524+             h  =  hdulist ['SPECRESP' ]
525+ 
526+         else :
527+             print ("Cannot find common FITS file extension for spectral response" )
528+             print ("Please set the `extension` keyword" )
529+             return 
530+ 
518531        data  =  h .data 
519532        hdr  =  h .header 
520533        hdulist .close ()
0 commit comments