Example #1
0
    def flatten(self, pixel_flat, illum_flat=None, bpm=None, force=False):
        """
        Flat field the proc image

        Wrapper to flat.flatfield

        Args:
            pixel_flat (`numpy.ndarray`_):
                Pixel flat image
            illum_flat (`numpy.ndarray`_, optional):
                Illumination flat image
            bpm (`numpy.ndarray`_, optional):
                Bad pixel mask image;  if provided, over-rides internal one
            force (bool, optional):
                Force the processing even if the image was already processed

        """
        step = inspect.stack()[0][3]
        # Check if already trimmed
        if self.steps[step] and (not force):
            msgs.warn(
                "Image was already flat fielded.  Returning the current image")
            return self.image.copy()
        # Check
        if pixel_flat is None:
            msgs.error("You requested flattening but provided no pixel flat!")
        # BPM
        if bpm is None:
            bpm = self.bpm
        # Do it
        self.image = flat.flatfield(self.image,
                                    pixel_flat,
                                    bpm,
                                    illum_flat=illum_flat)
        self.steps[step] = True
Example #2
0
    def flat_field(self, pixel_flat, bpm, illum_flat=None):
        """
        Flat field the stack image

        pixel_flat and illum_flat are passed here to force users to
        consider that they're needed when calling flat_field().

        Wrapper to arflat.flatfield()

        Returns
        -------
        self.stack : ndarray
          Flat fielded

        """
        # Assign the relevant data to self
        self.pixel_flat = pixel_flat
        self.bpm = bpm
        self.illum_flat = illum_flat

        # Check that the bad-pixel mask is available
        if self.bpm is None:
            msgs.error('No bpm for {0}'.format(self.spectrograph.spectrograph))

        msgs.info("Flat fielding your image")
        # Flat-field the data and return the result

        self.stack = flat.flatfield(self.stack,
                                    self.pixel_flat,
                                    self.bpm,
                                    illum_flat=self.illum_flat)
        return self.stack