These functions add various WCS information to R images. It is particularly designed to work in unison with magimage that is used extensively in the wider ProFit package.
magimageWCS(image, header, n, grid.col = "grey", grid.lty = 2, grid.lwd = 0.5,
lab.col = "green", coord.type = "sex", margin = TRUE, loc.diff = c(0, 0),
xlab = "Right Ascension", ylab = "Declination", mgp = c(2, 0.5, 0), mtline = 2,
position = "topright", com.col = "green", com.length = 0.05, coord.axis='auto',
pretty= 'auto', CRVAL1 = 0, CRVAL2 = 0, CRPIX1 = 0, CRPIX2 = 0, CD1_1 = 1, CD1_2 = 0,
CD2_1 = 0, CD2_2 = 1, ...)magimageWCSRGB(R, G, B, header_out, Rheader, Gheader, Bheader, direction = "auto",
boundary = "dirichlet", interpolation = "cubic", n, grid.col='grey', grid.lty=2,
grid.lwd=0.5, lab.col='green', coord.type='sex', margin=TRUE, loc.diff=c(0,0),
xlab='Right Ascension', ylab='Declination', mgp=c(2,0.5,0), mtline=2, position='topright',
com.col="green", com.length=0.05, coord.axis='auto', pretty='auto', CRVAL1=0, CRVAL2=0,
CRPIX1=0, CRPIX2=0, CD1_1=1, CD1_2=0, CD2_1=0, CD2_2=1, ...)
magimageWCSGrid(header, n, grid.col = "grey", grid.lty = 1, grid.lwd = 1,
coord.type = "sex", loc.diff = c(0, 0), pretty= 'auto', CRVAL1 = 0, CRVAL2 = 0,
CRPIX1 = 0, CRPIX2 = 0, CD1_1 = 1, CD1_2 = 0, CD2_1 = 0, CD2_2 = 1, ...)
magimageWCSLabels(header, n, lab.col = "green", coord.type = "sex", margin = TRUE,
loc.diff = c(0, 0), xlab = "Right Ascension", ylab = "Declination", mgp = c(2, 0.5, 0),
mtline = 2, coord.axis='auto', pretty= 'auto', CRVAL1 = 0, CRVAL2 = 0, CRPIX1 = 0,
CRPIX2 = 0, CD1_1 = 1, CD1_2 = 0, CD2_1 = 0, CD2_2 = 1, ...)
magimageWCSCompass(header, position = "topright", com.col = "green", com.length = 0.05,
loc.diff = c(0, 0), CRVAL1 = 0, CRVAL2 = 0, CRPIX1 = 0, CRPIX2 = 0, CD1_1 = 1, CD1_2 = 0,
CD2_1 = 0, CD2_2 = 1, ...)
Numeric matrix; required, the image we want to decorate. 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.
Full FITS header in table or vector format. 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 a header 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.
Numeric matrix; containing the red colour values to be plotted (NAs are allowed). If R is a list as created by readFITS
, read.fits
of magcutoutWCS
then the image part of the list is parsed to R and the correct header part is parsed to Rheader.
Numeric matrix; containing the green colour values to be plotted (NAs are allowed). If G is a list as created by readFITS
, read.fits
of magcutoutWCS
then the image part of the list is parsed to G and the correct header part is parsed to Gheader.
Numeric matrix; containing the blue colour values to be plotted (NAs are allowed). If B is a list as created by readFITS
, read.fits
of magcutoutWCS
then the image part of the list is parsed to B and the correct header part is parsed to Bheader.
Full FITS header in table or vector format. This is the target WCS projection that the RGB image 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 a header 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 R FITS header in table or vector format. It is usually easier to include the header with the R list input as described above.
Full G FITS header in table or vector format. It is usually easier to include the header with the G list input as described above.
Full B FITS header in table or vector format. It is usually easier to include the header with the B list input as described above.
Only used if re-mapping via magwarp
. "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.
Only used if re-mapping via magwarp
. Boundary conditions: "dirichlet", "neumann", "periodic" (default "dirichlet"), see imwarp
Only used if re-mapping via magwarp
. "nearest", "linear", "cubic" (default "linear"), see imwarp
The target number of major-axis sub-divisions. Will not necessarily be achieved.
The colour of the overlaid grid lines.
The line type of the overlaid grid lines.
The line width of the overlaid grid lines.
The colour of the labels when margin=FALSE.
Should the labels be drawn using degrees (deg) or colon delimited sexigesimal (sex).
Should the labels be drawn in the outer margin region (default).
The pixel offset to apply. Only relevant if the image being plotted is a cutout from within a FITS legal image.
x axis name. If left as default either H:M:S or D:M:S (coord.type='sex') or deg (coord.type='deg') will be appended.
y axis name. If left as default either H:M:S or D:M:S (coord.type='sex') or deg (coord.type='deg') will be appended.
The margin line (in mex units) for the axis title, axis labels and axis line. This has different (i.e. prettier) defaults than R of c(2,0.5,0) rather than c(3,1,0). This pushes the numbers and labels nearer to the plot compared to the defaults. For margin=FALSE mgp = -mgp - 3, which has the effect of shifting the tick labels nicely inside the margin.
Number of lines separating axis name from axis. For margin=FALSE mtline = -mtline, which has the effect of shifting the axis labels nicely inside the margin.
Integer vector; specifies whether the RA and Dec axes should be 1 or 2 (i.e. x or y axis). The default 'auto' tries to guess based on the header information (and this usually works okay). Otherwise coord.axis=c(1,2) would be sensible for a N/S vertical aligend frame and coord.axis=c(2,1) would be sensible for a E/W vertically aligned frame. When the orientation is between the two then it is not always obvious which will work better.
If 'auto' then it will try to compute the prettiest grid and label scaling *usually this is pretty good). Otherwise set to 1 to be degrees major ticks, 60 for minutes (DMS or HMS) and 3600 for seconds (DMS or HMS).
Relative position of the compass bar. This argument is used like the 'legend' function. Specify one of 'bottom', 'bottomleft', 'left', 'topleft', 'top', 'topright', 'right', 'bottomright' and 'centre'.
Colour of the compass.
Length of the edges of the arrow head.
FITS header CRVAL1 for the Tan Gnomonic projection system. This is the RA in degrees at the location of CRPIX1.
FITS header CRVAL2 for the Tan Gnomonic projection system. This is the Dec in degrees at the location of CRPIX2.
FITS header CRPIX1 for the Tan Gnomonic projection system. This is the x pixel value at the location of CRVAL1.
FITS header CRPIX2 for the Tan Gnomonic projection system. This is the y pixel value at the location of CRVAL2.
FITS header CD1_1 for the Tan Gnomonic projection system. Change in RA-Tan in degrees along x-Axis.
FITS header CD1_2 for the Tan Gnomonic projection system. Change in RA-Tan in degrees along y-Axis.
FITS header CD2_1 for the Tan Gnomonic projection system. Change in Dec-Tan in degrees along x-Axis.
FITS header CD2_2 for the Tan Gnomonic projection system. Change in Dec-Tan in degrees along y-Axis.
These are parsed to magimage
, (magimageWCS
), magimageRGB
, (magimageWCSRGB
), lines
(magimageWCSGrid
), axis
(magimageWCSLabels
) or arrows
(magimageWCSCompass
).
Outputs the final image list containing x,y and z (magimageWCS
) or R/G/B (magimageWCSRGB
). Generally run for the side effect of producing rapid and well-scaled image plots.
Most people will be content to use the higher level magimageWCS
function, which calls (in order) magimage
, magimageWCSGrid
, magimageWCSLabels
and magimageWCSCompass
.
magimageWCSRGB
can be used in a few different ways, but the recommended route is to supply combined image and header list objects to the R, G and B arguments. If header_out is not supplied then by default it will project the three images onto the first available WCS header it finds searching R, G and B in order. If you are happy to map the colour image into the R WCS then you do not need to supply header_out at all. Note if image remapping is required (the images are different sizes or the headers differ) then the imager
library will need to be installed in order to use magwarp
.
# NOT RUN {
image=readFITS(system.file("extdata", 'VIKING/mystery_VIKING_Z.fits', package="ProFit"))
#Convenient image plotting for lists containing headers:
magimageWCS(image$imDat, header=image$hdr)
magimageWCS(image)
#First using the outer margins for tick labels:
par(mar=c(3.1,3.1,1.1,1.1))
magimageWCS(image)
magimageWCS(image, coord.type='deg')
#Now removing the margins and putting labels inside the image:
par(mar=c(0,0,0,0))
magimageWCS(image, margin=FALSE)
magimageWCS(image, margin=FALSE, coord.type='deg')
#We can make a WCS colour image of mismatched images:
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"))
magimageWCSRGB(VISTA_K, VST_r, GALEX_NUV)
magimageWCSRGB(VISTA_K, VST_r, GALEX_NUV, saturation=0.5)
magimageWCSRGB(VISTA_K, VST_r, GALEX_NUV, VISTA_K$hdr)
magimageWCSRGB(VISTA_K, VST_r, GALEX_NUV, VST_r$hdr)
magimageWCSRGB(VISTA_K, VST_r, GALEX_NUV, GALEX_NUV$hdr)
# }
Run the code above in your browser using DataLab