1 /*** File libwcs/wcs.h
2  *** June 23, 2016
3  *** By Jessica Mink, jmink@cfa.harvard.edu
4  *** Harvard-Smithsonian Center for Astrophysics
5  *** Copyright (C) 1994-2016
6  *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
7 
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2 of the License, or (at your option) any later version.
12 
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 
22     Correspondence concerning WCSTools should be addressed as follows:
23            Internet email: jmink@cfa.harvard.edu
24            Postal address: Jessica Mink
25                            Smithsonian Astrophysical Observatory
26                            60 Garden St.
27                            Cambridge, MA 02138 USA
28  */
29 
30 #ifndef _wcs_h_
31 #define _wcs_h_
32 
33 #include "wcslib.h"
34 #include "fitshead.h"
35 
36 #define MAXNKWD	500
37 
38 /* SIRTF distortion matrix coefficients */
39 #define DISTMAX 10
40 struct Distort {
41   int    a_order;                /* max power for the 1st dimension */
42   double a[DISTMAX][DISTMAX];  /* coefficient array of 1st dimension */
43   int    b_order;                /* max power for 1st dimension */
44   double b[DISTMAX][DISTMAX];  /* coefficient array of 2nd dimension */
45   int    ap_order;               /* max power for the 1st dimension */
46   double ap[DISTMAX][DISTMAX]; /* coefficient array of 1st dimension */
47   int    bp_order;               /* max power for 1st dimension */
48   double bp[DISTMAX][DISTMAX]; /* coefficient array of 2nd dimension */
49 };
50 
51 struct WorldCoor {
52   double	xref;		/* X reference coordinate value (deg) */
53   double	yref;		/* Y reference coordinate value (deg) */
54   double	xrefpix;	/* X reference pixel */
55   double	yrefpix;	/* Y reference pixel */
56   double	xinc;		/* X coordinate increment (deg) */
57   double	yinc;		/* Y coordinate increment (deg) */
58   double	rot;		/* rotation around axis (deg) (N through E) */
59   double	cd[4];		/* rotation matrix */
60   double	dc[4];		/* inverse rotation matrix */
61   double	equinox;	/* Equinox of coordinates default to 1950.0 */
62   double	epoch;		/* Epoch of coordinates default to equinox */
63   double	nxpix;		/* Number of pixels in X-dimension of image */
64   double	nypix;		/* Number of pixels in Y-dimension of image */
65   double	plate_ra;	/* Right ascension of plate center */
66   double	plate_dec;	/* Declination of plate center */
67   double	plate_scale;	/* Plate scale in arcsec/mm */
68   double	x_pixel_offset;	/* X pixel offset of image lower right */
69   double	y_pixel_offset;	/* Y pixel offset of image lower right */
70   double	x_pixel_size;	/* X pixel_size */
71   double	y_pixel_size;	/* Y pixel_size */
72   double	ppo_coeff[6];	/* pixel to plate coefficients for DSS */
73   double	x_coeff[20];	/* X coefficients for plate model */
74   double	y_coeff[20];	/* Y coefficients for plate model */
75   double	xpix;		/* X (RA) coordinate (pixels) */
76   double	ypix;		/* Y (dec) coordinate (pixels) */
77   double	zpix;		/* Z (face) coordinate (pixels) */
78   double	xpos;		/* X (RA) coordinate (deg) */
79   double	ypos;		/* Y (dec) coordinate (deg) */
80   double	crpix[9];	/* Values of CRPIXn keywords */
81   double	crval[9];	/* Values of CRVALn keywords */
82   double	cdelt[9];	/* Values of CDELTn keywords */
83   double	pc[81];		/* Values of PCiiijjj keywords */
84   double	projp[10];	/* Constants for various projections */
85   int		pvfail;		/* If non-zero, significant inaccuracy likely to occur in projection */
86   double	projppv[2*MAXPV]; /* SCAMP constants for the PV coordinates */
87   struct poly	*inv_x;		/* SCAMP projection correction polynom in x */
88   struct poly	*inv_y;		/* SCAMP projection correction polynom in y */
89   double	longpole;	/* Longitude of North Pole in degrees */
90   double	latpole;	/* Latitude of North Pole in degrees */
91   double	rodeg;		/* Radius of the projection generating sphere */
92   double	imrot;		/* Rotation angle of north pole */
93   double	pa_north;	/* Position angle of north (0=horizontal) */
94   double	pa_east;	/* Position angle of east (0=horizontal) */
95   double	radvel;		/* Radial velocity (km/sec away from observer)*/
96   double	zvel;		/* Radial velocity (v/c away from observer)*/
97   double	zpzd;		/* Colat of FIP (degs) */
98   double	zpr;		/* Radius of FIP (degs) */
99   int		imflip;		/* If not 0, image is reflected around axis */
100   int		prjcode;	/* projection code (-1-32) */
101   int		latbase;	/* Latitude base 90 (NPA), 0 (LAT), -90 (SPA) */
102   int		ncoeff1;	/* Number of x-axis plate fit coefficients */
103   int		ncoeff2;	/* Number of y-axis plate fit coefficients */
104   int		zpnp;		 /* ZP polynomial order (0-9) */
105   int		changesys;	/* 1 for FK4->FK5, 2 for FK5->FK4 */
106   				/* 3 for FK4->galactic, 4 for FK5->galactic */
107   int		printsys;	/* 1 to print coordinate system, else 0 */
108   int		ndec;		/* Number of decimal places in PIX2WCST */
109   int		degout;		/* 1 to always print degrees in PIX2WCST */
110   int		tabsys;		/* 1 to put tab between RA & Dec, else 0 */
111   int		rotmat;		/* 0 if CDELT, CROTA; 1 if CD */
112   int		coorflip;	/* 0 if x=RA, y=Dec; 1 if x=Dec, y=RA */
113   int		offscl;		/* 0 if OK, 1 if offscale */
114   int		wcson;		/* 1 if WCS is set, else 0 */
115   int		naxis;		/* Number of axes in image (for WCSLIB 3.0) */
116   int		naxes;		/* Number of axes in image */
117   int		wcsproj;	/* WCS_OLD: AIPS worldpos() and worldpix()
118 				   WCS_NEW: Mark Calabretta's WCSLIB subroutines
119 				   WCS_BEST: WCSLIB for all but CAR,COE,NCP
120 				   WCS_ALT:  AIPS for all but CAR,COE,NCP */
121   int		linmode;	/* 0=system only, 1=units, 2=system+units */
122   int		detector;	/* Instrument detector number */
123   char		instrument[32];	/* Instrument name */
124   char		ctype[9][16];	/* Values of CTYPEn keywords */
125   char		c1type[8];	/*  1st coordinate type code:
126 					RA--, GLON, ELON */
127   char		c2type[8];	/*  2nd coordinate type code:
128 					DEC-, GLAT, ELAT */
129   char		ptype[8];	/*  projection type code:
130 				    SIN, TAN, ARC, NCP, GLS, MER, AIT, etc */
131   char		units[9][32];	/* Units if LINEAR */
132   char		radecsys[32];	/* Reference frame: FK4, FK4-NO-E, FK5, GAPPT*/
133   char		radecout[32];	/* Output reference frame: FK4,FK5,GAL,ECL */
134   char		radecin[32];	/* Input reference frame: FK4,FK5,GAL,ECL */
135   double	eqin;		/* Input equinox (match sysin if 0.0) */
136   double	eqout;		/* Output equinox (match sysout if 0.0) */
137   int		sysin;		/* Input coordinate system code */
138   int		syswcs;		/* WCS coordinate system code */
139   int		sysout;		/* Output coordinate system code */
140 				/* WCS_B1950, WCS_J2000, WCS_ICRS, WCS_GALACTIC,
141 				 * WCS_ECLIPTIC, WCS_LINEAR, WCS_ALTAZ  */
142   char		center[32];	/* Center coordinates (with frame) */
143   struct wcsprm wcsl;		/* WCSLIB main projection parameters */
144   struct linprm lin;		/* WCSLIB image/pixel conversion parameters */
145   struct celprm cel;		/* WCSLIB projection type */
146   struct prjprm prj;		/* WCSLIB projection parameters */
147   struct IRAFsurface *lngcor;	/* RA/longitude correction structure */
148   struct IRAFsurface *latcor;	/* Dec/latitude correction structure */
149   int		distcode;	/* Distortion code 0=none 1=SIRTF */
150   struct Distort distort;	/* SIRTF distortion coefficients */
151   char *command_format[10];	/* WCS command formats */
152 				/* where %s is replaced by WCS coordinates */
153 				/* where %f is replaced by the image filename */
154 				/* where %x is replaced by image coordinates */
155   double	ltm[4];		/* Image rotation matrix */
156   double	ltv[2];		/* Image offset */
157   int		idpix[2];	/* First pixel to use in image (x, y) */
158   int		ndpix[2];	/* Number of pixels to use in image (x, y) */
159   struct WorldCoor *wcs;	/* WCS upon which this WCS depends */
160   struct WorldCoor *wcsdep;	/* WCS depending on this WCS */
161   char		*wcsname;	/* WCS name (defaults to NULL pointer) */
162   char		wcschar;	/* WCS character (A-Z, null, space) */
163   int		logwcs;		/* 1 if DC-FLAG is set for log wavelength */
164 };
165 
166 /* Projections (1-26 are WCSLIB) (values for wcs->prjcode) */
167 #define WCS_PIX -1	/* Pixel WCS */
168 #define WCS_LIN  0	/* Linear projection */
169 #define WCS_AZP  1	/* Zenithal/Azimuthal Perspective */
170 #define WCS_SZP  2	/* Zenithal/Azimuthal Perspective */
171 #define WCS_TAN  3	/* Gnomonic = Tangent Plane */
172 #define WCS_SIN  4	/* Orthographic/synthesis */
173 #define WCS_STG  5	/* Stereographic */
174 #define WCS_ARC  6	/* Zenithal/azimuthal equidistant */
175 #define WCS_ZPN  7	/* Zenithal/azimuthal PolyNomial */
176 #define WCS_ZEA  8	/* Zenithal/azimuthal Equal Area */
177 #define WCS_AIR  9	/* Airy */
178 #define WCS_CYP 10	/* CYlindrical Perspective */
179 #define WCS_CAR 11	/* Cartesian */
180 #define WCS_MER 12	/* Mercator */
181 #define WCS_CEA 13	/* Cylindrical Equal Area */
182 #define WCS_COP 14	/* Conic PerSpective (COP) */
183 #define WCS_COD 15	/* COnic equiDistant */
184 #define WCS_COE 16	/* COnic Equal area */
185 #define WCS_COO 17	/* COnic Orthomorphic */
186 #define WCS_BON 18	/* Bonne */
187 #define WCS_PCO 19	/* Polyconic */
188 #define WCS_SFL 20	/* Sanson-Flamsteed (GLobal Sinusoidal) */
189 #define WCS_PAR 21	/* Parabolic */
190 #define WCS_AIT 22	/* Hammer-Aitoff */
191 #define WCS_MOL 23	/* Mollweide */
192 #define WCS_CSC 24	/* COBE quadrilateralized Spherical Cube */
193 #define WCS_QSC 25	/* Quadrilateralized Spherical Cube */
194 #define WCS_TSC 26	/* Tangential Spherical Cube */
195 #define WCS_NCP 27	/* Special case of SIN from AIPS*/
196 #define WCS_GLS 28	/* Same as SFL from AIPS*/
197 #define WCS_DSS 29	/* Digitized Sky Survey plate solution */
198 #define WCS_PLT 30	/* Plate fit polynomials (SAO) */
199 #define WCS_TNX 31	/* Tangent Plane (NOAO corrections) */
200 #define WCS_ZPX 32	/* Zenithal Azimuthal Polynomial (NOAO corrections) */
201 #define WCS_TPV 33	/* Tangent Plane (SCAMP corrections) */
202 #define NWCSTYPE 34	/* Number of WCS types (-1 really means no WCS) */
203 
204 /* Coordinate systems */
205 #define WCS_J2000	1	/* J2000(FK5) right ascension and declination */
206 #define WCS_B1950	2	/* B1950(FK4) right ascension and declination */
207 #define WCS_GALACTIC	3	/* Galactic longitude and latitude */
208 #define WCS_ECLIPTIC	4	/* Ecliptic longitude and latitude */
209 #define WCS_ALTAZ	5	/* Azimuth and altitude/elevation */
210 #define WCS_LINEAR	6	/* Linear with optional units */
211 #define WCS_NPOLE	7	/* Longitude and north polar angle */
212 #define WCS_SPA		8	/* Longitude and south polar angle */
213 #define WCS_PLANET	9	/* Longitude and latitude on planet */
214 #define WCS_XY		10	/* X-Y Cartesian coordinates */
215 #define WCS_ICRS	11	/* ICRS right ascension and declination */
216 
217 /* Method to use */
218 #define WCS_BEST	0	/* Use best WCS projections */
219 #define WCS_ALT		1	/* Use not best WCS projections */
220 #define WCS_OLD		2	/* Use AIPS WCS projections */
221 #define WCS_NEW		3	/* Use WCSLIB 2.5 WCS projections */
222 
223 /* Distortion codes (values for wcs->distcode) */
224 #define DISTORT_NONE	0	/* No distortion coefficients */
225 #define DISTORT_SIRTF	1	/* SIRTF distortion matrix */
226 
227 #ifndef PI
228 #define PI	3.141592653589793238462643
229 #endif
230 
231 /* pi/(180*3600):  arcseconds to radians */
232 #define AS2R		4.8481368110953e-6
233 
234 /* Conversions among hours of RA, degrees and radians. */
235 #define degrad(x)	((x)*PI/180.)
236 #define raddeg(x)	((x)*180./PI)
237 #define hrdeg(x)	((x)*15.)
238 #define deghr(x)	((x)/15.)
239 #define hrrad(x)	degrad(hrdeg(x))
240 #define radhr(x)	deghr(raddeg(x))
241 #define secrad(x)	((x)*AS2R)
242 
243 /* TNX/ZPX surface fitting structure and flags */
244 struct IRAFsurface {
245   double xrange;	/* 2. / (xmax - xmin), polynomials */
246   double xmaxmin;	/* - (xmax + xmin) / 2., polynomials */
247   double yrange;	/* 2. / (ymax - ymin), polynomials */
248   double ymaxmin;	/* - (ymax + ymin) / 2., polynomials */
249   int	 type;		/* type of curve to be fitted */
250   int    xorder;	/* order of the fit in x */
251   int    yorder;	/* order of the fit in y */
252   int    xterms;	/* cross terms for polynomials */
253   int    ncoeff;	/* total number of coefficients */
254   double *coeff;	/* pointer to coefficient vector */
255   double *xbasis;	/* pointer to basis functions (all x) */
256   double *ybasis;	/* pointer to basis functions (all y) */
257 };
258 
259 /* TNX/ZPX permitted types of surfaces */
260 #define  TNX_CHEBYSHEV    1
261 #define  TNX_LEGENDRE     2
262 #define  TNX_POLYNOMIAL   3
263 
264 /* TNX/ZPX cross-terms flags */
265 #define	TNX_XNONE	0	/* no x-terms (old no) */
266 #define	TNX_XFULL	1	/* full x-terms (new yes) */
267 #define	TNX_XHALF	2	/* half x-terms (new) */
268 
269 #ifdef __cplusplus /* C++ prototypes */
270 extern "C" {
271 #endif
272 
273 #ifdef __STDC__   /* Full ANSI prototypes */
274 
275     /* WCS data structure initialization subroutines in wcsinit.c */
276     struct WorldCoor *wcsinit ( /* set up WCS structure from a FITS image header */
277 	const char* hstring);
278 
279     struct WorldCoor *wcsninit ( /* set up WCS structure from a FITS image header */
280 	const char* hstring,	/* FITS header */
281 	int len);		/* Length of FITS header */
282 
283     struct WorldCoor *wcsinitn ( /* set up WCS structure from a FITS image header */
284 	const char* hstring,	/* FITS header */
285 	const char* wcsname);	/* WCS name */
286 
287     struct WorldCoor *wcsninitn ( /* set up WCS structure from a FITS image header */
288 	const char* hstring,	/* FITS header */
289 	int len,		/* Length of FITS header */
290 	const char* wcsname);	/* WCS name */
291 
292     struct WorldCoor *wcsinitc ( /* set up WCS structure from a FITS image header */
293 	const char* hstring,	/* FITS header */
294 	char *wcschar);		/* WCS character (A-Z) */
295 
296     struct WorldCoor *wcsninitc ( /* set up WCS structure from a FITS image header */
297 	const char* hstring,	/* FITS header */
298 	int len,		/* Length of FITS header */
299 	char *wcschar);		/* WCS character (A-Z) */
300     char *uppercase (		/* Convert string of any case to uppercase */
301 	const char *string);		/* String to convert */
302 
303     /* WCS subroutines in wcs.c */
304     void wcsfree (		/* Free a WCS structure and its contents */
305 	struct WorldCoor *wcs);	/* World coordinate system structure */
306 
307     int wcstype(		/* Set projection type from header CTYPEs */
308 	struct WorldCoor *wcs,	/* World coordinate system structure */
309 	char *ctype1,		/* FITS WCS projection for axis 1 */
310 	char *ctype2);		/* FITS WCS projection for axis 2 */
311 
312     int iswcs(		/* Returns 1 if wcs structure set, else 0 */
313 	struct WorldCoor *wcs);	/* World coordinate system structure */
314     int nowcs(		/* Returns 0 if wcs structure set, else 1 */
315 	struct WorldCoor *wcs);	/* World coordinate system structure */
316 
317     int pix2wcst (	/* Convert pixel coordinates to World Coordinate string */
318         struct WorldCoor *wcs,  /* World coordinate system structure */
319         double xpix, 	/* Image horizontal coordinate in pixels */
320         double ypix,	/* Image vertical coordinate in pixels */
321         char *wcstring,	/* World coordinate string (returned) */
322         int lstr);	/* Length of world coordinate string (returned) */
323 
324     void pix2wcs (	/* Convert pixel coordinates to World Coordinates */
325         struct WorldCoor *wcs,  /* World coordinate system structure */
326         double xpix,	/* Image horizontal coordinate in pixels */
327         double ypix,	/* Image vertical coordinate in pixels */
328         double *xpos,	/* Longitude/Right Ascension in degrees (returned) */
329         double *ypos);	/* Latitude/Declination in degrees (returned) */
330 
331     void wcsc2pix (	/* Convert World Coordinates to pixel coordinates */
332         struct WorldCoor *wcs,  /* World coordinate system structure */
333         double xpos,	/* Longitude/Right Ascension in degrees */
334         double ypos,	/* Latitude/Declination in degrees */
335 	char *coorsys,	/* Coordinate system (B1950, J2000, etc) */
336         double *xpix,	/* Image horizontal coordinate in pixels (returned) */
337         double *ypix,	/* Image vertical coordinate in pixels (returned) */
338         int *offscl);
339 
340     void wcs2pix (	/* Convert World Coordinates to pixel coordinates */
341         struct WorldCoor *wcs,  /* World coordinate system structure */
342         double xpos,	/* Longitude/Right Ascension in degrees */
343         double ypos,	/* Latitude/Declination in degrees */
344         double *xpix,	/* Image horizontal coordinate in pixels (returned) */
345         double *ypix,	/* Image vertical coordinate in pixels (returned) */
346         int *offscl);
347 
348     double wcsdist(	/* Compute angular distance between 2 sky positions */
349 	double ra1,	/* First longitude/right ascension in degrees */
350 	double dec1,	/* First latitude/declination in degrees */
351 	double ra2,	/* Second longitude/right ascension in degrees */
352 	double dec2);	/* Second latitude/declination in degrees */
353 
354     double wcsdist1(	/* Compute angular distance between 2 sky positions */
355 	double ra1,	/* First longitude/right ascension in degrees */
356 	double dec1,	/* First latitude/declination in degrees */
357 	double ra2,	/* Second longitude/right ascension in degrees */
358 	double dec2);	/* Second latitude/declination in degrees */
359 
360     double wcsdiff(	/* Compute angular distance between 2 sky positions */
361 	double ra1,	/* First longitude/right ascension in degrees */
362 	double dec1,	/* First latitude/declination in degrees */
363 	double ra2,	/* Second longitude/right ascension in degrees */
364 	double dec2);	/* Second latitude/declination in degrees */
365 
366     struct WorldCoor* wcsxinit( /* set up a WCS structure from arguments */
367         double cra,	/* Center right ascension in degrees */
368         double cdec,	/* Center declination in degrees */
369         double secpix,	/* Number of arcseconds per pixel */
370         double xrpix,	/* Reference pixel X coordinate */
371         double yrpix,	/* Reference pixel X coordinate */
372         int nxpix,	/* Number of pixels along x-axis */
373         int nypix,	/* Number of pixels along y-axis */
374         double rotate,	/* Rotation angle (clockwise positive) in degrees */
375         int equinox,	/* Equinox of coordinates, 1950 and 2000 supported */
376         double epoch,	/* Epoch of coordinates, used for FK4/FK5 conversion
377                          * no effect if 0 */
378         char *proj);	/* Projection */
379 
380     struct WorldCoor* wcskinit( /* set up WCS structure from keyword values */
381 	int naxis1,	/* Number of pixels along x-axis */
382 	int naxis2,	/* Number of pixels along y-axis */
383 	char *ctype1,	/* FITS WCS projection for axis 1 */
384 	char *ctype2,	/* FITS WCS projection for axis 2 */
385 	double crpix1,	/* Reference pixel coordinates */
386 	double crpix2,	/* Reference pixel coordinates */
387 	double crval1,	/* Coordinate at reference pixel in degrees */
388 	double crval2,	/* Coordinate at reference pixel in degrees */
389 	double *cd,	/* Rotation matrix, used if not NULL */
390 	double cdelt1,	/* scale in degrees/pixel, if cd is NULL */
391 	double cdelt2,	/* scale in degrees/pixel, if cd is NULL */
392 	double crota,	/* Rotation angle in degrees, if cd is NULL */
393 	int equinox,	/* Equinox of coordinates, 1950 and 2000 supported */
394 	double epoch);	/* Epoch of coordinates, for FK4/FK5 conversion */
395 
396     void wcsshift(	/* Change center of WCS */
397         struct WorldCoor *wcs,  /* World coordinate system structure */
398         double cra,	/* New center right ascension in degrees */
399         double cdec,	/* New center declination in degrees */
400         char *coorsys); /* FK4 or FK5 coordinates (1950 or 2000) */
401 
402     void wcsfull(	/* Return RA and Dec of image center, size in degrees */
403         struct WorldCoor *wcs,  /* World coordinate system structure */
404         double  *cra,	/* Right ascension of image center (deg) (returned) */
405         double  *cdec,	/* Declination of image center (deg) (returned) */
406         double  *width,	/* Width in degrees (returned) */
407         double  *height); /* Height in degrees (returned) */
408 
409     void wcscent(	/* Print the image center and size in WCS units */
410         struct WorldCoor *wcs); /* World coordinate system structure */
411 
412     void wcssize(	/* Return image center and size in RA and Dec */
413         struct WorldCoor *wcs,  /* World coordinate system structure */
414         double *cra,	/* Right ascension of image center (deg) (returned) */
415         double *cdec,	/* Declination of image center (deg) (returned) */
416         double *dra,	/* Half-width in right ascension (deg) (returned) */
417         double *ddec);	/* Half-width in declination (deg) (returned) */
418 
419     void wcsrange(	/* Return min and max RA and Dec of image in degrees */
420         struct WorldCoor *wcs,  /* World coordinate system structure */
421         double  *ra1,	/* Min. right ascension of image (deg) (returned) */
422         double  *ra2,	/* Max. right ascension of image (deg) (returned) */
423         double  *dec1,	/* Min. declination of image (deg) (returned) */
424         double  *dec2);	/* Max. declination of image (deg) (returned) */
425 
426     void wcscdset(	/* Set scaling and rotation from CD matrix */
427 	struct WorldCoor *wcs,	/* World coordinate system structure */
428 	double *cd);	/* CD matrix, ignored if NULL */
429 
430     void wcsdeltset(	/* set scaling, rotation from CDELTi, CROTA2 */
431 	struct WorldCoor *wcs,	/* World coordinate system structure */
432 	double cdelt1,	/* degrees/pixel in first axis (or both axes) */
433 	double cdelt2,	/* degrees/pixel in second axis if nonzero */
434 	double crota);	/* Rotation counterclockwise in degrees */
435 
436     void wcspcset(	/* set scaling, rotation from CDELTs and PC matrix */
437 	struct WorldCoor *wcs,	/* World coordinate system structure */
438 	double cdelt1,	/* degrees/pixel in first axis (or both axes) */
439 	double cdelt2,	/* degrees/pixel in second axis if nonzero */
440 	double *pc);	/* Rotation matrix, ignored if NULL */
441 
442     void setwcserr(	/* Set WCS error message for later printing */
443 	char *errmsg);	/* Error mesage < 80 char */
444     void wcserr(void);	/* Print WCS error message to stderr */
445 
446     void setdefwcs(	/* Set flag to use AIPS WCS instead of WCSLIB */
447 	int oldwcs);	/* 1 for AIPS WCS subroutines, else WCSLIB */
448     int getdefwcs(void);	/* Return flag for AIPS WCS set by setdefwcs */
449 
450     char *getradecsys(	/* Return name of image coordinate system */
451         struct WorldCoor *wcs);	/* World coordinate system structure */
452 
453     void wcsoutinit(	/* Set output coordinate system for pix2wcs */
454         struct WorldCoor *wcs,	/* World coordinate system structure */
455 	char *coorsys);	/* Coordinate system (B1950, J2000, etc) */
456 
457     char *getwcsout(	/* Return current output coordinate system */
458         struct WorldCoor *wcs);	/* World coordinate system structure */
459 
460     void wcsininit(	/* Set input coordinate system for wcs2pix */
461         struct WorldCoor *wcs,	/* World coordinate system structure */
462 	char *coorsys);	/* Coordinate system (B1950, J2000, etc) */
463 
464     char *getwcsin(	/* Return current input coordinate system */
465         struct WorldCoor *wcs);	/* World coordinate system structure */
466 
467     int setwcsdeg(	/* Set WCS coordinate output format */
468         struct WorldCoor *wcs,	/* World coordinate system structure */
469 	int degout);	/* 1= degrees, 0= hh:mm:ss dd:mm:ss */
470 
471     int wcsndec(	/* Set or get number of output decimal places */
472         struct WorldCoor *wcs,	/* World coordinate system structure */
473 	int ndec);	/* Number of decimal places in output string
474 			   if < 0, return current ndec unchanged */
475 
476     int wcsreset(	/* Change WCS using arguments */
477 	struct WorldCoor *wcs,	/* World coordinate system data structure */
478 	double crpix1,	/* Horizontal reference pixel */
479 	double crpix2,	/* Vertical reference pixel */
480 	double crval1,	/* Reference pixel horizontal coordinate in degrees */
481 	double crval2,	/* Reference pixel vertical coordinate in degrees */
482 	double cdelt1,	/* Horizontal scale in degrees/pixel, ignored if cd is not NULL */
483 	double cdelt2,	/* Vertical scale in degrees/pixel, ignored if cd is not NULL */
484 	double crota,	/* Rotation angle in degrees, ignored if cd is not NULL */
485 	double *cd);	/* Rotation matrix, used if not NULL */
486 
487     void wcseqset(	/* Change equinox of reference pixel coordinates in WCS */
488 	struct WorldCoor *wcs,	/* World coordinate system data structure */
489 	double equinox);	/* Desired equinox as fractional year */
490 
491     void setwcslin(	/* Set pix2wcst() mode for LINEAR coordinates */
492         struct WorldCoor *wcs,	/* World coordinate system structure */
493 	int mode);	/* 0: x y linear, 1: x units x units
494 			   2: x y linear units */
495 
496     int wcszin(		/* Set third dimension for cube projections */
497 	int izpix);	/* Set coordinate in third dimension (face) */
498 
499     int wcszout (	/* Return coordinate in third dimension */
500         struct WorldCoor *wcs);	/* World coordinate system structure */
501 
502     void wcscominit(	/* Initialize catalog search command set by -wcscom */
503 	struct WorldCoor *wcs,	/* World coordinate system structure */
504 	int i,		/* Number of command (0-9) to initialize */
505 	char *command);	/* command with %s where coordinates will go */
506 
507     void wcscom(	/* Execute catalog search command set by -wcscom */
508 	struct WorldCoor *wcs,	/* World coordinate system structure */
509 	int i,		/* Number of command (0-9) to execute */
510 	char *filename,	/* Image file name */
511 	double xfile,	/* Horizontal image pixel coordinates for WCS command */
512 	double yfile,	/* Vertical image pixel coordinates for WCS command */
513 	char *wcstring); /* WCS String from pix2wcst() */
514 
515     void savewcscom(	/* Save WCS shell command */
516 	int i,		/* i of 10 possible shell commands */
517 	char *wcscom);	/* Shell command using output WCS string */
518     char *getwcscom(	/* Return WCS shell command */
519 	int i);		/* i of 10 possible shell commands */
520     void setwcscom(	/* Set WCS shell commands from stored values */
521         struct WorldCoor *wcs);	/* World coordinate system structure */
522     void freewcscom(	/* Free memory storing WCS shell commands */
523         struct WorldCoor *wcs);	/* World coordinate system structure */
524 
525     void setwcsfile(	/* Set filename for WCS error message */
526 	char *filename); /* FITS or IRAF file name */
527     int cpwcs (		/* Copy WCS keywords with no suffix to ones with suffix */
528 	char **header,	/* Pointer to start of FITS header */
529 	char *cwcs);	/* Keyword suffix character for output WCS */
530 
531     void savewcscoor(	/* Save output coordinate system */
532 	char *wcscoor);	/* coordinate system (J2000, B1950, galactic) */
533     char *getwcscoor(void); /* Return output coordinate system */
534 
535     /* Coordinate conversion subroutines in wcscon.c */
536     void wcsconv(	/* Convert between coordinate systems and equinoxes */
537 	int sys1,	/* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
538 	int sys2,	/* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
539 	double eq1,	/* Input equinox (default of sys1 if 0.0) */
540 	double eq2,	/* Output equinox (default of sys2 if 0.0) */
541 	double ep1,	/* Input Besselian epoch in years */
542 	double ep2,	/* Output Besselian epoch in years */
543 	double *dtheta,	/* Longitude or right ascension in degrees
544 			   Input in sys1, returned in sys2 */
545 	double *dphi,	/* Latitude or declination in degrees
546 			   Input in sys1, returned in sys2 */
547 	double *ptheta,	/* Longitude or right ascension proper motion in deg/year
548 			   Input in sys1, returned in sys2 */
549 	double *pphi,	/* Latitude or declination proper motion in deg/year */
550 	double *px,	/* Parallax in arcseconds */
551 	double *rv);	/* Radial velocity in km/sec */
552     void wcsconp(	/* Convert between coordinate systems and equinoxes */
553 	int sys1,	/* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
554 	int sys2,	/* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
555 	double eq1,	/* Input equinox (default of sys1 if 0.0) */
556 	double eq2,	/* Output equinox (default of sys2 if 0.0) */
557 	double ep1,	/* Input Besselian epoch in years */
558 	double ep2,	/* Output Besselian epoch in years */
559 	double *dtheta,	/* Longitude or right ascension in degrees
560 			   Input in sys1, returned in sys2 */
561 	double *dphi,	/* Latitude or declination in degrees
562 			   Input in sys1, returned in sys2 */
563 	double *ptheta,	/* Longitude or right ascension proper motion in degrees/year
564 			   Input in sys1, returned in sys2 */
565 	double *pphi);	/* Latitude or declination proper motion in degrees/year
566 			   Input in sys1, returned in sys2 */
567     void wcscon(	/* Convert between coordinate systems and equinoxes */
568 	int sys1,	/* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
569 	int sys2,	/* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
570 	double eq1,	/* Input equinox (default of sys1 if 0.0) */
571 	double eq2,	/* Output equinox (default of sys2 if 0.0) */
572 	double *dtheta,	/* Longitude or right ascension in degrees
573 			   Input in sys1, returned in sys2 */
574 	double *dphi,	/* Latitude or declination in degrees
575 			   Input in sys1, returned in sys2 */
576 	double epoch);	/* Besselian epoch in years */
577     void fk425e (	/* Convert B1950(FK4) to J2000(FK5) coordinates */
578 	double *ra,	/* Right ascension in degrees (B1950 in, J2000 out) */
579 	double *dec,	/* Declination in degrees (B1950 in, J2000 out) */
580 	double epoch);	/* Besselian epoch in years */
581     void fk524e (	/* Convert J2000(FK5) to B1950(FK4) coordinates */
582 	double *ra,	/* Right ascension in degrees (J2000 in, B1950 out) */
583 	double *dec,	/* Declination in degrees (J2000 in, B1950 out) */
584 	double epoch);	/* Besselian epoch in years */
585     int wcscsys(	/* Return code for coordinate system in string */
586 	char *coorsys);	 /* Coordinate system (B1950, J2000, etc) */
587     double wcsceq (	/* Set equinox from string (return 0.0 if not obvious) */
588 	char *wcstring);  /* Coordinate system (B1950, J2000, etc) */
589     void wcscstr (	/* Set coordinate system type string from system and equinox */
590 	char   *cstr,	 /* Coordinate system string (returned) */
591 	int    syswcs,	/* Coordinate system code */
592 	double equinox,	/* Equinox of coordinate system */
593 	double epoch);	/* Epoch of coordinate system */
594     void d2v3 (		/* Convert RA and Dec in degrees and distance to vector */
595 	double	rra,	/* Right ascension in degrees */
596 	double	rdec,	/* Declination in degrees */
597 	double	r,	/* Distance to object in same units as pos */
598 	double pos[3]);	/* x,y,z geocentric equatorial position of object (returned) */
599     void s2v3 (		/* Convert RA and Dec in radians and distance to vector */
600 	double	rra,	/* Right ascension in radians */
601 	double	rdec,	/* Declination in radians */
602 	double	r,	/* Distance to object in same units as pos */
603 	double pos[3]);	/* x,y,z geocentric equatorial position of object (returned) */
604     void v2d3 (		/* Convert vector to RA and Dec in degrees and distance */
605 	double	pos[3],	/* x,y,z geocentric equatorial position of object */
606 	double	*rra,	/* Right ascension in degrees (returned) */
607 	double	*rdec,	/* Declination in degrees (returned) */
608 	double	*r);	/* Distance to object in same units as pos (returned) */
609     void v2s3 (		/* Convert vector to RA and Dec in radians and distance */
610 	double	pos[3],	/* x,y,z geocentric equatorial position of object */
611 	double	*rra,	/* Right ascension in radians (returned) */
612 	double	*rdec,	/* Declination in radians (returned) */
613 	double	*r);	/* Distance to object in same units as pos (returned) */
614 
615 /* Distortion model subroutines in distort.c */
616     void distortinit (	/* Set distortion coefficients from FITS header */
617 	struct WorldCoor *wcs,	/* World coordinate system structure */
618 	const char* hstring);	/* FITS header */
619     void setdistcode (	/* Set WCS distortion code string from CTYPEi value */
620 	struct WorldCoor *wcs,	/* World coordinate system structure */
621 	char	*ctype);	/* CTYPE value from FITS header */
622     char *getdistcode (	/* Return distortion code string for CTYPEi */
623 	struct WorldCoor *wcs);	/* World coordinate system structure */
624     int DelDistort (	/* Delete all distortion-related fields */
625 	char *header,	/* FITS header */
626 	int verbose);	/* If !=0, print keywords as deleted */
627     void pix2foc (	/* Convert pixel to focal plane coordinates */
628 	struct WorldCoor *wcs,	/* World coordinate system structure */
629 	double x,	/* Image pixel horizontal coordinate */
630 	double y,	/* Image pixel vertical coordinate */
631 	double *u,	/* Focal plane horizontal coordinate(returned) */
632 	double *v);	/* Focal plane vertical coordinate (returned) */
633     void foc2pix (	/* Convert focal plane to pixel coordinates */
634 	struct WorldCoor *wcs,	/* World coordinate system structure */
635 	double u,	/* Focal plane horizontal coordinate */
636 	double v,	/* Focal plane vertical coordinate */
637 	double *x,	/* Image pixel horizontal coordinate(returned) */
638 	double *y);	/* Image pixel vertical coordinate (returned) */
639 
640 /* Other projection subroutines */
641 
642 /* 8 projections using AIPS algorithms (worldpos.c) */
643     int worldpos (	/* Convert from pixel location to RA,Dec */
644 	double xpix,	/* x pixel number  (RA or long without rotation) */
645 	double ypix,	/* y pixel number  (Dec or lat without rotation) */
646 	struct WorldCoor *wcs, /* WCS parameter structure */
647 	double *xpos,	/* x (RA) coordinate (deg) (returned) */
648 	double *ypos);	/* y (dec) coordinate (deg) (returned) */
649     int worldpix (	/* Convert from RA,Dec to pixel location */
650 	double xpos,	/* x (RA) coordinate (deg) */
651 	double ypos,	/* y (dec) coordinate (deg) */
652 	struct WorldCoor *wcs, /* WCS parameter structure */
653 	double *xpix,	/* x pixel number (RA or long without rotation) */
654 	double *ypix);	/* y pixel number (dec or lat without rotation) */
655 
656 /* Digital Sky Survey projection (dsspos.c) */
657     int dsspos (	/* Convert from pixel location to RA,Dec */
658 	double xpix,	/* x pixel number  (RA or long without rotation) */
659 	double ypix,	/* y pixel number  (Dec or lat without rotation) */
660 	struct WorldCoor *wcs, /* WCS parameter structure */
661 	double *xpos,	/* x (RA) coordinate (deg) (returned) */
662 	double *ypos);	/* y (dec) coordinate (deg) (returned) */
663     int dsspix (	/* Convert from RA,Dec to pixel location */
664 	double xpos,	/* x (RA) coordinate (deg) */
665 	double ypos,	/* y (dec) coordinate (deg) */
666 	struct WorldCoor *wcs, /* WCS parameter structure */
667 	double *xpix,	/* x pixel number (RA or long without rotation) */
668 	double *ypix);	/* y pixel number (dec or lat without rotation) */
669 
670 /* SAO TDC TAN projection with higher order terms (platepos.c) */
671     int platepos (	/* Convert from pixel location to RA,Dec */
672 	double xpix,	/* x pixel number  (RA or long without rotation) */
673 	double ypix,	/* y pixel number  (Dec or lat without rotation) */
674 	struct WorldCoor *wcs, /* WCS parameter structure */
675 	double *xpos,	/* x (RA) coordinate (deg) (returned) */
676 	double *ypos);	/* y (dec) coordinate (deg) (returned) */
677     int platepix (	/* Convert from RA,Dec to pixel location */
678 	double xpos,	/* x (RA) coordinate (deg) */
679 	double ypos,	/* y (dec) coordinate (deg) */
680 	struct WorldCoor *wcs, /* WCS parameter structure */
681 	double *xpix,	/* x pixel number (RA or long without rotation) */
682 	double *ypix);	/* y pixel number (dec or lat without rotation) */
683     void SetFITSPlate (	/* Set FITS header plate fit coefficients from structure */
684 	char *header,	/* Image FITS header */
685 	struct WorldCoor *wcs); /* WCS structure */
686     int SetPlate (	/* Set plate fit coefficients in structure from arguments */
687 	struct WorldCoor *wcs, /* World coordinate system structure */
688 	int ncoeff1,	/* Number of coefficients for x */
689 	int ncoeff2,	/* Number of coefficients for y */
690 	double *coeff);	/* Plate fit coefficients */
691     int GetPlate (	/* Return plate fit coefficients from structure in arguments */
692 	struct WorldCoor *wcs, /* World coordinate system structure */
693 	int *ncoeff1,	/* Number of coefficients for x */
694 	int *ncoeff2,	/* Number of coefficients for y) */
695 	double *coeff);	/* Plate fit coefficients */
696 
697 /* IRAF TAN projection with higher order terms (tnxpos.c) */
698     int tnxinit (	/* initialize the gnomonic forward or inverse transform */
699 	const char *header, /* FITS header */
700 	struct WorldCoor *wcs); /* pointer to WCS structure */
701     int tnxpos (	/* forward transform (physical to world) gnomonic projection. */
702 	double xpix,	/* Image X coordinate */
703 	double ypix,	/* Image Y coordinate */
704 	struct WorldCoor *wcs, /* pointer to WCS descriptor */
705 	double *xpos,	/* Right ascension (returned) */
706 	double *ypos);	/* Declination (returned) */
707     int tnxpix (	/* Inverse transform (world to physical) gnomonic projection */
708 	double xpos,     /* Right ascension */
709 	double ypos,     /* Declination */
710 	struct WorldCoor *wcs, /* Pointer to WCS descriptor */
711 	double *xpix,	/* Image X coordinate (returned) */
712 	double *ypix);	/* Image Y coordinate (returned) */
713 
714 /* IRAF ZPN projection with higher order terms (zpxpos.c) */
715     int zpxinit (	/* initialize the zenithal forward or inverse transform */
716 	const char *header, /* FITS header */
717 	struct WorldCoor *wcs); /* pointer to WCS structure */
718     int zpxpos (	/* forward transform (physical to world) */
719 	double xpix,	/* Image X coordinate */
720 	double ypix,	/* Image Y coordinate */
721 	struct WorldCoor *wcs, /* pointer to WCS descriptor */
722 	double *xpos,	/* Right ascension (returned) */
723 	double *ypos);	/* Declination (returned) */
724     int zpxpix (	/* Inverse transform (world to physical) */
725 	double xpos,	/* Right ascension */
726 	double ypos,	/* Declination */
727 	struct WorldCoor *wcs, /* Pointer to WCS descriptor */
728 	double *xpix,	/* Image X coordinate (returned) */
729 	double *ypix);	/* Image Y coordinate (returned) */
730 
731 #else /* K&R prototypes */
732 
733 /* WCS subroutines in wcs.c */
734 struct WorldCoor *wcsinit(); /* set up a WCS structure from a FITS image header */
735 struct WorldCoor *wcsninit(); /* set up a WCS structure from a FITS image header */
736 struct WorldCoor *wcsinitn(); /* set up a WCS structure from a FITS image header */
737 struct WorldCoor *wcsninitn(); /* set up a WCS structure from a FITS image header */
738 struct WorldCoor *wcsinitc(); /* set up a WCS structure from a FITS image header */
739 struct WorldCoor *wcsninitc(); /* set up a WCS structure from a FITS image header */
740 struct WorldCoor *wcsxinit(); /* set up a WCS structure from arguments */
741 struct WorldCoor *wcskinit(); /* set up a WCS structure from keyword values */
742 char *uppercase();	/* Convert string of any case to uppercase */
743 void wcsfree(void);	/* Free a WCS structure and its contents */
744 int wcstype();		/* Set projection type from header CTYPEs */
745 void wcscdset();	/* Set scaling and rotation from CD matrix */
746 void wcsdeltset();	/* set scaling and rotation from CDELTs and CROTA2 */
747 void wcspcset();	/* set scaling and rotation from CDELTs and PC matrix */
748 int iswcs();		/* Return 1 if WCS structure is filled, else 0 */
749 int nowcs();		/* Return 0 if WCS structure is filled, else 1 */
750 void wcsshift();	/* Reset the center of a WCS structure */
751 void wcscent();		/* Print the image center and size in WCS units */
752 void wcssize();		/* Return RA and Dec of image center, size in RA and Dec */
753 void wcsfull();		/* Return RA and Dec of image center, size in degrees */
754 void wcsrange();	/* Return min and max RA and Dec of image in degrees */
755 double wcsdist();	/* Distance in degrees between two sky coordinates */
756 double wcsdist1();	/* Compute angular distance between 2 sky positions */
757 double wcsdiff();	/* Distance in degrees between two sky coordinates */
758 void wcscominit();	/* Initialize catalog search command set by -wcscom */
759 void wcscom();		/* Execute catalog search command set by -wcscom */
760 char *getradecsys();	/* Return current value of coordinate system */
761 void wcsoutinit();	/* Initialize WCS output coordinate system for use by pix2wcs */
762 char *getwcsout();	/* Return current value of WCS output coordinate system */
763 void wcsininit();	/* Initialize WCS input coordinate system for use by wcs2pix */
764 char *getwcsin();	/* Return current value of WCS input coordinate system */
765 int setwcsdeg();	/* Set WCS output in degrees (1) or hh:mm:ss dd:mm:ss (0) */
766 int wcsndec();		/* Set or get number of output decimal places */
767 int wcsreset();		/* Change WCS using arguments */
768 void wcseqset();	/* Change equinox of reference pixel coordinates in WCS */
769 void wcscstr();		/* Return system string from system code, equinox, epoch */
770 void setwcslin();	/* Set output string mode for LINEAR coordinates */
771 int pix2wcst();		/* Convert pixel coordinates to World Coordinate string */
772 void pix2wcs();		/* Convert pixel coordinates to World Coordinates */
773 void wcsc2pix();	/* Convert World Coordinates to pixel coordinates */
774 void wcs2pix();		/* Convert World Coordinates to pixel coordinates */
775 void setdefwcs();	/* Call to use AIPS classic WCS (also not PLT/TNX/ZPX */
776 int getdefwcs();	/* Call to get flag for AIPS classic WCS */
777 int wcszin();		/* Set coordinate in third dimension (face) */
778 int wcszout();		/* Return coordinate in third dimension */
779 void wcserr();		/* Print WCS error message to stderr */
780 void setwcserr();	/* Set WCS error message for later printing */
781 void savewcscoor();	/* Save output coordinate system */
782 char *getwcscoor();	/* Return output coordinate system */
783 void savewcscom();	/* Save WCS shell command */
784 char *getwcscom();	/* Return WCS shell command */
785 void setwcscom();	/* Set WCS shell commands from stored values */
786 void freewcscom();	/* Free memory used to store WCS shell commands */
787 void setwcsfile();	/* Set filename for WCS error message */
788 int cpwcs();		/* Copy WCS keywords with no suffix to ones with suffix */
789 
790 /* Coordinate conversion subroutines in wcscon.c */
791 void wcscon();		/* Convert between coordinate systems and equinoxes */
792 void wcsconp();		/* Convert between coordinate systems and equinoxes */
793 void wcsconv();		/* Convert between coordinate systems and equinoxes */
794 void fk425e();		/* Convert B1950(FK4) to J2000(FK5) coordinates */
795 void fk524e();		/* Convert J2000(FK5) to B1950(FK4) coordinates */
796 int wcscsys();		/* Set coordinate system from string */
797 double wcsceq();	/* Set equinox from string (return 0.0 if not obvious) */
798 void d2v3();		/* Convert RA and Dec in degrees and distance to vector */
799 void s2v3();		/* Convert RA and Dec in radians and distance to vector */
800 void v2d3();		/* Convert vector to RA and Dec in degrees and distance */
801 void v2s3();		/* Convert vector to RA and Dec in radians and distance */
802 
803 /* Distortion model subroutines in distort.c */
804 void distortinit();	/* Set distortion coefficients from FITS header */
805 void setdistcode();	/* Set WCS distortion code string from CTYPEi value */
806 char *getdistcode();	/* Return distortion code string for CTYPEi */
807 int DelDistort();	/* Delete all distortion-related fields */
808 void pix2foc();		/*  pixel coordinates -> focal plane coordinates */
809 void foc2pix();		/*  focal plane coordinates -> pixel coordinates */
810 
811 /* Other projection subroutines */
812 
813 /* 8 projections using AIPS algorithms (worldpos.c) */
814 extern int worldpos();	/* Convert from pixel location to RA,Dec */
815 extern int worldpix();	/* Convert from RA,Dec to pixel location */
816 
817 /* Digital Sky Survey projection (dsspos.c) */
818 extern int dsspos();	/* Convert from pixel location to RA,Dec */
819 extern int dsspix();	/* Convert from RA,Dec to pixel location */
820 
821 /* SAO TDC TAN projection with higher order terms (platepos.c) */
822 extern int platepos();	/* Convert from pixel location to RA,Dec */
823 extern int platepix();	/* Convert from RA,Dec to pixel location */
824 extern void SetFITSPlate(); /* Set FITS header plate fit coefficients from structure */
825 extern int SetPlate();	/* Set plate fit coefficients in structure from arguments */
826 extern int GetPlate();	/* Return plate fit coefficients from structure in arguments */
827 
828 /* IRAF TAN projection with higher order terms (tnxpos.c) */
829 extern int tnxinit();	/* initialize the gnomonic forward or inverse transform */
830 extern int tnxpos();	/* forward transform (physical to world) gnomonic projection. */
831 extern int tnxpix();	/* Inverse transform (world to physical) gnomonic projection */
832 
833 /* IRAF ZPN projection with higher order terms (zpxpos.c) */
834 extern int zpxinit();	/* initialize the gnomonic forward or inverse transform */
835 extern int zpxpos();	/* forward transform (physical to world) gnomonic projection. */
836 extern int zpxpix();	/* Inverse transform (world to physical) gnomonic projection */
837 
838 #endif	/* __STDC__ */
839 
840 #ifdef __cplusplus
841 }
842 #endif
843 
844 #endif	/* _wcs_h_ */
845 
846 /* Oct 26 1994	New file
847  * Dec 21 1994	Add rotation matrix
848  * Dec 22 1994	Add flag for coordinate reversal
849 
850  * Mar  6 1995	Add parameters for Digital Sky Survey plate fit
851  * Jun  8 1995	Add parameters for coordinate system change
852  * Jun 21 1995	Add parameter for plate scale
853  * Jul  6 1995	Add parameter to note whether WCS is set
854  * Aug  8 1995	Add parameter to note whether to print coordinate system
855  * Oct 16 1995	Add parameters to save image dimensions and center coordinates
856 
857  * Feb 15 1996	Add coordinate conversion functions
858  * Feb 20 1996	Add flag for tab tables
859  * Apr 26 1996	Add epoch of positions (actual date of image)
860  * Jul  5 1996	Add subroutine declarations
861  * Jul 19 1996	Add WCSFULL declaration
862  * Aug  5 1996	Add WCSNINIT to initialize WCS for non-terminated header
863  * Oct 31 1996	Add DCnn inverse rotation matrix
864  * Nov  1 1996	Add NDEC number of decimal places in output
865  *
866  * May 22 1997	Change range of pcode from 1-8 to -1-8 for linear transform
867  * Sep 12 1997	Add chip rotation MROT, XMPIX, YMPIX
868  *
869  * Jan  7 1998	Add INSTRUME and DETECTOR for HST metric correction
870  * Jan 16 1998	Add Mark Calabretta's WCSLIB data structures
871  * Jan 16 1998	Add LONGPOLE, LATPOLE, and PROJP constants for Calabretta
872  * Jan 22 1998	Add ctype[], crpix[], crval[], and cdelt[] for Calabretta
873  * Jan 23 1998	Change wcsset() to wcsxinit() and pcode to prjcode
874  * Jan 23 1998	Define projection type flags
875  * Jan 26 1998	Remove chip rotation
876  * Jan 26 1998	Add chip correction polynomial
877  * Feb  3 1998	Add number of coefficients for residual fit
878  * Feb  5 1998	Make cd and dc matrices vectors, not individual elements
879  * Feb 19 1998	Add projection names
880  * Feb 23 1998	Add TNX projection from NOAO
881  * Mar  3 1998	Add NOAO plate fit and residual fit
882  * Mar 12 1998	Add variables for TNX correction surface
883  * Mar 23 1998	Add PLT plate fit polynomial projection; reassign DSS
884  * Mar 23 1998	Drop plate_fit flag from structure
885  * Mar 25 1998	Add npcoeff to wcs structure for new plate fit WCS
886  * Apr  7 1998	Change amd_i_coeff to i_coeff
887  * Apr  8 1998	Add wcseqset() and wcsreset() subroutine declarations
888  * Apr 10 1998	Rearrange order of nonstandard WCS types
889  * Apr 13 1998	Add setdefwcs() subroutine declaration
890  * Apr 14 1998	Add coordinate systems and wcscoor()
891  * Apr 24 1998	Add units
892  * Apr 28 1998	Change coordinate system flags to WCS_*
893  * Apr 28 1998	Change projection flags to WCS_*
894  * Apr 28 1998	Add wcsc2pix()
895  * May  7 1998	Add C++ declarations
896  * May 13 1998	Add eqin and eqout for conversions to and from equinoxes
897  * May 14 1998	Add declarations for coordinate conversion subroutines
898  * May 27 1998	Add blsearch()
899  * May 27 1998	Change linear projection back to WCS_LIN from WCS_LPR
900  * May 27 1998	Move hget.c and hput.c C++ declarations to fitshead.h
901  * May 27 1998	Include fitshead.h
902  * May 29 1998	Add wcskinit()
903  * Jun  1 1998	Add wcserr()
904  * Jun 11 1998	Add initialization support subroutines
905  * Jun 18 1998	Add wcspcset()
906  * Jun 25 1998	Add wcsndec()
907  * Jul  6 1998	Add wcszin() and wcszout() to use third dimension of images
908  * Jul  7 1998	Change setdegout() to setwcsdeg(); setlinmode() to setwcslin()
909  * Jul 17 1998	Add savewcscoor(), getwcscoor(), savewcscom(), and getwcscom()
910  * Aug 14 1998	Add freewcscom(), setwcscom(), and multiple WCS commands
911  * Sep  3 1998	Add pa_north, pa_east, imrot and imflip to wcs structure
912  * Sep 14 1998	Add latbase for AXAF North Polar angle (NPOL not LAT-)
913  * Sep 16 1998	Make WCS_system start at 1; add NPOLE
914  * Sep 17 1998	Add wcscstr()
915  * Sep 21 1998	Add wcsconp() to convert proper motions, too.
916  * Dec  2 1998	Add WCS type for planet surface
917 
918  * Jan 20 1999	Add declaration of wcsfree()
919  * Jun 16 1999	Add declaration of wcsrange()
920  * Oct 21 1999	Add declaration of setwcsfile()
921  *
922  * Jan 28 2000	Add flags for choice of WCS projection subroutines
923  * Jun 26 2000	Add XY coordinate system
924  * Nov  2 2000	Add wcsconv() to convert coordinates when parallax or rv known
925  *
926  * Jan 17 2001	Add idpix and ndpix for trim section, ltm for readout rotation
927  * Jan 31 2001	Add wcsinitn(), wcsninitn(), wcsinitc(), and wcsninitc()
928  * Feb 20 2001	Add wcs->wcs to main data structure
929  * Mar 20 2001	Close unclosed comment in wcsconv() argument list
930  *
931  * Apr  3 2002	Add SZP and second GLS/SFL projection
932  * Apr  9 2002	Add wcs->wcsdep for pointer to WCS depending on this WCS
933  * Apr 26 2002	Add wcs->wcsname and wcs->wcschar to identify WCS structure
934  * May  9 2002	Add wcs->radvel and wcs->zvel for radial velocity in km/sec
935  *
936  * Apr  1 2003	Add wcs->distort Distort structure for distortion correction
937  * Apr  1 2003	Add foc2pix() and pix2foc() subroutines for distortion correction
938  * May  1 2003	Add missing semicolons after C++ declarations of previous two functions
939  * Oct  1 2003	Rename wcs->naxes to wcs->naxis to match WCSLIB 3.2
940  * Nov  3 2003	Add distinit(), setdistcode(), and getdistcode() to distort.c
941  * Dec  3 2003	Add back wcs->naxes for backward compatibility
942  *
943  * Aug 30 2004	Add DelDistort()
944  *
945  * Nov  1 2005	Add WCS_ICRS
946  *
947  * Jan  5 2006	Add secrad()
948  * Apr 21 2006	Increase maximum number of axes from 4 to 8
949  * Apr 24 2006	Increase maximum number of axes to 9
950  * Nov 29 2006	Drop semicolon at end of C++ ifdef
951  * Dec 21 2006	Add cpwcs()
952  *
953  * Jan  4 2007	Drop extra declaration of wcscstr()
954  * Jan  4 2007	Fix declarations so ANSI prototypes are not just for C++
955  * Jan  9 2007	Add fk425e() and fk524e() subroutines
956  * Jan  9 2007	Add worldpos.c, dsspos.c, platepos.c, and tnxpos.c subroutines
957  * Jan 10 2007	Add ANSI prototypes for all subroutines
958  * Feb  1 2007	Add wcs.wcslog for log wavelength
959  * Jul 25 2007	Add v2s3(), s2v3(), d2v3(), v2d3() for coordinate-vector conversion
960  *
961  * Mar 31 2010	Add wcsdist1(), an alternate method
962  * Apr 07 2010	Add NWCSTYPE to keep it aligned with actual number of WCS types
963  *
964  * Mar 11 2011	Add NOAO ZPX projection parameters and subroutines (Frank Valdes)
965  * Mar 14 2011	Add SCAMP polynomial projection coefficients
966  * Sep  1 2011	Add TPV TAN projectioin with SCAT PV terms
967  * Sep  9 2011	Fix comment on TPV declaration
968  *
969  * Feb  1 2013	Add uppercase() from wcsinit()
970  * Feb 25 2013	Pass const string to uppercase()
971  *
972  * Jun  8 2016	Increase projection code from 9 to 16 characters for SIP distortion
973  * Jun 23 2016	Set MAXNKWD here; used for copying keywords in cpwcs()
974  */
975