Remaps an input WCS Tan Gnomonic projection system to a different target WCS.
magwarp(image_in, header_out = NULL, header_in = NULL, dim_out, direction = "auto",
boundary = "dirichlet", interpolation = "cubic", CRVAL1_in = 0, CRVAL2_in = 0,
CRPIX1_in = 0, CRPIX2_in = 0, CD1_1_in = 1, CD1_2_in = 0, CD2_1_in = 0, CD2_2_in = 1,
CRVAL1_out = 0, CRVAL2_out = 0, CRPIX1_out = 0, CRPIX2_out = 0, CD1_1_out = 1,
CD1_2_out = 0, CD2_1_out = 0, CD2_2_out = 1, plot = FALSE, ...)
Numeric matrix; required, the image we want to remap. If image is a list as created by readFITS
, read.fits
of magcutoutWCS
then the image part of the list is parsed to image and the correct header part is parsed to header_in.
Full FITS header in table or vector format. This is the target WCS projection that image_in will be mapped onto. Legal table format headers are provided by the read.fitshdr
function or the hdr list output of read.fits
in the astro package; the hdr output of readFITS
in the FITSio
package or the header output of magcutoutWCS
. If header_ut is provided then key words will be taken from here as a priority. Missing header keywords are printed out and other header option arguments are used in these cases.
Full FITS header in table or vector format. This should be the header WCS that matches image_in. Legal table format headers are provided by the read.fitshdr
function or the hdr list output of read.fits
in the astro package; the hdr output of readFITS
in the FITSio
package or the header output of magcutoutWCS
. If header_in is provided then key words will be taken from here as a priority. Missing header keywords are printed out and other header option arguments are used in these cases.
Integer vector; this defines the desired dimensions of the output image. If this is not provided then the output image is made to be the same size as the NAXIS1 and NAXIS2 arguments taken from header_out (which is usually what you will want TBH).
"auto" (default), "forward" or "backward", see imwarp
. Since it is usally better to go from the higher resolution image and map this onto the lower resolution grid, "auto" selects the better direction given the pixel scales recovered from the header information.
boundary conditions: "dirichlet", "neumann", "periodic" (efault "dirichlet"), see imwarp
"nearest", "linear", "cubic" (default "linear"), see imwarp
FITS header CRVAL1 for the Tan Gnomonic projection system of the input WCS. This is the RA in degrees at the location of CRPIX1.
FITS header CRVAL2 for the Tan Gnomonic projection system of the input WCS. This is the Dec in degrees at the location of CRPIX2.
FITS header CRPIX1 for the Tan Gnomonic projection system of the input WCS. This is the x pixel value at the location of CRVAL1.
FITS header CRPIX2 for the Tan Gnomonic projection system of the input WCS. This is the y pixel value at the location of CRVAL2.
FITS header CD1_1 for the Tan Gnomonic projection system of the input WCS. Change in RA-Tan in degrees along x-Axis.
FITS header CD1_2 for the Tan Gnomonic projection system of the input WCS. Change in RA-Tan in degrees along y-Axis.
FITS header CD2_1 for the Tan Gnomonic projection system of the input WCS. Change in Dec-Tan in degrees along x-Axis.
FITS header CD2_2 for the Tan Gnomonic projection system of the input WCS. Change in Dec-Tan in degrees along y-Axis.
FITS header CRVAL1 for the Tan Gnomonic projection system of the output WCS. This is the RA in degrees at the location of CRPIX1.
FITS header CRVAL2 for the Tan Gnomonic projection system of the output WCS. This is the Dec in degrees at the location of CRPIX2.
FITS header CRPIX1 for the Tan Gnomonic projection system of the output WCS. This is the x pixel value at the location of CRVAL1.
FITS header CRPIX2 for the Tan Gnomonic projection system of the output WCS. This is the y pixel value at the location of CRVAL2.
FITS header CD1_1 for the Tan Gnomonic projection system of the output WCS. Change in RA-Tan in degrees along x-Axis.
FITS header CD1_2 for the Tan Gnomonic projection system of the output WCS. Change in RA-Tan in degrees along y-Axis.
FITS header CD2_1 for the Tan Gnomonic projection system of the output WCS. Change in Dec-Tan in degrees along x-Axis.
FITS header CD2_2 for the Tan Gnomonic projection system of the output WCS. Change in Dec-Tan in degrees along y-Axis.
Logical; should a magimageWCS
plot of the output be generated?
Dots are parsed to either magimageWCS
(only relevant if plot=TRUE).
A list containing:
Numeric matrix; the remapped image using the target WCS.
The target header_out.
The function allows for arbitrary WCS remapping, as long as the input and output WCS both use the Tan Gnomonic projection system (which is by far the most common with modern survey imaging data). The process internally does the following:
xy2radec; maps the input image to RA and Dec per pixel using the input header
radec2xy; maps the pixel RA and Dec coordinates onto the desired output pixel grid using the output header
There are a few different ways to consider doing pixel remapping (or warping). The main question is usually whether to operate on a forward or backwards manner (see imwarp
). Backwards mapping (the default) finds the best interpolation of every output pixel in the input image, whereas forward mapping finds the best interpolation of every input pixel on the output image. Backwards mapping usually provides the fewest artefacts (hence it is the default), but in general if the input image is higher resolution then you might prefer forward mapping and vica-versa.
The actual warping is done using the imwarp
function in the imager
package, so this will need to be installed prior to use (it is available on CRAN).
# NOT RUN {
VISTA_K=readFITS(system.file("extdata", 'VISTA_K.fits', package="magicaxis"))
VST_r=readFITS(system.file("extdata", 'VST_r.fits', package="magicaxis"))
GALEX_NUV=readFITS(system.file("extdata", 'GALEX_NUV.fits', package="magicaxis"))
magwarp(VST_r, GALEX_NUV$hdr, plot=TRUE)
magwarp(VISTA_K, GALEX_NUV$hdr, plot=TRUE)
magwarp(GALEX_NUV, VST_r$hdr, plot=TRUE)
magwarp(VISTA_K, VST_r$hdr, plot=TRUE)
magwarp(GALEX_NUV, VISTA_K$hdr, plot=TRUE)
magwarp(VST_r, VISTA_K$hdr, plot=TRUE)
# }
Run the code above in your browser using DataLab