>  Docs Center  >  Libraries  >  ASTROLIB  >  XYAD






      Use a FITS header to convert pixel (X,Y) to world coordinates


      Use astrometry in a FITS image header to compute world
      coordinates in decimal degrees from X and Y.
      If spherical coordinates (Calabretta & Greisen 2002, A&A, 395, 1077) are
      not present, then XYAD will still perform the transformation specified
      by the CD, CRVAL, and CRPIX keywords.

Calling Sequence

      XYAD, HDR ;Prompt for X and Y positions
      XYAD, HDR, X, Y, A, D, [ /PRINT, /Galactic, /Celestial, /Ecliptic,
                                ALT =, PRECISION=]


      HDR - FITS Image header containing astrometry info

Optional Inputs

      X - row position in pixels, scalar or vector
      Y - column position in pixels, scalar or vector
      X and Y should be in IDL convention, (first pixel is (0,0) where
      the integral value corresponds to the center of the pixel.)

Optional Output

      A - Output longitude in decimal DEGREES (for spherical coordinates),
              same number of elements as X and Y. For celestial
              coordinates, this is the Right ascension.
      D - Output latitude in decimal DEGREES. For celestial coordinates,
              this is the declination.

Optional Keyword Input

      ALT - single character 'A' through 'Z' or ' ' specifying an alternate
            astrometry system present in the FITS header. The default is
            to use the primary astrometry or ALT = ' '. If /ALT is set,
            then this is equivalent to ALT = 'A'. See Section 3.3 of
            Greisen & Calabretta (2002, A&A, 395, 1061) for information about
            alternate astrometry keywords.
      PRECISION - Integer scalar (0-4) specifying the number of digits
            displayed after the decimal of declination. The RA is
            automatically one digit more. See ADSTRING() for more info.
            Default value is 1, and the keyword is ignored if results are not
            displayed at the terminal
      /PRINT - If this keyword is set and non-zero, then results are displayed
              at the terminal.in both decimal and sexagesimal notation.
      The default for XYAD is to return the coordinate system present in
      in the FITS header. However, the following mutually exclusive
      keywords can be used to convert to a particular coordinate system:
      /CELESTIAL - Output is Right Ascension and declination
      /ECLIPTIC - Output is Ecliptic longitude and latitude
      /GALACTIC - Output is Galactic longitude and latitude
                  Celestial & Ecliptic coords depend on the reference
                  equinox, set to either B1950 (=FK4) or J2000 (=FK5,ICRS)
                  according to the header or standard FITS WCS defaults.
                  Note that astrometry at the sub-arcsec level requires
                  fine distinctions that are not handled here.

Operational Notes

      If less than 5 parameters are supplied, or if the /PRINT keyword is
      set, then the computed astronomical coordinates are displayed at the
      If this procedure is to be used repeatedly with the same header,
      then it would be faster to use XY2AD.


      A FITS header, hdr, contains astrometric information in celestial
      coordinates. Find the RA and Dec corresponding to position X=23.3
        Y = 100.2 on an image
        IDL> xyad, hdr, 23.3, 100.2 ;Displays results at the terminal
      To display the results in Galactic coordinates
        IDL> xyad, hdr, 23.3, 100.2, /GALACTIC

Procedures Called


Revision History

      W. Landsman STX Jan, 1988
      Use astrometry structure W. Landsman Jan, 1994
      Recognize GSSS header W. Landsman June, 1994
      Changed ADSTRING output format W. Landsman September 1995
      Converted to IDL V5.0 W. Landsman September 1997
      Use vector call to ADSTRING() W. Landsman February 2000
      Added ALT input keyword W. Landsman June 2003
      Add precision keyword W. Landsman February 2004
      Fix display if 'RA','DEC' reversed in CTYPE W. Landsman Feb. 2004
      Handle display of NaN values W. Landsman May 2004
      Work for non-spherical coordinate transformations W. Landsman Oct 2004
      Fix output display units if ALT keyword used W. Landsman March 2005
      More informative error message if no astrometry present W.L Nov 2007
      Fix display when no equinox in header W.L. Dec 2007
      Fix header display for noncelestial coords W.L. Jan 2008
      Check for non-standard projections, set FK4 flag. J. P. Leahy Jul 2013

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us