Learn R Programming

celestial (version 1.4.6)

skyproj: Tan Gnomonic and Sine Orthographic Projection System WCS Solver Functions

Description

Converts RA/Dec (degrees) to x/y (pixels) position using the Tan Gnomonic or Sine Orthographic projection systems, and vice-versa. Translations adapted from: http://mathworld.wolfram.com/GnomonicProjection.html and http://mathworld.wolfram.com/OrthographicProjection.html.

Usage

radec2xy(RA, Dec, header, CRVAL1 = 0, CRVAL2 = 0, CRPIX1 = 0, CRPIX2 = 0, CD1_1 = 1,
CD1_2 = 0, CD2_1 = 0, CD2_2 = 1, CTYPE1 = 'RA--TAN', CTYPE2 = 'DEC--TAN')
xy2radec(x, y, header, CRVAL1 = 0, CRVAL2 = 0, CRPIX1 = 0, CRPIX2 = 0, CD1_1 = 1,
CD1_2 = 0, CD2_1 = 0, CD2_2 = 1, CTYPE1 = 'RA--TAN', CTYPE2 = 'DEC--TAN')

Arguments

RA

Vector or matrix; target right ascension in degrees. If matrix then the first column will be used as RA and the second column as Dec.

Dec

Vector; target declination in degrees. Ignored if RA is a matrix.

x

Vector or matrix; target x-pixel. If Matrix then the first column will be used as the x-axis and the second column as y-axis.

y

Vector; target y-pixel. Ignored if x is a matrix.

CRVAL1

FITS header CRVAL1 for the CTYPE1 projection system. This is the RA in degrees at the location of CRPIX1.

CRVAL2

FITS header CRVAL2 for the CTYPE2 projection system. This is the Dec in degrees at the location of CRPIX2.

CRPIX1

FITS header CRPIX1 for the CTYPE1 projection system. This is the x pixel value at the location of CRVAL1.

CRPIX2

FITS header CRPIX2 for the CTYPE2 projection system. This is the y pixel value at the location of CRVAL2.

CD1_1

FITS header CD1_1 for the CTYPE1 projection system. Change in CTYPE1 in degrees along x-Axis.

CD1_2

FITS header CD1_2 for the CTYPE1 projection system. Change in CTYPE1 in degrees along y-Axis.

CD2_1

FITS header CD2_1 for the CTYPE2 projection system. Change in CTYPE2 in degrees along x-Axis.

CD2_2

FITS header CD2_2 for the CTYPE2 projection system. Change in CTYPE2 in degrees along y-Axis.

CTYPE1

The RA projection system type. Either 'RA--TAN' for Tan Gnomonic (default), or 'RA--SIN' for Sine Orthographic. 'RA--NCP' is approximated by Sine Orthographic with a warning. Over-ridden by the FITS header.

CTYPE2

The DEC projection system type. Either 'DEC--TAN' for Tan Gnomonic (default), or 'DEC--SIN' for Sine Orthographic. 'DEC--NCP' is approximated by Sine Orthographic with a warning. Over-ridden by the FITS header.

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). Also the hdr output of readFITS in the FITSio package provides legal vector format inputs. 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.

Value

radec2xy

Returns a two column matrix with columns x and y.

xy2radec

Returns a two column matrix with columns RA and Dec (in degrees).

Details

These functions encode the standard FITS Tan Gnomonic and Sine Orthographic projection systems for solving an image WCS (covering most moden imaging and radio data). They do not deal with higher order polynomial distortion terms.

References

http://mathworld.wolfram.com/GnomonicProjection.html http://mathworld.wolfram.com/OrthographicProjection.html

See Also

deg2dms, deg2hms, dms2deg, hms2deg

Examples

Run this code
# NOT RUN {
#A simple example:

radec2xy(10, 20)
xy2radec(radec2xy(10, 20))
xy2radec(radec2xy(10, 20, CTYPE1='RA--SIN', CTYPE2='DEC--SIN'),
CTYPE1='RA--SIN',CTYPE2='DEC--SIN')

#A more complicated example, where we transform and rotate large amounts:

exdata_start=expand.grid(1:10,21:30)
plot(exdata_start)
exradec=radec2xy(exdata_start, CRVAL1=20, CRPIX1=100, CRVAL2=30, CRPIX2=130, CD1_1=0.1,
CD1_2=-0.05, CD2_1=0.05, CD2_2=0.1)
plot(exradec)
exdata_end=xy2radec(exradec, CRVAL1=20, CRPIX1=100, CRVAL2=30, CRPIX2=130, CD1_1=0.1,
CD1_2=-0.05, CD2_1=0.05, CD2_2=0.1)
plot(exdata_start,cex=2)
points(exdata_end,col='red')

#The residuals should be very small (in the noice of double precision arithmetic):

plot(density(exdata_start[,1]-exdata_end[,1]))
lines(density(exdata_start[,2]-exdata_end[,2]),col='red')
# }

Run the code above in your browser using DataLab