Exemplo n.º 1
0
def gwcs_blot(median_model, blot_img, interp='poly5', sinscl=1.0):
    """
    Resample the output/resampled image to recreate an input image based on
    the input image's world coordinate system

    Parameters
    ----------
    median_model : ~jwst.datamodels.DataModel

    blot_img : datamodel
        Datamodel containing header and WCS to define the 'blotted' image

    interp : str, optional
        The type of interpolation used in the resampling. The
        possible values are "nearest" (nearest neighbor interpolation),
        "linear" (bilinear interpolation), "poly3" (cubic polynomial
        interpolation), "poly5" (quintic polynomial interpolation),
        "sinc" (sinc interpolation), "lan3" (3rd order Lanczos
        interpolation), and "lan5" (5th order Lanczos interpolation).

    sincscl : float, optional
        The scaling factor for sinc interpolation.
    """
    blot_wcs = blot_img.meta.wcs

    # Compute the mapping between the input and output pixel coordinates
    pixmap = calc_gwcs_pixmap(blot_wcs, median_model.meta.wcs,
                              blot_img.data.shape)
    log.debug("Pixmap shape: {}".format(pixmap[:, :, 0].shape))
    log.debug("Sci shape: {}".format(blot_img.data.shape))

    pix_ratio = 1
    log.info('Blotting {} <-- {}'.format(blot_img.data.shape,
                                         median_model.data.shape))

    outsci = np.zeros(blot_img.shape, dtype=np.float32)

    # Currently tblot cannot handle nans in the pixmap, so we need to give some
    # other value.  -1 is not optimal and may have side effects.  But this is
    # what we've been doing up until now, so more investigation is needed
    # before a change is made.  Preferably, fix tblot in drizzle.
    pixmap[np.isnan(pixmap)] = -1
    tblot(median_model.data,
          pixmap,
          outsci,
          scale=pix_ratio,
          kscale=1.0,
          interp=interp,
          exptime=1.0,
          misval=0.0,
          sinscl=sinscl)

    return outsci
Exemplo n.º 2
0
def gwcs_blot(median_model, blot_img, interp='poly5', sinscl=1.0):
    """
    Resample the output/resampled image to recreate an input image based on
    the input image's world coordinate system

    Parameters
    ----------
    median_model : ~jwst.datamodels.DataModel

    blot_img : datamodel
        Datamodel containing header and WCS to define the 'blotted' image

    interp : str, optional
        The type of interpolation used in the resampling. The
        possible values are "nearest" (nearest neighbor interpolation),
        "linear" (bilinear interpolation), "poly3" (cubic polynomial
        interpolation), "poly5" (quintic polynomial interpolation),
        "sinc" (sinc interpolation), "lan3" (3rd order Lanczos
        interpolation), and "lan5" (5th order Lanczos interpolation).

    sincscl : float, optional
        The scaling factor for sinc interpolation.
    """
    blot_wcs = blot_img.meta.wcs

    # Compute the mapping between the input and output pixel coordinates
    pixmap = calc_gwcs_pixmap(blot_wcs, median_model.meta.wcs,
                              blot_img.data.shape)
    log.debug("Pixmap shape: {}".format(pixmap[:, :, 0].shape))
    log.debug("Sci shape: {}".format(blot_img.data.shape))

    # median_model_pscale = median_model.meta.wcsinfo.cdelt1
    # blot_pscale = blot_img.meta.wcsinfo.cdelt1

    pix_ratio = 1
    log.info('Blotting {} <-- {}'.format(blot_img.data.shape,
                                         median_model.data.shape))

    outsci = np.zeros(blot_img.shape, dtype=np.float32)
    tblot(median_model.data,
          pixmap,
          outsci,
          scale=pix_ratio,
          kscale=1.0,
          interp=interp,
          exptime=1.0,
          misval=0.0,
          sinscl=sinscl)

    return outsci
Exemplo n.º 3
0
    def extract_image(self, blot_wcs, interp='poly5', sinscl=1.0):
        """
        Resample the output/resampled image to recreate an input image based on 
        the input image's world coordinate system 

        Parameters
        ----------

        blot_wcs : wcs
            The world coordinate system to be used to define the 'blotted' image

        interp : str, optional
            The type of interpolation used in the resampling. The
            possible values are "nearest" (nearest neighbor interpolation),
            "linear" (bilinear interpolation), "poly3" (cubic polynomial
            interpolation), "poly5" (quintic polynomial interpolation),
            "sinc" (sinc interpolation), "lan3" (3rd order Lanczos
            interpolation), and "lan5" (5th order Lanczos interpolation).

        sincscl : float, optional
            The scaling factor for sinc interpolation.
        """
        blot_shape = resample_utils.build_size_from_domain(blot_wcs.domain)
        _outsci = np.zeros((blot_shape[1], blot_shape[0]), dtype=np.float32)

        # Compute the mapping between the input and output pixel coordinates
        #log.info("Creating PIXMAP for blotted image...")
        pixmap = resample_utils.calc_gwcs_pixmap(self.source_wcs, blot_wcs)

        source_pscale = self.source_wcs.forward_transform[
            'cdelt1'].factor.value
        blot_pscale = blot_wcs.forward_transform['cdelt1'].factor.value

        pix_ratio = source_pscale / blot_pscale
        #log.info("Starting blot...")
        cdrizzle.tblot(self.source,
                       pixmap,
                       _outsci,
                       scale=pix_ratio,
                       kscale=1.0,
                       interp=interp,
                       exptime=1.0,
                       misval=0.0,
                       sinscl=sinscl)

        return _outsci
Exemplo n.º 4
0
    def extract_image(self, blot_img, interp='poly5', sinscl=1.0):
        """
        Resample the output/resampled image to recreate an input image based on
        the input image's world coordinate system

        Parameters
        ----------

        blot_img : datamodel
            Datamodel containing header and WCS to define the 'blotted' image

        interp : str, optional
            The type of interpolation used in the resampling. The
            possible values are "nearest" (nearest neighbor interpolation),
            "linear" (bilinear interpolation), "poly3" (cubic polynomial
            interpolation), "poly5" (quintic polynomial interpolation),
            "sinc" (sinc interpolation), "lan3" (3rd order Lanczos
            interpolation), and "lan5" (5th order Lanczos interpolation).

        sincscl : float, optional
            The scaling factor for sinc interpolation.
        """
        blot_wcs = blot_img.meta.wcs
        outsci = np.zeros(blot_img.shape, dtype=np.float32)

        # Compute the mapping between the input and output pixel coordinates
        pixmap = resample_utils.calc_gwcs_pixmap(blot_wcs, self.source_wcs,
            outsci.shape)
        log.debug("Pixmap shape: {}".format(pixmap[:, :, 0].shape))
        log.debug("Sci shape: {}".format(outsci.shape))

        source_pscale = self.source_model.meta.wcsinfo.cdelt1
        blot_pscale = blot_img.meta.wcsinfo.cdelt1

        pix_ratio = source_pscale / blot_pscale
        log.info('Blotting {} <-- {}'.format(outsci.shape, self.source.shape))
        tblot(self.source, pixmap, outsci, scale=pix_ratio, kscale=1.0,
                       interp=interp, exptime=1.0, misval=0.0, sinscl=sinscl)

        return outsci
Exemplo n.º 5
0
    def extract_image(self, blot_img, interp='poly5', sinscl=1.0):
        """
        Resample the output/resampled image to recreate an input image based on
        the input image's world coordinate system

        Parameters
        ----------

        blot_img : datamodel
            Datamodel containing header and WCS to define the 'blotted' image

        interp : str, optional
            The type of interpolation used in the resampling. The
            possible values are "nearest" (nearest neighbor interpolation),
            "linear" (bilinear interpolation), "poly3" (cubic polynomial
            interpolation), "poly5" (quintic polynomial interpolation),
            "sinc" (sinc interpolation), "lan3" (3rd order Lanczos
            interpolation), and "lan5" (5th order Lanczos interpolation).

        sincscl : float, optional
            The scaling factor for sinc interpolation.
        """
        blot_wcs = blot_img.meta.wcs
        blot_shape = resample_utils.build_size_from_domain(blot_wcs.domain)
        outsci = np.zeros((blot_shape[0], blot_shape[1]), dtype=np.float32)

        # Compute the mapping between the input and output pixel coordinates
        #log.info("Creating PIXMAP for blotted image...")
        pixmap = resample_utils.calc_gwcs_pixmap(self.source_wcs, blot_wcs)

        source_pscale = self.source_model.meta.wcsinfo.cdelt1
        blot_pscale = blot_img.meta.wcsinfo.cdelt1

        pix_ratio = source_pscale / blot_pscale
        #log.info("Starting blot...")
        cdrizzle.tblot(self.source, pixmap, outsci, scale=pix_ratio, kscale=1.0,
                       interp=interp, exptime=1.0, misval=0.0, sinscl=sinscl)

        return outsci