code: def find_d2ifile(flist,detector):
      
      d2ifile = None
      for f in flist:
          fdet = fits.getval(f, 'detector', memmap=False)
          if fdet == detector:
              d2ifile = f
      return d2ifile
docs: Search a list of files for one that matches the detector specified.