Ejemplo n.º 1
0
def read_wcs(filename):
    """
    Read the wcs of a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    with fits.open(fileroot) as hdulist:
        the_wcs = wcs.WCS(hdulist[1].header)
    return the_wcs
Ejemplo n.º 2
0
def read_header(filename):
    """
    Read the primary header from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    with fits.open(fileroot) as hdulist:
        header = hdulist[0].header
    return header
Ejemplo n.º 3
0
def read_image(filename):
    """
    Read the image from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    with fits.open(fileroot, memmap=False) as hdulist:
        data = hdulist[1].data.copy()
    return data
Ejemplo n.º 4
0
def read_wcs(filename):
    """
    Read the wcs of a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    the_wcs = wcs.WCS(hdu[1].header)
    hdu.close()
    return the_wcs
Ejemplo n.º 5
0
def read_image(filename):
    """
    Read the image from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    image = hdu[1].data
    hdu.close()
    return image
Ejemplo n.º 6
0
def read_header(filename):
    """
    Read the primary header from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    header = hdu[0].header
    hdu.close()
    return header
Ejemplo n.º 7
0
def read_wcs(filename):
    """
    Read the wcs of a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    the_wcs = wcs.WCS(hdu[1].header)
    hdu.close()
    return the_wcs
Ejemplo n.º 8
0
def read_image(filename):
    """
    Read the image from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    image = hdu[1].data
    hdu.close()
    return image
Ejemplo n.º 9
0
def read_header(filename):
    """
    Read the primary header from a fits file
    """
    fileroot, extn = util.parse_filename(os.path.join(DATA_DIR, filename))
    hdu = fits.open(fileroot)

    header = hdu[0].header
    hdu.close()
    return header
Ejemplo n.º 10
0
    def blot_fits_file(self, infile, interp='poly5', sinscl=1.0):
        """
        Resample the output using another image's world coordinate system.

        Parameters
        ----------

        infile : str
            The name of the fits file containing the world coordinate
            system that the output file will be resampled to. The name may
            possibly include an extension.

        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.
        """
        blotwcs = None

        fileroot, extn = util.parse_filename(infile)

        if os.path.exists(fileroot):
            handle = fits.open(fileroot)
            hdu = util.get_extn(handle, extn=extn)

            if hdu is not None:
                blotwcs = wcs.WCS(header=hdu.header)
            handle.close()

        if not blotwcs:
            raise ValueError("Drizzle did not get a blot reference image")

        self.blot_image(blotwcs, interp=interp, sinscl=sinscl)
Ejemplo n.º 11
0
    def blot_fits_file(self, infile, interp='poly5', sinscl=1.0):
        """
        Resample the output using another image's world coordinate system.

        Parameters
        ----------

        infile : str
            The name of the fits file containing the world coordinate
            system that the output file will be resampled to. The name may
            possibly include an extension.

        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.
        """
        blotwcs = None

        fileroot, extn = util.parse_filename(infile)

        if os.path.exists(fileroot):
            handle = fits.open(fileroot)
            hdu = util.get_extn(handle, extn=extn)

            if hdu is not None:
                blotwcs = wcs.WCS(header=hdu.header)
            handle.close()

        if not blotwcs:
            raise ValueError("Drizzle did not get a blot reference image")

        self.blot_image(blotwcs, interp=interp, sinscl=sinscl)