jsky.coords
Class WCSTransform

java.lang.Object
  extended by jsky.coords.WCSTransform
All Implemented Interfaces:
WorldCoordinateConverter

public class WCSTransform
extends java.lang.Object
implements WorldCoordinateConverter

A port of pieces of the WCSTools library version 2.6, originally written in C. WCSTranform is the main class. It can construct a proper transform using a WCSKeywordProvider object. The methods pix2wcs and wcs2pix do the actual conversions between image pixel values and WCS coordinates.

In porting the code to Java, I attempted to change as little as possible, hoping that this would make it easier to keep up-to-date with the C version.

See the WCSTools page for more information.

Original file:
libwcs/wcs.c
February 6, 1998
By Doug Mink, Harvard-Smithsonian Center for Astrophysics

This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project.

Version:
$Revision: 1.2 $
Author:
J. Jones / 588, A. Brighton (changes for JSky)

Field Summary
static java.lang.String NO_WCS_IN_HEADER_MESSAGE
          Message if header does not contain a valid World Coordinate System
 
Constructor Summary
WCSTransform(double cra, double cdec, double xsecpix, double ysecpix, double xrpix, double yrpix, int nxpix, int nypix, double rotate, int equinox, double epoch, java.lang.String proj)
          Constructs a new WCSTransform.
WCSTransform(WCSKeywordProvider head)
          Constructs a new WCSTransform using data from the specified FITS Header.
 
Method Summary
static double deghr(double x)
           
static double degrad(double x)
          Conversions among hours of RA, degrees and radians.
 double getEquinox()
          Return the equinox used for coordinates (usually the equionx of the image)
 double getHeight()
          Return the image height in pixels.
 double getHeightInDeg()
          return the height in deg
 java.awt.geom.Point2D.Double getImageCenter()
          Return the center coordinates in image pixels.
 java.awt.geom.Point2D.Double getWCSCenter()
          Return the center RA,DEC coordinates in deg.
 double getWidth()
          Return the image width in pixels.
 double getWidthInDeg()
          return the width in deg
static double hrdeg(double x)
           
static double hrrad(double x)
           
 void imageToWorldCoords(java.awt.geom.Point2D.Double p, boolean isDistance)
          Convert the given image coordinates to world coordinates degrees in the equinox of the current image.
 boolean isValid()
           
 boolean isWCS()
          Return true if world coordinates conversion is available.
 java.awt.geom.Point2D.Double pix2wcs(double xpix, double ypix)
          Converts pixel coordinates to World Coordinates.
static double raddeg(double x)
           
static double radhr(double x)
           
 java.awt.geom.Point2D.Double wcs2pix(double xpos, double ypos)
          Converts World Coordinates to pixel coordinates.
 double wcsdist(double x1, double y1, double x2, double y2)
          Compute distance in degrees between two sky coordinates (RA,Dec) or (Long,Lat) in degrees
 void wcseq(WCSKeywordProvider head)
           
protected  void wcsfull()
          Set the RA and Dec of the image center, plus size in degrees
 void wcsshift(double rra, double rdec, java.lang.String coorsys)
          Reset the center of a WCS structure.
 void wcssize()
          Return RA and Dec of image center, plus size in RA and Dec
 void worldToImageCoords(java.awt.geom.Point2D.Double p, boolean isDistance)
          Convert the given world coordinates (degrees, in the equinox of the current image) to image coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_WCS_IN_HEADER_MESSAGE

public static final java.lang.String NO_WCS_IN_HEADER_MESSAGE
Message if header does not contain a valid World Coordinate System

Constructor Detail

WCSTransform

public WCSTransform(WCSKeywordProvider head)
Constructs a new WCSTransform using data from the specified FITS Header.

Parameters:
head - provides the required WCS keywords and associated values
Throws:
java.lang.IllegalArgumentException - if the header does not contain a valid World Coordinate System.

WCSTransform

public WCSTransform(double cra,
                    double cdec,
                    double xsecpix,
                    double ysecpix,
                    double xrpix,
                    double yrpix,
                    int nxpix,
                    int nypix,
                    double rotate,
                    int equinox,
                    double epoch,
                    java.lang.String proj)
Constructs a new WCSTransform.

Parameters:
cra - Center right ascension in degrees
cdec - Center declination in degrees
xsecpix - Number of arcseconds per pixel along x-axis
ysecpix - Number of arcseconds per pixel along y-axis
xrpix - Reference pixel X coordinate
yrpix - Reference pixel Y coordinate
nxpix - Number of pixels along x-axis
nypix - Number of pixels along y-axis
rotate - Rotation angle (clockwise positive) in degrees
equinox - Equinox of coordinates, 1950 and 2000 supported
epoch - Epoch of coordinates, used for FK4/FK5 conversion no effect if 0
proj - Projection
Method Detail

degrad

public static double degrad(double x)
Conversions among hours of RA, degrees and radians.


raddeg

public static double raddeg(double x)

hrdeg

public static double hrdeg(double x)

deghr

public static double deghr(double x)

hrrad

public static double hrrad(double x)

radhr

public static double radhr(double x)

getEquinox

public double getEquinox()
Return the equinox used for coordinates (usually the equionx of the image)

Specified by:
getEquinox in interface WorldCoordinateConverter

getWCSCenter

public java.awt.geom.Point2D.Double getWCSCenter()
Return the center RA,DEC coordinates in deg.

Specified by:
getWCSCenter in interface WorldCoordinateConverter

getImageCenter

public java.awt.geom.Point2D.Double getImageCenter()
Return the center coordinates in image pixels.

Specified by:
getImageCenter in interface WorldCoordinateConverter

isWCS

public boolean isWCS()
Return true if world coordinates conversion is available. This method should be called to check before calling any of the world coordinates conversion methods.

Specified by:
isWCS in interface WorldCoordinateConverter

imageToWorldCoords

public void imageToWorldCoords(java.awt.geom.Point2D.Double p,
                               boolean isDistance)
Convert the given image coordinates to world coordinates degrees in the equinox of the current image.

Specified by:
imageToWorldCoords in interface WorldCoordinateConverter
Parameters:
p - The point to convert.
isDistance - True if p should be interpreted as a distance instead of a point.

worldToImageCoords

public void worldToImageCoords(java.awt.geom.Point2D.Double p,
                               boolean isDistance)
Convert the given world coordinates (degrees, in the equinox of the current image) to image coordinates.

Specified by:
worldToImageCoords in interface WorldCoordinateConverter
Parameters:
p - The point to convert.
isDistance - True if p should be interpreted as a distance instead of a point.

getWidthInDeg

public double getWidthInDeg()
return the width in deg

Specified by:
getWidthInDeg in interface WorldCoordinateConverter

getHeightInDeg

public double getHeightInDeg()
return the height in deg

Specified by:
getHeightInDeg in interface WorldCoordinateConverter

getWidth

public double getWidth()
Return the image width in pixels.

Specified by:
getWidth in interface WorldCoordinateConverter

getHeight

public double getHeight()
Return the image height in pixels.

Specified by:
getHeight in interface WorldCoordinateConverter

wcseq

public void wcseq(WCSKeywordProvider head)

isValid

public boolean isValid()

wcsshift

public void wcsshift(double rra,
                     double rdec,
                     java.lang.String coorsys)
Reset the center of a WCS structure.

Parameters:
rra - Reference pixel right ascension in degrees
rdec - Reference pixel declination in degrees
coorsys - FK4 or FK5 coordinates (1950 or 2000)

wcssize

public void wcssize()
Return RA and Dec of image center, plus size in RA and Dec


wcsfull

protected void wcsfull()
Set the RA and Dec of the image center, plus size in degrees


wcsdist

public double wcsdist(double x1,
                      double y1,
                      double x2,
                      double y2)
Compute distance in degrees between two sky coordinates (RA,Dec) or (Long,Lat) in degrees


pix2wcs

public java.awt.geom.Point2D.Double pix2wcs(double xpix,
                                            double ypix)
Converts pixel coordinates to World Coordinates. Returns null if the WCSTransform is not valid.


wcs2pix

public java.awt.geom.Point2D.Double wcs2pix(double xpos,
                                            double ypos)
Converts World Coordinates to pixel coordinates. Returns null if the WCSTransform is invalid, or if the WCS position does not fall within the image.