code: def getflat(self, chip):
          
          sci_chip = self._image[self.scienceExt, chip]
          # The keyword for ACS flat fields in the primary header of the flt
          # file is pfltfile.  This flat file is already in the required
          # units of electrons.
  
          # The use of fileutil.osfn interprets any environment variable, such as
          # jref$, used in the specification of the reference filename
          filename = fileutil.osfn(self._image["PRIMARY"].header[self.flatkey])
          hdulist = None
          try:
              hdulist = fileutil.openImage(filename, mode='readonly',
                                           memmap=False)
              data = hdulist[(self.scienceExt, chip)].data
  
              if data.shape[0] != sci_chip.image_shape[0]:
                  ltv2 = int(np.round(sci_chip.ltv2))
              else:
                  ltv2 = 0
              size2 = sci_chip.image_shape[0] + ltv2
  
              if data.shape[1] != sci_chip.image_shape[1]:
                  ltv1 = int(np.round(sci_chip.ltv1))
              else:
                  ltv1 = 0
              size1 = sci_chip.image_shape[1] + ltv1
  
              flat = data[ltv2:size2, ltv1:size1]
  
          except FileNotFoundError:
              flat = np.ones(sci_chip.image_shape, dtype=sci_chip.image_dtype)
              log.warning("Cannot find flat field file '{}'".format(filename))
              log.warning("Treating flatfield as a constant value of '1'.")
  
          finally:
              if hdulist is not None:
                  hdulist.close()
  
          return flat
docs: Method for retrieving a detector's flat field.
  
          Returns
          -------
          flat: array
              This method will return an array the same shape as the image in
              **units of electrons**.