WCSLIB  7.3
wcs.h
Go to the documentation of this file.
1 /*============================================================================
2 
3  WCSLIB 7.3 - an implementation of the FITS WCS standard.
4  Copyright (C) 1995-2020, Mark Calabretta
5 
6  This file is part of WCSLIB.
7 
8  WCSLIB is free software: you can redistribute it and/or modify it under the
9  terms of the GNU Lesser General Public License as published by the Free
10  Software Foundation, either version 3 of the License, or (at your option)
11  any later version.
12 
13  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16  more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with WCSLIB. If not, see http://www.gnu.org/licenses.
20 
21  Direct correspondence concerning WCSLIB to mark@calabretta.id.au
22 
23  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
24  http://www.atnf.csiro.au/people/Mark.Calabretta
25  $Id: wcs.h,v 7.3 2020/06/03 03:37:02 mcalabre Exp $
26 *=============================================================================
27 *
28 * WCSLIB 7.3 - C routines that implement the FITS World Coordinate System
29 * (WCS) standard. Refer to the README file provided with WCSLIB for an
30 * overview of the library.
31 *
32 *
33 * Summary of the wcs routines
34 * ---------------------------
35 * Routines in this suite implement the FITS World Coordinate System (WCS)
36 * standard which defines methods to be used for computing world coordinates
37 * from image pixel coordinates, and vice versa. The standard, and proposed
38 * extensions for handling distortions, are described in
39 *
40 = "Representations of world coordinates in FITS",
41 = Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (WCS Paper I)
42 =
43 = "Representations of celestial coordinates in FITS",
44 = Calabretta, M.R., & Greisen, E.W. 2002, A&A, 395, 1077 (WCS Paper II)
45 =
46 = "Representations of spectral coordinates in FITS",
47 = Greisen, E.W., Calabretta, M.R., Valdes, F.G., & Allen, S.L.
48 = 2006, A&A, 446, 747 (WCS Paper III)
49 =
50 = "Representations of distortions in FITS world coordinate systems",
51 = Calabretta, M.R. et al. (WCS Paper IV, draft dated 2004/04/22),
52 = available from http://www.atnf.csiro.au/people/Mark.Calabretta
53 =
54 = "Mapping on the HEALPix grid",
55 = Calabretta, M.R., & Roukema, B.F. 2007, MNRAS, 381, 865 (WCS Paper V)
56 =
57 = "Representing the 'Butterfly' Projection in FITS -- Projection Code XPH",
58 = Calabretta, M.R., & Lowe, S.R. 2013, PASA, 30, e050 (WCS Paper VI)
59 =
60 = "Representations of time coordinates in FITS -
61 = Time and relative dimension in space",
62 = Rots, A.H., Bunclark, P.S., Calabretta, M.R., Allen, S.L.,
63 = Manchester, R.N., & Thompson, W.T. 2015, A&A, 574, A36 (WCS Paper VII)
64 *
65 * These routines are based on the wcsprm struct which contains all information
66 * needed for the computations. The struct contains some members that must be
67 * set by the user, and others that are maintained by these routines, somewhat
68 * like a C++ class but with no encapsulation.
69 *
70 * wcsnpv(), wcsnps(), wcsini(), wcsinit(), wcssub(), and wcsfree() are
71 * provided to manage the wcsprm struct and another, wcsprt(), prints its
72 * contents. Refer to the description of the wcsprm struct for an explanation
73 * of the anticipated usage of these routines. wcscopy(), which does a deep
74 * copy of one wcsprm struct to another, is defined as a preprocessor macro
75 * function that invokes wcssub().
76 *
77 * wcsperr() prints the error message(s) (if any) stored in a wcsprm struct,
78 * and the linprm, celprm, prjprm, spcprm, and tabprm structs that it contains.
79 *
80 * A setup routine, wcsset(), computes intermediate values in the wcsprm struct
81 * from parameters in it that were supplied by the user. The struct always
82 * needs to be set up by wcsset() but this need not be called explicitly -
83 * refer to the explanation of wcsprm::flag.
84 *
85 * wcsp2s() and wcss2p() implement the WCS world coordinate transformations.
86 * In fact, they are high level driver routines for the WCS linear,
87 * logarithmic, celestial, spectral and tabular transformation routines
88 * described in lin.h, log.h, cel.h, spc.h and tab.h.
89 *
90 * Given either the celestial longitude or latitude plus an element of the
91 * pixel coordinate a hybrid routine, wcsmix(), iteratively solves for the
92 * unknown elements.
93 *
94 * wcssptr() translates the spectral axis in a wcsprm struct. For example, a
95 * 'FREQ' axis may be translated into 'ZOPT-F2W' and vice versa.
96 *
97 * wcslib_version() returns the WCSLIB version number.
98 *
99 * Quadcube projections:
100 * ---------------------
101 * The quadcube projections (TSC, CSC, QSC) may be represented in FITS in
102 * either of two ways:
103 *
104 * a: The six faces may be laid out in one plane and numbered as follows:
105 *
106 = 0
107 =
108 = 4 3 2 1 4 3 2
109 =
110 = 5
111 *
112 * Faces 2, 3 and 4 may appear on one side or the other (or both). The
113 * world-to-pixel routines map faces 2, 3 and 4 to the left but the
114 * pixel-to-world routines accept them on either side.
115 *
116 * b: The "COBE" convention in which the six faces are stored in a
117 * three-dimensional structure using a CUBEFACE axis indexed from
118 * 0 to 5 as above.
119 *
120 * These routines support both methods; wcsset() determines which is being
121 * used by the presence or absence of a CUBEFACE axis in ctype[]. wcsp2s()
122 * and wcss2p() translate the CUBEFACE axis representation to the single
123 * plane representation understood by the lower-level WCSLIB projection
124 * routines.
125 *
126 *
127 * wcsnpv() - Memory allocation for PVi_ma
128 * ---------------------------------------
129 * wcsnpv() sets or gets the value of NPVMAX (default 64). This global
130 * variable controls the number of pvcard structs, for holding PVi_ma
131 * keyvalues, that wcsini() should allocate space for. It is also used by
132 * wcsinit() as the default value of npvmax.
133 *
134 * PLEASE NOTE: This function is not thread-safe.
135 *
136 * Given:
137 * n int Value of NPVMAX; ignored if < 0. Use a value less
138 * than zero to get the current value.
139 *
140 * Function return value:
141 * int Current value of NPVMAX.
142 *
143 *
144 * wcsnps() - Memory allocation for PSi_ma
145 * ---------------------------------------
146 * wcsnps() sets or gets the value of NPSMAX (default 8). This global variable
147 * controls the number of pscard structs, for holding PSi_ma keyvalues, that
148 * wcsini() should allocate space for. It is also used by wcsinit() as the
149 * default value of npsmax.
150 *
151 * PLEASE NOTE: This function is not thread-safe.
152 *
153 * Given:
154 * n int Value of NPSMAX; ignored if < 0. Use a value less
155 * than zero to get the current value.
156 *
157 * Function return value:
158 * int Current value of NPSMAX.
159 *
160 *
161 * wcsini() - Default constructor for the wcsprm struct
162 * ----------------------------------------------------
163 * wcsini() is a thin wrapper on wcsinit(). It invokes it with npvmax,
164 * npsmax, and ndpmax set to -1 which causes it to use the values of the
165 * global variables NDPMAX, NPSMAX, and NDPMAX. It is thereby potentially
166 * thread-unsafe if these variables are altered dynamically via wcsnpv(),
167 * wcsnps(), and disndp(). Use wcsinit() for a thread-safe alternative in
168 * this case.
169 *
170 *
171 * wcsinit() - Default constructor for the wcsprm struct
172 * -----------------------------------------------------
173 * wcsinit() optionally allocates memory for arrays in a wcsprm struct and sets
174 * all members of the struct to default values.
175 *
176 * PLEASE NOTE: every wcsprm struct should be initialized by wcsinit(),
177 * possibly repeatedly. On the first invokation, and only the first
178 * invokation, wcsprm::flag must be set to -1 to initialize memory management,
179 * regardless of whether wcsinit() will actually be used to allocate memory.
180 *
181 * Given:
182 * alloc int If true, allocate memory unconditionally for the
183 * crpix, etc. arrays. Please note that memory is never
184 * allocated by wcsinit() for the auxprm, tabprm, nor
185 * wtbarr structs.
186 *
187 * If false, it is assumed that pointers to these arrays
188 * have been set by the user except if they are null
189 * pointers in which case memory will be allocated for
190 * them regardless. (In other words, setting alloc true
191 * saves having to initalize these pointers to zero.)
192 *
193 * naxis int The number of world coordinate axes. This is used to
194 * determine the length of the various wcsprm vectors and
195 * matrices and therefore the amount of memory to
196 * allocate for them.
197 *
198 * Given and returned:
199 * wcs struct wcsprm*
200 * Coordinate transformation parameters.
201 *
202 * Note that, in order to initialize memory management,
203 * wcsprm::flag should be set to -1 when wcs is
204 * initialized for the first time (memory leaks may
205 * result if it had already been initialized).
206 *
207 * Given:
208 * npvmax int The number of PVi_ma keywords to allocate space for.
209 * If set to -1, the value of the global variable NPVMAX
210 * will be used. This is potentially thread-unsafe if
211 * wcsnpv() is being used dynamically to alter its value.
212 *
213 * npsmax int The number of PSi_ma keywords to allocate space for.
214 * If set to -1, the value of the global variable NPSMAX
215 * will be used. This is potentially thread-unsafe if
216 * wcsnps() is being used dynamically to alter its value.
217 *
218 * ndpmax int The number of DPja or DQia keywords to allocate space
219 * for. If set to -1, the value of the global variable
220 * NDPMAX will be used. This is potentially
221 * thread-unsafe if disndp() is being used dynamically to
222 * alter its value.
223 *
224 * Function return value:
225 * int Status return value:
226 * 0: Success.
227 * 1: Null wcsprm pointer passed.
228 * 2: Memory allocation failed.
229 *
230 * For returns > 1, a detailed error message is set in
231 * wcsprm::err if enabled, see wcserr_enable().
232 *
233 *
234 * wcsauxi() - Default constructor for the auxprm struct
235 * -----------------------------------------------------
236 * wcsauxi() optionally allocates memory for an auxprm struct, attaches it to
237 * wcsprm, and sets all members of the struct to default values.
238 *
239 * Given:
240 * alloc int If true, allocate memory unconditionally for the
241 * auxprm struct.
242 *
243 * If false, it is assumed that wcsprm::aux has already
244 * been set to point to an auxprm struct, in which case
245 * the user is responsible for managing that memory.
246 * However, if wcsprm::aux is a null pointer, memory will
247 * be allocated regardless. (In other words, setting
248 * alloc true saves having to initalize the pointer to
249 * zero.)
250 *
251 * Given and returned:
252 * wcs struct wcsprm*
253 * Coordinate transformation parameters.
254 *
255 * Function return value:
256 * int Status return value:
257 * 0: Success.
258 * 1: Null wcsprm pointer passed.
259 * 2: Memory allocation failed.
260 *
261 *
262 * wcssub() - Subimage extraction routine for the wcsprm struct
263 * ------------------------------------------------------------
264 * wcssub() extracts the coordinate description for a subimage from a wcsprm
265 * struct. It does a deep copy, using wcsinit() to allocate memory for its
266 * arrays if required. Only the "information to be provided" part of the
267 * struct is extracted. Consequently, wcsset() need not have been, and won't
268 * be invoked on the struct from which the subimage is extracted. A call to
269 * wcsset() is required to set up the subimage struct.
270 *
271 * The world coordinate system of the subimage must be separable in the sense
272 * that the world coordinates at any point in the subimage must depend only on
273 * the pixel coordinates of the axes extracted. In practice, this means that
274 * the linear transformation matrix of the original image must not contain
275 * non-zero off-diagonal terms that associate any of the subimage axes with any
276 * of the non-subimage axes. Likewise, if any distortions are associated with
277 * the subimage axes, they must not depend on any of the axes that are not
278 * being extracted.
279 *
280 * Note that while the required elements of the tabprm array are extracted, the
281 * wtbarr array is not. (Thus it is not appropriate to call wcssub() after
282 * wcstab() but before filling the tabprm structs - refer to wcshdr.h.)
283 *
284 * wcssub() can also add axes to a wcsprm struct. The new axes will be created
285 * using the defaults set by wcsinit() which produce a simple, unnamed, linear
286 * axis with world coordinate equal to the pixel coordinate. These default
287 * values can be changed afterwards, before invoking wcsset().
288 *
289 * Given:
290 * alloc int If true, allocate memory for the crpix, etc. arrays in
291 * the destination. Otherwise, it is assumed that
292 * pointers to these arrays have been set by the user
293 * except if they are null pointers in which case memory
294 * will be allocated for them regardless.
295 *
296 * wcssrc const struct wcsprm*
297 * Struct to extract from.
298 *
299 * Given and returned:
300 * nsub int*
301 * axes int[] Vector of length *nsub containing the image axis
302 * numbers (1-relative) to extract. Order is
303 * significant; axes[0] is the axis number of the input
304 * image that corresponds to the first axis in the
305 * subimage, etc.
306 *
307 * Use an axis number of 0 to create a new axis using
308 * the defaults set by wcsinit(). They can be changed
309 * later.
310 *
311 * nsub (the pointer) may be set to zero, and so also may
312 * *nsub, which is interpreted to mean all axes in the
313 * input image; the number of axes will be returned if
314 * nsub != 0x0. axes itself (the pointer) may be set to
315 * zero to indicate the first *nsub axes in their
316 * original order.
317 *
318 * Set both nsub (or *nsub) and axes to zero to do a deep
319 * copy of one wcsprm struct to another.
320 *
321 * Subimage extraction by coordinate axis type may be
322 * done by setting the elements of axes[] to the
323 * following special preprocessor macro values:
324 *
325 * WCSSUB_LONGITUDE: Celestial longitude.
326 * WCSSUB_LATITUDE: Celestial latitude.
327 * WCSSUB_CUBEFACE: Quadcube CUBEFACE axis.
328 * WCSSUB_SPECTRAL: Spectral axis.
329 * WCSSUB_STOKES: Stokes axis.
330 *
331 * Refer to the notes (below) for further usage examples.
332 *
333 * On return, *nsub will be set to the number of axes in
334 * the subimage; this may be zero if there were no axes
335 * of the required type(s) (in which case no memory will
336 * be allocated). axes[] will contain the axis numbers
337 * that were extracted, or 0 for newly created axes. The
338 * vector length must be sufficient to contain all axis
339 * numbers. No checks are performed to verify that the
340 * coordinate axes are consistent, this is done by
341 * wcsset().
342 *
343 * wcsdst struct wcsprm*
344 * Struct describing the subimage. wcsprm::flag should
345 * be set to -1 if wcsdst was not previously initialized
346 * (memory leaks may result if it was previously
347 * initialized).
348 *
349 * Function return value:
350 * int Status return value:
351 * 0: Success.
352 * 1: Null wcsprm pointer passed.
353 * 2: Memory allocation failed.
354 * 12: Invalid subimage specification.
355 * 13: Non-separable subimage coordinate system.
356 *
357 * For returns > 1, a detailed error message is set in
358 * wcsprm::err if enabled, see wcserr_enable().
359 *
360 * Notes:
361 * Combinations of subimage axes of particular types may be extracted in the
362 * same order as they occur in the input image by combining preprocessor
363 * codes, for example
364 *
365 = *nsub = 1;
366 = axes[0] = WCSSUB_LONGITUDE | WCSSUB_LATITUDE | WCSSUB_SPECTRAL;
367 *
368 * would extract the longitude, latitude, and spectral axes in the same order
369 * as the input image. If one of each were present, *nsub = 3 would be
370 * returned.
371 *
372 * For convenience, WCSSUB_CELESTIAL is defined as the combination
373 * WCSSUB_LONGITUDE | WCSSUB_LATITUDE | WCSSUB_CUBEFACE.
374 *
375 * The codes may also be negated to extract all but the types specified, for
376 * example
377 *
378 = *nsub = 4;
379 = axes[0] = WCSSUB_LONGITUDE;
380 = axes[1] = WCSSUB_LATITUDE;
381 = axes[2] = WCSSUB_CUBEFACE;
382 = axes[3] = -(WCSSUB_SPECTRAL | WCSSUB_STOKES);
383 *
384 * The last of these specifies all axis types other than spectral or Stokes.
385 * Extraction is done in the order specified by axes[] a longitude axis (if
386 * present) would be extracted first (via axes[0]) and not subsequently (via
387 * axes[3]). Likewise for the latitude and cubeface axes in this example.
388 *
389 * From the foregoing, it is apparent that the value of *nsub returned may be
390 * less than or greater than that given. However, it will never exceed the
391 * number of axes in the input image (plus the number of newly-created axes
392 * if any were specified on input).
393 *
394 *
395 * wcscompare() - Compare two wcsprm structs for equality
396 * ------------------------------------------------------
397 * wcscompare() compares two wcsprm structs for equality.
398 *
399 * Given:
400 * cmp int A bit field controlling the strictness of the
401 * comparison. When 0, all fields must be identical.
402 *
403 * The following constants may be or'ed together to
404 * relax the comparison:
405 * WCSCOMPARE_ANCILLARY: Ignore ancillary keywords
406 * that don't change the WCS transformation, such
407 * as DATE-OBS or EQUINOX.
408 * WCSCOMPARE_TILING: Ignore integral differences in
409 * CRPIXja. This is the 'tiling' condition, where
410 * two WCSes cover different regions of the same
411 * map projection and align on the same map grid.
412 * WCSCOMPARE_CRPIX: Ignore any differences at all in
413 * CRPIXja. The two WCSes cover different regions
414 * of the same map projection but may not align on
415 * the same map grid. Overrides WCSCOMPARE_TILING.
416 *
417 * tol double Tolerance for comparison of floating-point values.
418 * For example, for tol == 1e-6, all floating-point
419 * values in the structs must be equal to the first 6
420 * decimal places. A value of 0 implies exact equality.
421 *
422 * wcs1 const struct wcsprm*
423 * The first wcsprm struct to compare.
424 *
425 * wcs2 const struct wcsprm*
426 * The second wcsprm struct to compare.
427 *
428 * Returned:
429 * equal int* Non-zero when the given structs are equal.
430 *
431 * Function return value:
432 * int Status return value:
433 * 0: Success.
434 * 1: Null pointer passed.
435 *
436 *
437 * wcscopy() macro - Copy routine for the wcsprm struct
438 * ----------------------------------------------------
439 * wcscopy() does a deep copy of one wcsprm struct to another. As of
440 * WCSLIB 3.6, it is implemented as a preprocessor macro that invokes
441 * wcssub() with the nsub and axes pointers both set to zero.
442 *
443 *
444 * wcsfree() - Destructor for the wcsprm struct
445 * --------------------------------------------
446 * wcsfree() frees memory allocated for the wcsprm arrays by wcsinit() and/or
447 * wcsset(). wcsinit() records the memory it allocates and wcsfree() will only
448 * attempt to free this.
449 *
450 * PLEASE NOTE: wcsfree() must not be invoked on a wcsprm struct that was not
451 * initialized by wcsinit().
452 *
453 * Returned:
454 * wcs struct wcsprm*
455 * Coordinate transformation parameters.
456 *
457 * Function return value:
458 * int Status return value:
459 * 0: Success.
460 * 1: Null wcsprm pointer passed.
461 *
462 *
463 * wcsprt() - Print routine for the wcsprm struct
464 * ----------------------------------------------
465 * wcsprt() prints the contents of a wcsprm struct using wcsprintf(). Mainly
466 * intended for diagnostic purposes.
467 *
468 * Given:
469 * wcs const struct wcsprm*
470 * Coordinate transformation parameters.
471 *
472 * Function return value:
473 * int Status return value:
474 * 0: Success.
475 * 1: Null wcsprm pointer passed.
476 *
477 *
478 * wcsperr() - Print error messages from a wcsprm struct
479 * -----------------------------------------------------
480 * wcsperr() prints the error message(s), if any, stored in a wcsprm struct,
481 * and the linprm, celprm, prjprm, spcprm, and tabprm structs that it contains.
482 * If there are no errors then nothing is printed. It uses wcserr_prt(), q.v.
483 *
484 * Given:
485 * wcs const struct wcsprm*
486 * Coordinate transformation parameters.
487 *
488 * prefix const char *
489 * If non-NULL, each output line will be prefixed with
490 * this string.
491 *
492 * Function return value:
493 * int Status return value:
494 * 0: Success.
495 * 1: Null wcsprm pointer passed.
496 *
497 *
498 * wcsbchk() - Enable/disable bounds checking
499 * ------------------------------------------
500 * wcsbchk() is used to control bounds checking in the projection routines.
501 * Note that wcsset() always enables bounds checking. wcsbchk() will invoke
502 * wcsset() on the wcsprm struct beforehand if necessary.
503 *
504 * Given and returned:
505 * wcs struct wcsprm*
506 * Coordinate transformation parameters.
507 *
508 * Given:
509 * bounds int If bounds&1 then enable strict bounds checking for the
510 * spherical-to-Cartesian (s2x) transformation for the
511 * AZP, SZP, TAN, SIN, ZPN, and COP projections.
512 *
513 * If bounds&2 then enable strict bounds checking for the
514 * Cartesian-to-spherical (x2s) transformation for the
515 * HPX and XPH projections.
516 *
517 * If bounds&4 then enable bounds checking on the native
518 * coordinates returned by the Cartesian-to-spherical
519 * (x2s) transformations using prjchk().
520 *
521 * Zero it to disable all checking.
522 *
523 * Function return value:
524 * int Status return value:
525 * 0: Success.
526 * 1: Null wcsprm pointer passed.
527 *
528 *
529 * wcsset() - Setup routine for the wcsprm struct
530 * ----------------------------------------------
531 * wcsset() sets up a wcsprm struct according to information supplied within
532 * it (refer to the description of the wcsprm struct).
533 *
534 * wcsset() recognizes the NCP projection and converts it to the equivalent SIN
535 * projection and likewise translates GLS into SFL. It also translates the
536 * AIPS spectral types ('FREQ-LSR', 'FELO-HEL', etc.), possibly changing the
537 * input header keywords wcsprm::ctype and/or wcsprm::specsys if necessary.
538 *
539 * Note that this routine need not be called directly; it will be invoked by
540 * wcsp2s() and wcss2p() if the wcsprm::flag is anything other than a
541 * predefined magic value.
542 *
543 * Given and returned:
544 * wcs struct wcsprm*
545 * Coordinate transformation parameters.
546 *
547 * Function return value:
548 * int Status return value:
549 * 0: Success.
550 * 1: Null wcsprm pointer passed.
551 * 2: Memory allocation failed.
552 * 3: Linear transformation matrix is singular.
553 * 4: Inconsistent or unrecognized coordinate axis
554 * types.
555 * 5: Invalid parameter value.
556 * 6: Invalid coordinate transformation parameters.
557 * 7: Ill-conditioned coordinate transformation
558 * parameters.
559 *
560 * For returns > 1, a detailed error message is set in
561 * wcsprm::err if enabled, see wcserr_enable().
562 *
563 * Notes:
564 * wcsset() always enables strict bounds checking in the projection routines
565 * (via a call to prjini()). Use wcsbchk() to modify bounds-checking after
566 * wcsset() is invoked.
567 *
568 *
569 * wcsp2s() - Pixel-to-world transformation
570 * ----------------------------------------
571 * wcsp2s() transforms pixel coordinates to world coordinates.
572 *
573 * Given and returned:
574 * wcs struct wcsprm*
575 * Coordinate transformation parameters.
576 *
577 * Given:
578 * ncoord,
579 * nelem int The number of coordinates, each of vector length
580 * nelem but containing wcs.naxis coordinate elements.
581 * Thus nelem must equal or exceed the value of the
582 * NAXIS keyword unless ncoord == 1, in which case nelem
583 * is not used.
584 *
585 * pixcrd const double[ncoord][nelem]
586 * Array of pixel coordinates.
587 *
588 * Returned:
589 * imgcrd double[ncoord][nelem]
590 * Array of intermediate world coordinates. For
591 * celestial axes, imgcrd[][wcs.lng] and
592 * imgcrd[][wcs.lat] are the projected x-, and
593 * y-coordinates in pseudo "degrees". For spectral
594 * axes, imgcrd[][wcs.spec] is the intermediate spectral
595 * coordinate, in SI units.
596 *
597 * phi,theta double[ncoord]
598 * Longitude and latitude in the native coordinate system
599 * of the projection [deg].
600 *
601 * world double[ncoord][nelem]
602 * Array of world coordinates. For celestial axes,
603 * world[][wcs.lng] and world[][wcs.lat] are the
604 * celestial longitude and latitude [deg]. For
605 * spectral axes, imgcrd[][wcs.spec] is the intermediate
606 * spectral coordinate, in SI units.
607 *
608 * stat int[ncoord]
609 * Status return value for each coordinate:
610 * 0: Success.
611 * 1+: A bit mask indicating invalid pixel coordinate
612 * element(s).
613 *
614 * Function return value:
615 * int Status return value:
616 * 0: Success.
617 * 1: Null wcsprm pointer passed.
618 * 2: Memory allocation failed.
619 * 3: Linear transformation matrix is singular.
620 * 4: Inconsistent or unrecognized coordinate axis
621 * types.
622 * 5: Invalid parameter value.
623 * 6: Invalid coordinate transformation parameters.
624 * 7: Ill-conditioned coordinate transformation
625 * parameters.
626 * 8: One or more of the pixel coordinates were
627 * invalid, as indicated by the stat vector.
628 *
629 * For returns > 1, a detailed error message is set in
630 * wcsprm::err if enabled, see wcserr_enable().
631 *
632 *
633 * wcss2p() - World-to-pixel transformation
634 * ----------------------------------------
635 * wcss2p() transforms world coordinates to pixel coordinates.
636 *
637 * Given and returned:
638 * wcs struct wcsprm*
639 * Coordinate transformation parameters.
640 *
641 * Given:
642 * ncoord,
643 * nelem int The number of coordinates, each of vector length nelem
644 * but containing wcs.naxis coordinate elements. Thus
645 * nelem must equal or exceed the value of the NAXIS
646 * keyword unless ncoord == 1, in which case nelem is not
647 * used.
648 *
649 * world const double[ncoord][nelem]
650 * Array of world coordinates. For celestial axes,
651 * world[][wcs.lng] and world[][wcs.lat] are the
652 * celestial longitude and latitude [deg]. For spectral
653 * axes, world[][wcs.spec] is the spectral coordinate, in
654 * SI units.
655 *
656 * Returned:
657 * phi,theta double[ncoord]
658 * Longitude and latitude in the native coordinate
659 * system of the projection [deg].
660 *
661 * imgcrd double[ncoord][nelem]
662 * Array of intermediate world coordinates. For
663 * celestial axes, imgcrd[][wcs.lng] and
664 * imgcrd[][wcs.lat] are the projected x-, and
665 * y-coordinates in pseudo "degrees". For quadcube
666 * projections with a CUBEFACE axis the face number is
667 * also returned in imgcrd[][wcs.cubeface]. For
668 * spectral axes, imgcrd[][wcs.spec] is the intermediate
669 * spectral coordinate, in SI units.
670 *
671 * pixcrd double[ncoord][nelem]
672 * Array of pixel coordinates.
673 *
674 * stat int[ncoord]
675 * Status return value for each coordinate:
676 * 0: Success.
677 * 1+: A bit mask indicating invalid world coordinate
678 * element(s).
679 *
680 * Function return value:
681 * int Status return value:
682 * 0: Success.
683 * 1: Null wcsprm pointer passed.
684 * 2: Memory allocation failed.
685 * 3: Linear transformation matrix is singular.
686 * 4: Inconsistent or unrecognized coordinate axis
687 * types.
688 * 5: Invalid parameter value.
689 * 6: Invalid coordinate transformation parameters.
690 * 7: Ill-conditioned coordinate transformation
691 * parameters.
692 * 9: One or more of the world coordinates were
693 * invalid, as indicated by the stat vector.
694 *
695 * For returns > 1, a detailed error message is set in
696 * wcsprm::err if enabled, see wcserr_enable().
697 *
698 *
699 * wcsmix() - Hybrid coordinate transformation
700 * -------------------------------------------
701 * wcsmix(), given either the celestial longitude or latitude plus an element
702 * of the pixel coordinate, solves for the remaining elements by iterating on
703 * the unknown celestial coordinate element using wcss2p(). Refer also to the
704 * notes below.
705 *
706 * Given and returned:
707 * wcs struct wcsprm*
708 * Indices for the celestial coordinates obtained
709 * by parsing the wcsprm::ctype[].
710 *
711 * Given:
712 * mixpix int Which element of the pixel coordinate is given.
713 *
714 * mixcel int Which element of the celestial coordinate is given:
715 * 1: Celestial longitude is given in
716 * world[wcs.lng], latitude returned in
717 * world[wcs.lat].
718 * 2: Celestial latitude is given in
719 * world[wcs.lat], longitude returned in
720 * world[wcs.lng].
721 *
722 * vspan const double[2]
723 * Solution interval for the celestial coordinate [deg].
724 * The ordering of the two limits is irrelevant.
725 * Longitude ranges may be specified with any convenient
726 * normalization, for example [-120,+120] is the same as
727 * [240,480], except that the solution will be returned
728 * with the same normalization, i.e. lie within the
729 * interval specified.
730 *
731 * vstep const double
732 * Step size for solution search [deg]. If zero, a
733 * sensible, although perhaps non-optimal default will be
734 * used.
735 *
736 * viter int If a solution is not found then the step size will be
737 * halved and the search recommenced. viter controls how
738 * many times the step size is halved. The allowed range
739 * is 5 - 10.
740 *
741 * Given and returned:
742 * world double[naxis]
743 * World coordinate elements. world[wcs.lng] and
744 * world[wcs.lat] are the celestial longitude and
745 * latitude [deg]. Which is given and which returned
746 * depends on the value of mixcel. All other elements
747 * are given.
748 *
749 * Returned:
750 * phi,theta double[naxis]
751 * Longitude and latitude in the native coordinate
752 * system of the projection [deg].
753 *
754 * imgcrd double[naxis]
755 * Image coordinate elements. imgcrd[wcs.lng] and
756 * imgcrd[wcs.lat] are the projected x-, and
757 * y-coordinates in pseudo "degrees".
758 *
759 * Given and returned:
760 * pixcrd double[naxis]
761 * Pixel coordinate. The element indicated by mixpix is
762 * given and the remaining elements are returned.
763 *
764 * Function return value:
765 * int Status return value:
766 * 0: Success.
767 * 1: Null wcsprm pointer passed.
768 * 2: Memory allocation failed.
769 * 3: Linear transformation matrix is singular.
770 * 4: Inconsistent or unrecognized coordinate axis
771 * types.
772 * 5: Invalid parameter value.
773 * 6: Invalid coordinate transformation parameters.
774 * 7: Ill-conditioned coordinate transformation
775 * parameters.
776 * 10: Invalid world coordinate.
777 * 11: No solution found in the specified interval.
778 *
779 * For returns > 1, a detailed error message is set in
780 * wcsprm::err if enabled, see wcserr_enable().
781 *
782 * Notes:
783 * Initially the specified solution interval is checked to see if it's a
784 * "crossing" interval. If it isn't, a search is made for a crossing
785 * solution by iterating on the unknown celestial coordinate starting at the
786 * upper limit of the solution interval and decrementing by the specified
787 * step size. A crossing is indicated if the trial value of the pixel
788 * coordinate steps through the value specified. If a crossing interval is
789 * found then the solution is determined by a modified form of "regula falsi"
790 * division of the crossing interval. If no crossing interval was found
791 * within the specified solution interval then a search is made for a
792 * "non-crossing" solution as may arise from a point of tangency. The
793 * process is complicated by having to make allowance for the discontinuities
794 * that occur in all map projections.
795 *
796 * Once one solution has been determined others may be found by subsequent
797 * invokations of wcsmix() with suitably restricted solution intervals.
798 *
799 * Note the circumstance that arises when the solution point lies at a native
800 * pole of a projection in which the pole is represented as a finite curve,
801 * for example the zenithals and conics. In such cases two or more valid
802 * solutions may exist but wcsmix() only ever returns one.
803 *
804 * Because of its generality wcsmix() is very compute-intensive. For
805 * compute-limited applications more efficient special-case solvers could be
806 * written for simple projections, for example non-oblique cylindrical
807 * projections.
808 *
809 *
810 * wcssptr() - Spectral axis translation
811 * -------------------------------------
812 * wcssptr() translates the spectral axis in a wcsprm struct. For example, a
813 * 'FREQ' axis may be translated into 'ZOPT-F2W' and vice versa.
814 *
815 * Given and returned:
816 * wcs struct wcsprm*
817 * Coordinate transformation parameters.
818 *
819 * i int* Index of the spectral axis (0-relative). If given < 0
820 * it will be set to the first spectral axis identified
821 * from the ctype[] keyvalues in the wcsprm struct.
822 *
823 * ctype char[9] Desired spectral CTYPEia. Wildcarding may be used as
824 * for the ctypeS2 argument to spctrn() as described in
825 * the prologue of spc.h, i.e. if the final three
826 * characters are specified as "???", or if just the
827 * eighth character is specified as '?', the correct
828 * algorithm code will be substituted and returned.
829 *
830 * Function return value:
831 * int Status return value:
832 * 0: Success.
833 * 1: Null wcsprm pointer passed.
834 * 2: Memory allocation failed.
835 * 3: Linear transformation matrix is singular.
836 * 4: Inconsistent or unrecognized coordinate axis
837 * types.
838 * 5: Invalid parameter value.
839 * 6: Invalid coordinate transformation parameters.
840 * 7: Ill-conditioned coordinate transformation
841 * parameters.
842 * 12: Invalid subimage specification (no spectral
843 * axis).
844 *
845 * For returns > 1, a detailed error message is set in
846 * wcsprm::err if enabled, see wcserr_enable().
847 *
848 *
849 * wcslib_version() - WCSLIB version number
850 * ----------------------------------------
851 * wcslib_version() returns the WCSLIB version number.
852 *
853 * The major version number changes when the ABI changes or when the license
854 * conditions change. ABI changes typically result from a change to the
855 * contents of one of the structs. The major version number is used to
856 * distinguish between incompatible versions of the sharable library.
857 *
858 * The minor version number changes with new functionality or bug fixes that do
859 * not involve a change in the ABI.
860 *
861 * The auxiliary version number (which is often absent) signals changes to the
862 * documentation, test suite, build procedures, or any other change that does
863 * not affect the compiled library.
864 *
865 * Returned:
866 * vers[3] int[3] The broken-down version number:
867 * 0: Major version number.
868 * 1: Minor version number.
869 * 2: Auxiliary version number (zero if absent).
870 * May be given as a null pointer if not required.
871 *
872 * Function return value:
873 * char* A null-terminated, statically allocated string
874 * containing the version number in the usual form, i.e.
875 * "<major>.<minor>.<auxiliary>".
876 *
877 *
878 * wcsprm struct - Coordinate transformation parameters
879 * ----------------------------------------------------
880 * The wcsprm struct contains information required to transform world
881 * coordinates. It consists of certain members that must be set by the user
882 * ("given") and others that are set by the WCSLIB routines ("returned").
883 * While the addresses of the arrays themselves may be set by wcsinit() if it
884 * (optionally) allocates memory, their contents must be set by the user.
885 *
886 * Some parameters that are given are not actually required for transforming
887 * coordinates. These are described as "auxiliary"; the struct simply provides
888 * a place to store them, though they may be used by wcshdo() in constructing a
889 * FITS header from a wcsprm struct. Some of the returned values are supplied
890 * for informational purposes and others are for internal use only as
891 * indicated.
892 *
893 * In practice, it is expected that a WCS parser would scan the FITS header to
894 * determine the number of coordinate axes. It would then use wcsinit() to
895 * allocate memory for arrays in the wcsprm struct and set default values.
896 * Then as it reread the header and identified each WCS keyrecord it would load
897 * the value into the relevant wcsprm array element. This is essentially what
898 * wcspih() does - refer to the prologue of wcshdr.h. As the final step,
899 * wcsset() is invoked, either directly or indirectly, to set the derived
900 * members of the wcsprm struct. wcsset() strips off trailing blanks in all
901 * string members and null-fills the character array.
902 *
903 * int flag
904 * (Given and returned) This flag must be set to zero whenever any of the
905 * following wcsprm struct members are set or changed:
906 *
907 * - wcsprm::naxis (q.v., not normally set by the user),
908 * - wcsprm::crpix,
909 * - wcsprm::pc,
910 * - wcsprm::cdelt,
911 * - wcsprm::crval,
912 * - wcsprm::cunit,
913 * - wcsprm::ctype,
914 * - wcsprm::lonpole,
915 * - wcsprm::latpole,
916 * - wcsprm::restfrq,
917 * - wcsprm::restwav,
918 * - wcsprm::npv,
919 * - wcsprm::pv,
920 * - wcsprm::nps,
921 * - wcsprm::ps,
922 * - wcsprm::cd,
923 * - wcsprm::crota,
924 * - wcsprm::altlin,
925 * - wcsprm::ntab,
926 * - wcsprm::nwtb,
927 * - wcsprm::tab,
928 * - wcsprm::wtb.
929 *
930 * This signals the initialization routine, wcsset(), to recompute the
931 * returned members of the celprm struct. celset() will reset flag to
932 * indicate that this has been done.
933 *
934 * PLEASE NOTE: flag should be set to -1 when wcsinit() is called for the
935 * first time for a particular wcsprm struct in order to initialize memory
936 * management. It must ONLY be used on the first initialization otherwise
937 * memory leaks may result.
938 *
939 * int naxis
940 * (Given or returned) Number of pixel and world coordinate elements.
941 *
942 * If wcsinit() is used to initialize the linprm struct (as would normally
943 * be the case) then it will set naxis from the value passed to it as a
944 * function argument. The user should not subsequently modify it.
945 *
946 * double *crpix
947 * (Given) Address of the first element of an array of double containing
948 * the coordinate reference pixel, CRPIXja.
949 *
950 * double *pc
951 * (Given) Address of the first element of the PCi_ja (pixel coordinate)
952 * transformation matrix. The expected order is
953 *
954 = struct wcsprm wcs;
955 = wcs.pc = {PC1_1, PC1_2, PC2_1, PC2_2};
956 *
957 * This may be constructed conveniently from a 2-D array via
958 *
959 = double m[2][2] = {{PC1_1, PC1_2},
960 = {PC2_1, PC2_2}};
961 *
962 * which is equivalent to
963 *
964 = double m[2][2];
965 = m[0][0] = PC1_1;
966 = m[0][1] = PC1_2;
967 = m[1][0] = PC2_1;
968 = m[1][1] = PC2_2;
969 *
970 * The storage order for this 2-D array is the same as for the 1-D array,
971 * whence
972 *
973 = wcs.pc = *m;
974 *
975 * would be legitimate.
976 *
977 * double *cdelt
978 * (Given) Address of the first element of an array of double containing
979 * the coordinate increments, CDELTia.
980 *
981 * double *crval
982 * (Given) Address of the first element of an array of double containing
983 * the coordinate reference values, CRVALia.
984 *
985 * char (*cunit)[72]
986 * (Given) Address of the first element of an array of char[72] containing
987 * the CUNITia keyvalues which define the units of measurement of the
988 * CRVALia, CDELTia, and CDi_ja keywords.
989 *
990 * As CUNITia is an optional header keyword, cunit[][72] may be left blank
991 * but otherwise is expected to contain a standard units specification as
992 * defined by WCS Paper I. Utility function wcsutrn(), described in
993 * wcsunits.h, is available to translate commonly used non-standard units
994 * specifications but this must be done as a separate step before invoking
995 * wcsset().
996 *
997 * For celestial axes, if cunit[][72] is not blank, wcsset() uses
998 * wcsunits() to parse it and scale cdelt[], crval[], and cd[][*] to
999 * degrees. It then resets cunit[][72] to "deg".
1000 *
1001 * For spectral axes, if cunit[][72] is not blank, wcsset() uses wcsunits()
1002 * to parse it and scale cdelt[], crval[], and cd[][*] to SI units. It
1003 * then resets cunit[][72] accordingly.
1004 *
1005 * wcsset() ignores cunit[][72] for other coordinate types; cunit[][72] may
1006 * be used to label coordinate values.
1007 *
1008 * These variables accomodate the longest allowed string-valued FITS
1009 * keyword, being limited to 68 characters, plus the null-terminating
1010 * character.
1011 *
1012 * char (*ctype)[72]
1013 * (Given) Address of the first element of an array of char[72] containing
1014 * the coordinate axis types, CTYPEia.
1015 *
1016 * The ctype[][72] keyword values must be in upper case and there must be
1017 * zero or one pair of matched celestial axis types, and zero or one
1018 * spectral axis. The ctype[][72] strings should be padded with blanks on
1019 * the right and null-terminated so that they are at least eight characters
1020 * in length.
1021 *
1022 * These variables accomodate the longest allowed string-valued FITS
1023 * keyword, being limited to 68 characters, plus the null-terminating
1024 * character.
1025 *
1026 * double lonpole
1027 * (Given and returned) The native longitude of the celestial pole, phi_p,
1028 * given by LONPOLEa [deg] or by PVi_2a [deg] attached to the longitude
1029 * axis which takes precedence if defined, and ...
1030 * double latpole
1031 * (Given and returned) ... the native latitude of the celestial pole,
1032 * theta_p, given by LATPOLEa [deg] or by PVi_3a [deg] attached to the
1033 * longitude axis which takes precedence if defined.
1034 *
1035 * lonpole and latpole may be left to default to values set by wcsinit()
1036 * (see celprm::ref), but in any case they will be reset by wcsset() to
1037 * the values actually used. Note therefore that if the wcsprm struct is
1038 * reused without resetting them, whether directly or via wcsinit(), they
1039 * will no longer have their default values.
1040 *
1041 * double restfrq
1042 * (Given) The rest frequency [Hz], and/or ...
1043 * double restwav
1044 * (Given) ... the rest wavelength in vacuo [m], only one of which need be
1045 * given, the other should be set to zero.
1046 *
1047 * int npv
1048 * (Given) The number of entries in the wcsprm::pv[] array.
1049 *
1050 * int npvmax
1051 * (Given or returned) The length of the wcsprm::pv[] array.
1052 *
1053 * npvmax will be set by wcsinit() if it allocates memory for wcsprm::pv[],
1054 * otherwise it must be set by the user. See also wcsnpv().
1055 *
1056 * struct pvcard *pv
1057 * (Given) Address of the first element of an array of length npvmax of
1058 * pvcard structs.
1059 *
1060 * As a FITS header parser encounters each PVi_ma keyword it should load it
1061 * into a pvcard struct in the array and increment npv. wcsset()
1062 * interprets these as required.
1063 *
1064 * Note that, if they were not given, wcsset() resets the entries for
1065 * PVi_1a, PVi_2a, PVi_3a, and PVi_4a for longitude axis i to match
1066 * phi_0 and theta_0 (the native longitude and latitude of the reference
1067 * point), LONPOLEa and LATPOLEa respectively.
1068 *
1069 * int nps
1070 * (Given) The number of entries in the wcsprm::ps[] array.
1071 *
1072 * int npsmax
1073 * (Given or returned) The length of the wcsprm::ps[] array.
1074 *
1075 * npsmax will be set by wcsinit() if it allocates memory for wcsprm::ps[],
1076 * otherwise it must be set by the user. See also wcsnps().
1077 *
1078 * struct pscard *ps
1079 * (Given) Address of the first element of an array of length npsmax of
1080 * pscard structs.
1081 *
1082 * As a FITS header parser encounters each PSi_ma keyword it should load it
1083 * into a pscard struct in the array and increment nps. wcsset()
1084 * interprets these as required (currently no PSi_ma keyvalues are
1085 * recognized).
1086 *
1087 * double *cd
1088 * (Given) For historical compatibility, the wcsprm struct supports two
1089 * alternate specifications of the linear transformation matrix, those
1090 * associated with the CDi_ja keywords, and ...
1091 * double *crota
1092 * (Given) ... those associated with the CROTAi keywords. Although these
1093 * may not formally co-exist with PCi_ja, the approach taken here is simply
1094 * to ignore them if given in conjunction with PCi_ja.
1095 *
1096 * int altlin
1097 * (Given) altlin is a bit flag that denotes which of the PCi_ja, CDi_ja
1098 * and CROTAi keywords are present in the header:
1099 *
1100 * - Bit 0: PCi_ja is present.
1101 *
1102 * - Bit 1: CDi_ja is present.
1103 *
1104 * Matrix elements in the IRAF convention are
1105 * equivalent to the product CDi_ja = CDELTia * PCi_ja, but the
1106 * defaults differ from that of the PCi_ja matrix. If one or more
1107 * CDi_ja keywords are present then all unspecified CDi_ja default to
1108 * zero. If no CDi_ja (or CROTAi) keywords are present, then the
1109 * header is assumed to be in PCi_ja form whether or not any PCi_ja
1110 * keywords are present since this results in an interpretation of
1111 * CDELTia consistent with the original FITS specification.
1112 *
1113 * While CDi_ja may not formally co-exist with PCi_ja, it may co-exist
1114 * with CDELTia and CROTAi which are to be ignored.
1115 *
1116 * - Bit 2: CROTAi is present.
1117 *
1118 * In the AIPS convention, CROTAi may only be
1119 * associated with the latitude axis of a celestial axis pair. It
1120 * specifies a rotation in the image plane that is applied AFTER the
1121 * CDELTia; any other CROTAi keywords are ignored.
1122 *
1123 * CROTAi may not formally co-exist with PCi_ja.
1124 *
1125 * CROTAi and CDELTia may formally co-exist with CDi_ja but if so are to
1126 * be ignored.
1127 *
1128 * CDi_ja and CROTAi keywords, if found, are to be stored in the
1129 * wcsprm::cd and wcsprm::crota arrays which are dimensioned similarly to
1130 * wcsprm::pc and wcsprm::cdelt. FITS
1131 * header parsers should use the following procedure:
1132 *
1133 * - Whenever a PCi_ja keyword is encountered: altlin |= 1;
1134 *
1135 * - Whenever a CDi_ja keyword is encountered: altlin |= 2;
1136 *
1137 * - Whenever a CROTAi keyword is encountered: altlin |= 4;
1138 *
1139 * If none of these bits are set the PCi_ja representation results, i.e.
1140 * wcsprm::pc and wcsprm::cdelt will be used as given.
1141 *
1142 * These alternate specifications of the linear transformation matrix are
1143 * translated immediately to PCi_ja by wcsset() and are invisible to the
1144 * lower-level WCSLIB routines. In particular, wcsset() resets
1145 * wcsprm::cdelt to unity if CDi_ja is present (and no PCi_ja).
1146 *
1147 * If CROTAi are present but none is associated with the latitude axis
1148 * (and no PCi_ja or CDi_ja), then wcsset() reverts to a unity PCi_ja
1149 * matrix.
1150 *
1151 * int velref
1152 * (Given) AIPS velocity code VELREF, refer to spcaips().
1153 *
1154 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1155 * wcsprm::velref is changed.
1156 *
1157 * char alt[4]
1158 * (Given, auxiliary) Character code for alternate coordinate descriptions
1159 * (i.e. the 'a' in keyword names such as CTYPEia). This is blank for the
1160 * primary coordinate description, or one of the 26 upper-case letters,
1161 * A-Z.
1162 *
1163 * An array of four characters is provided for alignment purposes, only the
1164 * first is used.
1165 *
1166 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1167 * wcsprm::alt is changed.
1168 *
1169 * int colnum
1170 * (Given, auxiliary) Where the coordinate representation is associated
1171 * with an image-array column in a FITS binary table, this variable may be
1172 * used to record the relevant column number.
1173 *
1174 * It should be set to zero for an image header or pixel list.
1175 *
1176 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1177 * wcsprm::colnum is changed.
1178 *
1179 * int *colax
1180 * (Given, auxiliary) Address of the first element of an array of int
1181 * recording the column numbers for each axis in a pixel list.
1182 *
1183 * The array elements should be set to zero for an image header or image
1184 * array in a binary table.
1185 *
1186 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1187 * wcsprm::colax is changed.
1188 *
1189 * char (*cname)[72]
1190 * (Given, auxiliary) The address of the first element of an array of
1191 * char[72] containing the coordinate axis names, CNAMEia.
1192 *
1193 * These variables accomodate the longest allowed string-valued FITS
1194 * keyword, being limited to 68 characters, plus the null-terminating
1195 * character.
1196 *
1197 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1198 * wcsprm::cname is changed.
1199 *
1200 * double *crder
1201 * (Given, auxiliary) Address of the first element of an array of double
1202 * recording the random error in the coordinate value, CRDERia.
1203 *
1204 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1205 * wcsprm::crder is changed.
1206 *
1207 * double *csyer
1208 * (Given, auxiliary) Address of the first element of an array of double
1209 * recording the systematic error in the coordinate value, CSYERia.
1210 *
1211 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1212 * wcsprm::csyer is changed.
1213 *
1214 * double *czphs
1215 * (Given, auxiliary) Address of the first element of an array of double
1216 * recording the time at the zero point of a phase axis, CZPHSia.
1217 *
1218 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1219 * wcsprm::czphs is changed.
1220 *
1221 * double *cperi
1222 * (Given, auxiliary) Address of the first element of an array of double
1223 * recording the period of a phase axis, CPERIia.
1224 *
1225 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1226 * wcsprm::cperi is changed.
1227 *
1228 * char wcsname[72]
1229 * (Given, auxiliary) The name given to the coordinate representation,
1230 * WCSNAMEa. This variable accomodates the longest allowed string-valued
1231 * FITS keyword, being limited to 68 characters, plus the null-terminating
1232 * character.
1233 *
1234 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1235 * wcsprm::wcsname is changed.
1236 *
1237 * char timesys[72]
1238 * (Given, auxiliary) TIMESYS keyvalue, being the time scale (UTC, TAI,
1239 * etc.) in which all other time-related auxiliary header values are
1240 * recorded. Also defines the time scale for an image axis with CTYPEia
1241 * set to 'TIME'.
1242 *
1243 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1244 * wcsprm::timesys is changed.
1245 *
1246 * char trefpos[72]
1247 * (Given, auxiliary) TREFPOS keyvalue, being the location in space where
1248 * the recorded time is valid.
1249 *
1250 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1251 * wcsprm::trefpos is changed.
1252 *
1253 * char trefdir[72]
1254 * (Given, auxiliary) TREFDIR keyvalue, being the reference direction used
1255 * in calculating a pathlength delay.
1256 *
1257 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1258 * wcsprm::trefdir is changed.
1259 *
1260 * char plephem[72]
1261 * (Given, auxiliary) PLEPHEM keyvalue, being the Solar System ephemeris
1262 * used for calculating a pathlength delay.
1263 *
1264 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1265 * wcsprm::plephem is changed.
1266 *
1267 * char timeunit[72]
1268 * (Given, auxiliary) TIMEUNIT keyvalue, being the time units in which
1269 * the following header values are expressed: TSTART, TSTOP, TIMEOFFS,
1270 * TIMSYER, TIMRDER, TIMEDEL. It also provides the default value for
1271 * CUNITia for time axes.
1272 *
1273 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1274 * wcsprm::timeunit is changed.
1275 *
1276 * char dateref[72]
1277 * (Given, auxiliary) DATEREF keyvalue, being the date of a reference epoch
1278 * relative to which other time measurements refer.
1279 *
1280 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1281 * wcsprm::dateref is changed.
1282 *
1283 * double mjdref[2]
1284 * (Given, auxiliary) MJDREF keyvalue, equivalent to DATEREF expressed as
1285 * a Modified Julian Date (MJD = JD - 2400000.5). The value is given as
1286 * the sum of the two-element vector, allowing increased precision.
1287 *
1288 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1289 * wcsprm::mjdref is changed.
1290 *
1291 * double timeoffs
1292 * (Given, auxiliary) TIMEOFFS keyvalue, being a time offset, which may be
1293 * used, for example, to provide a uniform clock correction for times
1294 * referenced to DATEREF.
1295 *
1296 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1297 * wcsprm::timeoffs is changed.
1298 *
1299 * char dateobs[72]
1300 * (Given, auxiliary) DATE-OBS keyvalue, being the date at the start of the
1301 * observation unless otherwise explained in the DATE-OBS keycomment, in
1302 * ISO format, yyyy-mm-ddThh:mm:ss.
1303 *
1304 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1305 * wcsprm::dateobs is changed.
1306 *
1307 * char datebeg[72]
1308 * (Given, auxiliary) DATE-BEG keyvalue, being the date at the start of the
1309 * observation in ISO format, yyyy-mm-ddThh:mm:ss.
1310 *
1311 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1312 * wcsprm::datebeg is changed.
1313 *
1314 * char dateavg[72]
1315 * (Given, auxiliary) DATE-AVG keyvalue, being the date at a representative
1316 * mid-point of the observation in ISO format, yyyy-mm-ddThh:mm:ss.
1317 *
1318 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1319 * wcsprm::dateavg is changed.
1320 *
1321 * char dateend[72]
1322 * (Given, auxiliary) DATE-END keyvalue, baing the date at the end of the
1323 * observation in ISO format, yyyy-mm-ddThh:mm:ss.
1324 *
1325 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1326 * wcsprm::dateend is changed.
1327 *
1328 * double mjdobs
1329 * (Given, auxiliary) MJD-OBS keyvalue, equivalent to DATE-OBS expressed
1330 * as a Modified Julian Date (MJD = JD - 2400000.5).
1331 *
1332 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1333 * wcsprm::mjdobs is changed.
1334 *
1335 * double mjdbeg
1336 * (Given, auxiliary) MJD-BEG keyvalue, equivalent to DATE-BEG expressed
1337 * as a Modified Julian Date (MJD = JD - 2400000.5).
1338 *
1339 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1340 * wcsprm::mjdbeg is changed.
1341 *
1342 * double mjdavg
1343 * (Given, auxiliary) MJD-AVG keyvalue, equivalent to DATE-AVG expressed
1344 * as a Modified Julian Date (MJD = JD - 2400000.5).
1345 *
1346 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1347 * wcsprm::mjdavg is changed.
1348 *
1349 * double mjdend
1350 * (Given, auxiliary) MJD-END keyvalue, equivalent to DATE-END expressed
1351 * as a Modified Julian Date (MJD = JD - 2400000.5).
1352 *
1353 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1354 * wcsprm::mjdend is changed.
1355 *
1356 * double jepoch
1357 * (Given, auxiliary) JEPOCH keyvalue, equivalent to DATE-OBS expressed
1358 * as a Julian epoch.
1359 *
1360 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1361 * wcsprm::jepoch is changed.
1362 *
1363 * double bepoch
1364 * (Given, auxiliary) BEPOCH keyvalue, equivalent to DATE-OBS expressed
1365 * as a Besselian epoch
1366 *
1367 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1368 * wcsprm::bepoch is changed.
1369 *
1370 * double tstart
1371 * (Given, auxiliary) TSTART keyvalue, equivalent to DATE-BEG expressed
1372 * as a time in units of TIMEUNIT relative to DATEREF+TIMEOFFS.
1373 *
1374 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1375 * wcsprm::tstart is changed.
1376 *
1377 * double tstop
1378 * (Given, auxiliary) TSTOP keyvalue, equivalent to DATE-END expressed
1379 * as a time in units of TIMEUNIT relative to DATEREF+TIMEOFFS.
1380 *
1381 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1382 * wcsprm::tstop is changed.
1383 *
1384 * double xposure
1385 * (Given, auxiliary) XPOSURE keyvalue, being the effective exposure time
1386 * in units of TIMEUNIT.
1387 *
1388 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1389 * wcsprm::xposure is changed.
1390 *
1391 * double telapse
1392 * (Given, auxiliary) TELAPSE keyvalue, equivalent to the elapsed time
1393 * between DATE-BEG and DATE-END, in units of TIMEUNIT.
1394 *
1395 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1396 * wcsprm::telapse is changed.
1397 *
1398 * double timsyer
1399 * (Given, auxiliary) TIMSYER keyvalue, being the absolute error of the
1400 * time values, in units of TIMEUNIT.
1401 *
1402 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1403 * wcsprm::timsyer is changed.
1404 *
1405 * double timrder
1406 * (Given, auxiliary) TIMRDER keyvalue, being the accuracy of time stamps
1407 * relative to each other, in units of TIMEUNIT.
1408 *
1409 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1410 * wcsprm::timrder is changed.
1411 *
1412 * double timedel
1413 * (Given, auxiliary) TIMEDEL keyvalue, being the resolution of the time
1414 * stamps.
1415 *
1416 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1417 * wcsprm::timedel is changed.
1418 *
1419 * double timepixr
1420 * (Given, auxiliary) TIMEPIXR keyvalue, being the relative position of the
1421 * time stamps in binned time intervals, a value between 0.0 and 1.0.
1422 *
1423 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1424 * wcsprm::timepixr is changed.
1425 *
1426 * double obsgeo[6]
1427 * (Given, auxiliary) Location of the observer in a standard terrestrial
1428 * reference frame. The first three give ITRS Cartesian coordinates
1429 * OBSGEO-X [m], OBSGEO-Y [m], OBSGEO-Z [m], and the second three give
1430 * OBSGEO-L [deg], OBSGEO-B [deg], OBSGEO-H [m], which are related through
1431 * a standard transformation.
1432 *
1433 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1434 * wcsprm::obsgeo is changed.
1435 *
1436 * char obsorbit[72]
1437 * (Given, auxiliary) OBSORBIT keyvalue, being the URI, URL, or name of an
1438 * orbit ephemeris file giving spacecraft coordinates relating to TREFPOS.
1439 *
1440 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1441 * wcsprm::obsorbit is changed.
1442 *
1443 * char radesys[72]
1444 * (Given, auxiliary) The equatorial or ecliptic coordinate system type,
1445 * RADESYSa.
1446 *
1447 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1448 * wcsprm::radesys is changed.
1449 *
1450 * double equinox
1451 * (Given, auxiliary) The equinox associated with dynamical equatorial or
1452 * ecliptic coordinate systems, EQUINOXa (or EPOCH in older headers). Not
1453 * applicable to ICRS equatorial or ecliptic coordinates.
1454 *
1455 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1456 * wcsprm::equinox is changed.
1457 *
1458 * char specsys[72]
1459 * (Given, auxiliary) Spectral reference frame (standard of rest),
1460 * SPECSYSa.
1461 *
1462 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1463 * wcsprm::specsys is changed.
1464 *
1465 * char ssysobs[72]
1466 * (Given, auxiliary) The spectral reference frame in which there is no
1467 * differential variation in the spectral coordinate across the
1468 * field-of-view, SSYSOBSa.
1469 *
1470 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1471 * wcsprm::ssysobs is changed.
1472 *
1473 * double velosys
1474 * (Given, auxiliary) The relative radial velocity [m/s] between the
1475 * observer and the selected standard of rest in the direction of the
1476 * celestial reference coordinate, VELOSYSa.
1477 *
1478 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1479 * wcsprm::velosys is changed.
1480 *
1481 * double zsource
1482 * (Given, auxiliary) The redshift, ZSOURCEa, of the source.
1483 *
1484 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1485 * wcsprm::zsource is changed.
1486 *
1487 * char ssyssrc[72]
1488 * (Given, auxiliary) The spectral reference frame (standard of rest),
1489 * SSYSSRCa, in which wcsprm::zsource was measured.
1490 *
1491 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1492 * wcsprm::ssyssrc is changed.
1493 *
1494 * double velangl
1495 * (Given, auxiliary) The angle [deg] that should be used to decompose an
1496 * observed velocity into radial and transverse components.
1497 *
1498 * It is not necessary to reset the wcsprm struct (via wcsset()) when
1499 * wcsprm::velangl is changed.
1500 *
1501 * struct auxprm *aux
1502 * (Given, auxiliary) This struct holds auxiliary coordinate system
1503 * information of a specialist nature. While these parameters may be
1504 * widely recognized within particular fields of astronomy, they differ
1505 * from the above auxiliary parameters in not being defined by any of the
1506 * FITS WCS standards. Collecting them together in a separate struct that
1507 * is allocated only when required helps to control bloat in the size of
1508 * the wcsprm struct.
1509 *
1510 * int ntab
1511 * (Given) See wcsprm::tab.
1512 *
1513 * int nwtb
1514 * (Given) See wcsprm::wtb.
1515 *
1516 * struct tabprm *tab
1517 * (Given) Address of the first element of an array of ntab tabprm structs
1518 * for which memory has been allocated. These are used to store tabular
1519 * transformation parameters.
1520 *
1521 * Although technically wcsprm::ntab and tab are "given", they will
1522 * normally be set by invoking wcstab(), whether directly or indirectly.
1523 *
1524 * The tabprm structs contain some members that must be supplied and others
1525 * that are derived. The information to be supplied comes primarily from
1526 * arrays stored in one or more FITS binary table extensions. These
1527 * arrays, referred to here as "wcstab arrays", are themselves located by
1528 * parameters stored in the FITS image header.
1529 *
1530 * struct wtbarr *wtb
1531 * (Given) Address of the first element of an array of nwtb wtbarr structs
1532 * for which memory has been allocated. These are used in extracting
1533 * wcstab arrays from a FITS binary table.
1534 *
1535 * Although technically wcsprm::nwtb and wtb are "given", they will
1536 * normally be set by invoking wcstab(), whether directly or indirectly.
1537 *
1538 * char lngtyp[8]
1539 * (Returned) Four-character WCS celestial longitude and ...
1540 * char lattyp[8]
1541 * (Returned) ... latitude axis types. e.g. "RA", "DEC", "GLON", "GLAT",
1542 * etc. extracted from 'RA--', 'DEC-', 'GLON', 'GLAT', etc. in the first
1543 * four characters of CTYPEia but with trailing dashes removed. (Declared
1544 * as char[8] for alignment reasons.)
1545 *
1546 * int lng
1547 * (Returned) Index for the longitude coordinate, and ...
1548 * int lat
1549 * (Returned) ... index for the latitude coordinate, and ...
1550 * int spec
1551 * (Returned) ... index for the spectral coordinate in the imgcrd[][] and
1552 * world[][] arrays in the API of wcsp2s(), wcss2p() and wcsmix().
1553 *
1554 * These may also serve as indices into the pixcrd[][] array provided that
1555 * the PCi_ja matrix does not transpose axes.
1556 *
1557 * int cubeface
1558 * (Returned) Index into the pixcrd[][] array for the CUBEFACE axis. This
1559 * is used for quadcube projections where the cube faces are stored on a
1560 * separate axis (see wcs.h).
1561 *
1562 * int *types
1563 * (Returned) Address of the first element of an array of int containing a
1564 * four-digit type code for each axis.
1565 *
1566 * - First digit (i.e. 1000s):
1567 * - 0: Non-specific coordinate type.
1568 * - 1: Stokes coordinate.
1569 * - 2: Celestial coordinate (including CUBEFACE).
1570 * - 3: Spectral coordinate.
1571 *
1572 * - Second digit (i.e. 100s):
1573 * - 0: Linear axis.
1574 * - 1: Quantized axis (STOKES, CUBEFACE).
1575 * - 2: Non-linear celestial axis.
1576 * - 3: Non-linear spectral axis.
1577 * - 4: Logarithmic axis.
1578 * - 5: Tabular axis.
1579 *
1580 * - Third digit (i.e. 10s):
1581 * - 0: Group number, e.g. lookup table number, being an index into the
1582 * tabprm array (see above).
1583 *
1584 * - The fourth digit is used as a qualifier depending on the axis type.
1585 *
1586 * - For celestial axes:
1587 * - 0: Longitude coordinate.
1588 * - 1: Latitude coordinate.
1589 * - 2: CUBEFACE number.
1590 *
1591 * - For lookup tables: the axis number in a multidimensional table.
1592 *
1593 * CTYPEia in "4-3" form with unrecognized algorithm code will have its
1594 * type set to -1 and generate an error.
1595 *
1596 * struct linprm lin
1597 * (Returned) Linear transformation parameters (usage is described in the
1598 * prologue to lin.h).
1599 *
1600 * struct celprm cel
1601 * (Returned) Celestial transformation parameters (usage is described in
1602 * the prologue to cel.h).
1603 *
1604 * struct spcprm spc
1605 * (Returned) Spectral transformation parameters (usage is described in the
1606 * prologue to spc.h).
1607 *
1608 * struct wcserr *err
1609 * (Returned) If enabled, when an error status is returned, this struct
1610 * contains detailed information about the error, see wcserr_enable().
1611 *
1612 * int m_flag
1613 * (For internal use only.)
1614 * int m_naxis
1615 * (For internal use only.)
1616 * double *m_crpix
1617 * (For internal use only.)
1618 * double *m_pc
1619 * (For internal use only.)
1620 * double *m_cdelt
1621 * (For internal use only.)
1622 * double *m_crval
1623 * (For internal use only.)
1624 * char (*m_cunit)[72]
1625 * (For internal use only.)
1626 * char (*m_ctype)[72]
1627 * (For internal use only.)
1628 * struct pvcard *m_pv
1629 * (For internal use only.)
1630 * struct pscard *m_ps
1631 * (For internal use only.)
1632 * double *m_cd
1633 * (For internal use only.)
1634 * double *m_crota
1635 * (For internal use only.)
1636 * int *m_colax
1637 * (For internal use only.)
1638 * char (*m_cname)[72]
1639 * (For internal use only.)
1640 * double *m_crder
1641 * (For internal use only.)
1642 * double *m_csyer
1643 * (For internal use only.)
1644 * double *m_czphs
1645 * (For internal use only.)
1646 * double *m_cperi
1647 * (For internal use only.)
1648 * struct tabprm *m_tab
1649 * (For internal use only.)
1650 * struct wtbarr *m_wtb
1651 * (For internal use only.)
1652 *
1653 *
1654 * pvcard struct - Store for PVi_ma keyrecords
1655 * -------------------------------------------
1656 * The pvcard struct is used to pass the parsed contents of PVi_ma keyrecords
1657 * to wcsset() via the wcsprm struct.
1658 *
1659 * All members of this struct are to be set by the user.
1660 *
1661 * int i
1662 * (Given) Axis number (1-relative), as in the FITS PVi_ma keyword. If
1663 * i == 0, wcsset() will replace it with the latitude axis number.
1664 *
1665 * int m
1666 * (Given) Parameter number (non-negative), as in the FITS PVi_ma keyword.
1667 *
1668 * double value
1669 * (Given) Parameter value.
1670 *
1671 *
1672 * pscard struct - Store for PSi_ma keyrecords
1673 * -------------------------------------------
1674 * The pscard struct is used to pass the parsed contents of PSi_ma keyrecords
1675 * to wcsset() via the wcsprm struct.
1676 *
1677 * All members of this struct are to be set by the user.
1678 *
1679 * int i
1680 * (Given) Axis number (1-relative), as in the FITS PSi_ma keyword.
1681 *
1682 * int m
1683 * (Given) Parameter number (non-negative), as in the FITS PSi_ma keyword.
1684 *
1685 * char value[72]
1686 * (Given) Parameter value.
1687 *
1688 *
1689 * auxprm struct - Additional auxiliary parameters
1690 * -----------------------------------------------
1691 * The auxprm struct holds auxiliary coordinate system information of a
1692 * specialist nature. It is anticipated that this struct will expand in future
1693 * to accomodate additional parameters.
1694 *
1695 * All members of this struct are to be set by the user.
1696 *
1697 * double rsun_ref
1698 * (Given, auxiliary) Reference radius of the Sun used in coordinate
1699 * calculations (m).
1700 *
1701 * double dsun_obs
1702 * (Given, auxiliary) Distance between the centre of the Sun and the
1703 * observer (m).
1704 *
1705 * double crln_obs
1706 * (Given, auxiliary) Carrington heliographic longitude of the observer
1707 * (deg).
1708 *
1709 * double hgln_obs
1710 * (Given, auxiliary) Stonyhurst heliographic longitude of the observer
1711 * (deg).
1712 *
1713 * double hglt_obs
1714 * (Given, auxiliary) Heliographic latitude (Carrington or Stonyhurst) of
1715 * the observer (deg).
1716 *
1717 *
1718 * Global variable: const char *wcs_errmsg[] - Status return messages
1719 * ------------------------------------------------------------------
1720 * Error messages to match the status value returned from each function.
1721 *
1722 *===========================================================================*/
1723 
1724 #ifndef WCSLIB_WCS
1725 #define WCSLIB_WCS
1726 
1727 #include "lin.h"
1728 #include "cel.h"
1729 #include "spc.h"
1730 
1731 #ifdef __cplusplus
1732 extern "C" {
1733 #define wtbarr wtbarr_s /* See prologue of wtbarr.h. */
1734 #endif
1735 
1736 #define WCSSUB_LONGITUDE 0x1001
1737 #define WCSSUB_LATITUDE 0x1002
1738 #define WCSSUB_CUBEFACE 0x1004
1739 #define WCSSUB_CELESTIAL 0x1007
1740 #define WCSSUB_SPECTRAL 0x1008
1741 #define WCSSUB_STOKES 0x1010
1743 
1744 #define WCSCOMPARE_ANCILLARY 0x0001
1745 #define WCSCOMPARE_TILING 0x0002
1746 #define WCSCOMPARE_CRPIX 0x0004
1748 
1749 extern const char *wcs_errmsg[];
1750 
1752  WCSERR_SUCCESS = 0, /* Success. */
1753  WCSERR_NULL_POINTER = 1, /* Null wcsprm pointer passed. */
1754  WCSERR_MEMORY = 2, /* Memory allocation failed. */
1755  WCSERR_SINGULAR_MTX = 3, /* Linear transformation matrix is
1756  singular. */
1757  WCSERR_BAD_CTYPE = 4, /* Inconsistent or unrecognized coordinate
1758  axis type. */
1759  WCSERR_BAD_PARAM = 5, /* Invalid parameter value. */
1760  WCSERR_BAD_COORD_TRANS = 6, /* Unrecognized coordinate transformation
1761  parameter. */
1762  WCSERR_ILL_COORD_TRANS = 7, /* Ill-conditioned coordinate transformation
1763  parameter. */
1764  WCSERR_BAD_PIX = 8, /* One or more of the pixel coordinates were
1765  invalid. */
1766  WCSERR_BAD_WORLD = 9, /* One or more of the world coordinates were
1767  invalid. */
1768  WCSERR_BAD_WORLD_COORD = 10, /* Invalid world coordinate. */
1769  WCSERR_NO_SOLUTION = 11, /* No solution found in the specified
1770  interval. */
1771  WCSERR_BAD_SUBIMAGE = 12, /* Invalid subimage specification. */
1772  WCSERR_NON_SEPARABLE = 13 /* Non-separable subimage coordinate
1773  system. */
1774 };
1775 
1776 
1777 /* Struct used for storing PVi_ma keywords. */
1778 struct pvcard {
1779  int i; /* Axis number, as in PVi_ma (1-relative). */
1780  int m; /* Parameter number, ditto (0-relative). */
1781  double value; /* Parameter value. */
1782 };
1783 
1784 /* Size of the pvcard struct in int units, used by the Fortran wrappers. */
1785 #define PVLEN (sizeof(struct pvcard)/sizeof(int))
1787 /* Struct used for storing PSi_ma keywords. */
1788 struct pscard {
1789  int i; /* Axis number, as in PSi_ma (1-relative). */
1790  int m; /* Parameter number, ditto (0-relative). */
1791  char value[72]; /* Parameter value. */
1792 };
1793 
1794 /* Size of the pscard struct in int units, used by the Fortran wrappers. */
1795 #define PSLEN (sizeof(struct pscard)/sizeof(int))
1797 /* Struct used to hold additional auxiliary parameters. */
1798 struct auxprm {
1799  double rsun_ref; /* Solar radius. */
1800  double dsun_obs; /* Distance from Sun centre to observer. */
1801  double crln_obs; /* Carrington heliographic lng of observer. */
1802  double hgln_obs; /* Stonyhurst heliographic lng of observer. */
1803  double hglt_obs; /* Heliographic latitude of observer. */
1804 };
1805 
1806 /* Size of the auxprm struct in int units, used by the Fortran wrappers. */
1807 #define AUXLEN (sizeof(struct auxprm)/sizeof(int))
1809 
1810 struct wcsprm {
1811  /* Initialization flag (see the prologue above). */
1812  /*------------------------------------------------------------------------*/
1813  int flag; /* Set to zero to force initialization. */
1814 
1815  /* FITS header keyvalues to be provided (see the prologue above). */
1816  /*------------------------------------------------------------------------*/
1817  int naxis; /* Number of axes (pixel and coordinate). */
1818  double *crpix; /* CRPIXja keyvalues for each pixel axis. */
1819  double *pc; /* PCi_ja linear transformation matrix. */
1820  double *cdelt; /* CDELTia keyvalues for each coord axis. */
1821  double *crval; /* CRVALia keyvalues for each coord axis. */
1822 
1823  char (*cunit)[72]; /* CUNITia keyvalues for each coord axis. */
1824  char (*ctype)[72]; /* CTYPEia keyvalues for each coord axis. */
1825 
1826  double lonpole; /* LONPOLEa keyvalue. */
1827  double latpole; /* LATPOLEa keyvalue. */
1828 
1829  double restfrq; /* RESTFRQa keyvalue. */
1830  double restwav; /* RESTWAVa keyvalue. */
1831 
1832  int npv; /* Number of PVi_ma keywords, and the */
1833  int npvmax; /* number for which space was allocated. */
1834  struct pvcard *pv; /* PVi_ma keywords for each i and m. */
1835 
1836  int nps; /* Number of PSi_ma keywords, and the */
1837  int npsmax; /* number for which space was allocated. */
1838  struct pscard *ps; /* PSi_ma keywords for each i and m. */
1839 
1840  /* Alternative header keyvalues (see the prologue above). */
1841  /*------------------------------------------------------------------------*/
1842  double *cd; /* CDi_ja linear transformation matrix. */
1843  double *crota; /* CROTAi keyvalues for each coord axis. */
1844  int altlin; /* Alternative representations */
1845  /* Bit 0: PCi_ja is present, */
1846  /* Bit 1: CDi_ja is present, */
1847  /* Bit 2: CROTAi is present. */
1848  int velref; /* AIPS velocity code, VELREF. */
1849 
1850  /* Auxiliary coordinate system information of a general nature. Not */
1851  /* used by WCSLIB. Refer to the prologue comments above for a brief */
1852  /* explanation of these values. */
1853  char alt[4];
1854  int colnum;
1855  int *colax;
1856  /* Auxiliary coordinate axis information. */
1857  char (*cname)[72];
1858  double *crder;
1859  double *csyer;
1860  double *czphs;
1861  double *cperi;
1862 
1863  char wcsname[72];
1864  /* Time reference system and measurement. */
1865  char timesys[72], trefpos[72], trefdir[72], plephem[72];
1866  char timeunit[72];
1867  char dateref[72];
1868  double mjdref[2];
1869  double timeoffs;
1870  /* Data timestamps and durations. */
1871  char dateobs[72], datebeg[72], dateavg[72], dateend[72];
1873  double jepoch, bepoch;
1874  double tstart, tstop;
1875  double xposure, telapse;
1876  /* Timing accuracy. */
1877  double timsyer, timrder;
1879  /* Spatial & celestial reference frame. */
1880  double obsgeo[6];
1881  char obsorbit[72];
1882  char radesys[72];
1883  double equinox;
1884  char specsys[72];
1885  char ssysobs[72];
1886  double velosys;
1887  double zsource;
1888  char ssyssrc[72];
1889  double velangl;
1890 
1891  /* Additional auxiliary coordinate system information of a specialist */
1892  /* nature. Not used by WCSLIB. Refer to the prologue comments above. */
1893  struct auxprm *aux;
1894 
1895  /* Coordinate lookup tables (see the prologue above). */
1896  /*------------------------------------------------------------------------*/
1897  int ntab; /* Number of separate tables. */
1898  int nwtb; /* Number of wtbarr structs. */
1899  struct tabprm *tab; /* Tabular transformation parameters. */
1900  struct wtbarr *wtb; /* Array of wtbarr structs. */
1901 
1902  /*------------------------------------------------------------------------*/
1903  /* Information derived from the FITS header keyvalues by wcsset(). */
1904  /*------------------------------------------------------------------------*/
1905  char lngtyp[8], lattyp[8]; /* Celestial axis types, e.g. RA, DEC. */
1906  int lng, lat, spec; /* Longitude, latitude and spectral axis */
1907  /* indices (0-relative). */
1908  int cubeface; /* True if there is a CUBEFACE axis. */
1909  int *types; /* Coordinate type codes for each axis. */
1910 
1911  struct linprm lin; /* Linear transformation parameters. */
1912  struct celprm cel; /* Celestial transformation parameters. */
1913  struct spcprm spc; /* Spectral transformation parameters. */
1914 
1915  /*------------------------------------------------------------------------*/
1916  /* THE REMAINDER OF THE WCSPRM STRUCT IS PRIVATE. */
1917  /*------------------------------------------------------------------------*/
1918 
1919  /* Error handling, if enabled. */
1920  /*------------------------------------------------------------------------*/
1921  struct wcserr *err;
1922 
1923  /* Memory management. */
1924  /*------------------------------------------------------------------------*/
1926  double *m_crpix, *m_pc, *m_cdelt, *m_crval;
1927  char (*m_cunit)[72], (*m_ctype)[72];
1928  struct pvcard *m_pv;
1929  struct pscard *m_ps;
1930  double *m_cd, *m_crota;
1931  int *m_colax;
1932  char (*m_cname)[72];
1934  struct auxprm *m_aux;
1935  struct tabprm *m_tab;
1936  struct wtbarr *m_wtb;
1937 };
1938 
1939 /* Size of the wcsprm struct in int units, used by the Fortran wrappers. */
1940 #define WCSLEN (sizeof(struct wcsprm)/sizeof(int))
1942 
1943 int wcsnpv(int n);
1944 
1945 int wcsnps(int n);
1946 
1947 int wcsini(int alloc, int naxis, struct wcsprm *wcs);
1948 
1949 int wcsinit(int alloc, int naxis, struct wcsprm *wcs, int npvmax, int npsmax,
1950  int ndpmax);
1951 
1952 int wcsauxi(int alloc, struct wcsprm *wcs);
1953 
1954 int wcssub(int alloc, const struct wcsprm *wcssrc, int *nsub, int axes[],
1955  struct wcsprm *wcsdst);
1956 
1957 int wcscompare(int cmp, double tol, const struct wcsprm *wcs1,
1958  const struct wcsprm *wcs2, int *equal);
1959 
1960 int wcsfree(struct wcsprm *wcs);
1961 
1962 int wcsprt(const struct wcsprm *wcs);
1963 
1964 int wcsperr(const struct wcsprm *wcs, const char *prefix);
1965 
1966 int wcsbchk(struct wcsprm *wcs, int bounds);
1967 
1968 int wcsset(struct wcsprm *wcs);
1969 
1970 int wcsp2s(struct wcsprm *wcs, int ncoord, int nelem, const double pixcrd[],
1971  double imgcrd[], double phi[], double theta[], double world[],
1972  int stat[]);
1973 
1974 int wcss2p(struct wcsprm *wcs, int ncoord, int nelem, const double world[],
1975  double phi[], double theta[], double imgcrd[], double pixcrd[],
1976  int stat[]);
1977 
1978 int wcsmix(struct wcsprm *wcs, int mixpix, int mixcel, const double vspan[],
1979  double vstep, int viter, double world[], double phi[],
1980  double theta[], double imgcrd[], double pixcrd[]);
1981 
1982 int wcssptr(struct wcsprm *wcs, int *i, char ctype[9]);
1983 
1984 const char* wcslib_version(int vers[3]);
1985 
1986 /* Defined mainly for backwards compatibility, use wcssub() instead. */
1987 #define wcscopy(alloc, wcssrc, wcsdst) wcssub(alloc, wcssrc, 0x0, 0x0, wcsdst)
1989 
1990 /* Deprecated. */
1991 #define wcsini_errmsg wcs_errmsg
1992 #define wcssub_errmsg wcs_errmsg
1993 #define wcscopy_errmsg wcs_errmsg
1994 #define wcsfree_errmsg wcs_errmsg
1995 #define wcsprt_errmsg wcs_errmsg
1996 #define wcsset_errmsg wcs_errmsg
1997 #define wcsp2s_errmsg wcs_errmsg
1998 #define wcss2p_errmsg wcs_errmsg
1999 #define wcsmix_errmsg wcs_errmsg
2001 #ifdef __cplusplus
2002 #undef wtbarr
2003 }
2004 #endif
2005 
2006 #endif /* WCSLIB_WCS */
pscard::m
int m
Definition: wcs.h:1790
wcsprm::timepixr
double timepixr
Definition: wcs.h:1878
wcsprm::m_pv
struct pvcard * m_pv
Definition: wcs.h:1928
wcsprm::nps
int nps
Definition: wcs.h:1836
wcsprm::timesys
char timesys[72]
Definition: wcs.h:1865
pscard::value
char value[72]
Definition: wcs.h:1791
auxprm::crln_obs
double crln_obs
Definition: wcs.h:1801
wcsprm::dateref
char dateref[72]
Definition: wcs.h:1867
wcsprm::cel
struct celprm cel
Definition: wcs.h:1912
wcsprm::spec
int spec
Definition: wcs.h:1906
wcsprm::ssysobs
char ssysobs[72]
Definition: wcs.h:1885
wcsprm::cubeface
int cubeface
Definition: wcs.h:1908
wcsprm::trefdir
char trefdir[72]
Definition: wcs.h:1865
wcsprm::dateobs
char dateobs[72]
Definition: wcs.h:1871
cel.h
wcsprm::m_crota
double * m_crota
Definition: wcs.h:1930
wcsprm::m_tab
struct tabprm * m_tab
Definition: wcs.h:1935
WCSERR_BAD_PIX
@ WCSERR_BAD_PIX
Definition: wcs.h:1764
WCSERR_ILL_COORD_TRANS
@ WCSERR_ILL_COORD_TRANS
Definition: wcs.h:1762
WCSERR_NULL_POINTER
@ WCSERR_NULL_POINTER
Definition: wcs.h:1753
wcsprm::lng
int lng
Definition: wcs.h:1906
wcslib_version
const char * wcslib_version(int vers[3])
wcscompare
int wcscompare(int cmp, double tol, const struct wcsprm *wcs1, const struct wcsprm *wcs2, int *equal)
Compare two wcsprm structs for equality.
spc.h
wcsprm::m_cname
char(* m_cname)[72]
Definition: wcs.h:1932
wcsprm::lngtyp
char lngtyp[8]
Definition: wcs.h:1905
wcsinit
int wcsinit(int alloc, int naxis, struct wcsprm *wcs, int npvmax, int npsmax, int ndpmax)
Default constructor for the wcsprm struct.
wcsprm::crota
double * crota
Definition: wcs.h:1843
wcsprm::lat
int lat
Definition: wcs.h:1906
wcsprm::obsorbit
char obsorbit[72]
Definition: wcs.h:1881
wcsprm::dateavg
char dateavg[72]
Definition: wcs.h:1871
wcsprm::cd
double * cd
Definition: wcs.h:1842
WCSERR_BAD_COORD_TRANS
@ WCSERR_BAD_COORD_TRANS
Definition: wcs.h:1760
wcsprm::m_pc
double * m_pc
Definition: wcs.h:1926
wcsprm::trefpos
char trefpos[72]
Definition: wcs.h:1865
spcprm
Spectral transformation parameters.
Definition: spc.h:807
wcsprm::m_cperi
double * m_cperi
Definition: wcs.h:1933
wcsprm::ps
struct pscard * ps
Definition: wcs.h:1838
wcsprm::zsource
double zsource
Definition: wcs.h:1887
wcsprm::velangl
double velangl
Definition: wcs.h:1889
wcsprm::npv
int npv
Definition: wcs.h:1832
wcsprm::crval
double * crval
Definition: wcs.h:1821
wcsprm::colax
int * colax
Definition: wcs.h:1855
WCSERR_NON_SEPARABLE
@ WCSERR_NON_SEPARABLE
Definition: wcs.h:1772
wcsprm::specsys
char specsys[72]
Definition: wcs.h:1884
wtbarr
Extraction of coordinate lookup tables from BINTABLE.
Definition: getwcstab.h:170
wcsprm::m_crpix
double * m_crpix
Definition: wcs.h:1926
wcsprm::m_wtb
struct wtbarr * m_wtb
Definition: wcs.h:1936
auxprm::rsun_ref
double rsun_ref
Definition: wcs.h:1799
wcsprm::timrder
double timrder
Definition: wcs.h:1877
wcsprm::m_aux
struct auxprm * m_aux
Definition: wcs.h:1934
wcsprm::cname
char(* cname)[72]
Definition: wcs.h:1857
wcsprm::timedel
double timedel
Definition: wcs.h:1878
wcsprm::lattyp
char lattyp[8]
Definition: wcs.h:1905
wcsprm::alt
char alt[4]
Definition: wcs.h:1853
wcsset
int wcsset(struct wcsprm *wcs)
Setup routine for the wcsprm struct.
pscard::i
int i
Definition: wcs.h:1789
wcsprm::timsyer
double timsyer
Definition: wcs.h:1877
wcsprm::m_flag
int m_flag
Definition: wcs.h:1925
pvcard::i
int i
Definition: wcs.h:1779
wcs_errmsg_enum
wcs_errmsg_enum
Definition: wcs.h:1751
wcsprm::crpix
double * crpix
Definition: wcs.h:1818
wcsprm::flag
int flag
Definition: wcs.h:1813
WCSERR_BAD_PARAM
@ WCSERR_BAD_PARAM
Definition: wcs.h:1759
wcsprm::mjdend
double mjdend
Definition: wcs.h:1872
WCSERR_SUCCESS
@ WCSERR_SUCCESS
Definition: wcs.h:1752
wcsprm::tstart
double tstart
Definition: wcs.h:1874
wcsnpv
int wcsnpv(int n)
Memory allocation for PVi_ma.
wcsprm::m_cd
double * m_cd
Definition: wcs.h:1930
wcsprm::timeoffs
double timeoffs
Definition: wcs.h:1869
wcsprm::timeunit
char timeunit[72]
Definition: wcs.h:1866
wcsprm::restfrq
double restfrq
Definition: wcs.h:1829
wcsprm::types
int * types
Definition: wcs.h:1909
wcss2p
int wcss2p(struct wcsprm *wcs, int ncoord, int nelem, const double world[], double phi[], double theta[], double imgcrd[], double pixcrd[], int stat[])
World-to-pixel transformation.
wcsprt
int wcsprt(const struct wcsprm *wcs)
Print routine for the wcsprm struct.
WCSERR_BAD_CTYPE
@ WCSERR_BAD_CTYPE
Definition: wcs.h:1757
wcsprm
Coordinate transformation parameters.
Definition: wcs.h:1810
wcsprm::datebeg
char datebeg[72]
Definition: wcs.h:1871
wcsprm::latpole
double latpole
Definition: wcs.h:1827
wcsprm::lin
struct linprm lin
Definition: wcs.h:1911
wcsprm::tstop
double tstop
Definition: wcs.h:1874
auxprm::dsun_obs
double dsun_obs
Definition: wcs.h:1800
wcsprm::pv
struct pvcard * pv
Definition: wcs.h:1834
wcsprm::mjdbeg
double mjdbeg
Definition: wcs.h:1872
wcsprm::altlin
int altlin
Definition: wcs.h:1844
wcsprm::jepoch
double jepoch
Definition: wcs.h:1873
wcsprm::cperi
double * cperi
Definition: wcs.h:1861
wcsprm::obsgeo
double obsgeo[6]
Definition: wcs.h:1880
wcsprm::m_ps
struct pscard * m_ps
Definition: wcs.h:1929
auxprm::hglt_obs
double hglt_obs
Definition: wcs.h:1803
WCSERR_BAD_SUBIMAGE
@ WCSERR_BAD_SUBIMAGE
Definition: wcs.h:1771
wcsprm::dateend
char dateend[72]
Definition: wcs.h:1871
wcsprm::m_crder
double * m_crder
Definition: wcs.h:1933
wcsprm::mjdavg
double mjdavg
Definition: wcs.h:1872
wcsprm::telapse
double telapse
Definition: wcs.h:1875
wcsauxi
int wcsauxi(int alloc, struct wcsprm *wcs)
Default constructor for the auxprm struct.
wcsprm::err
struct wcserr * err
Definition: wcs.h:1921
wcsprm::restwav
double restwav
Definition: wcs.h:1830
WCSERR_BAD_WORLD_COORD
@ WCSERR_BAD_WORLD_COORD
Definition: wcs.h:1768
WCSERR_NO_SOLUTION
@ WCSERR_NO_SOLUTION
Definition: wcs.h:1769
tabprm
Tabular transformation parameters.
Definition: tab.h:546
wcssub
int wcssub(int alloc, const struct wcsprm *wcssrc, int *nsub, int axes[], struct wcsprm *wcsdst)
Subimage extraction routine for the wcsprm struct.
wcsprm::spc
struct spcprm spc
Definition: wcs.h:1913
celprm
Celestial transformation parameters.
Definition: cel.h:398
wcsprm::pc
double * pc
Definition: wcs.h:1819
wcsprm::mjdobs
double mjdobs
Definition: wcs.h:1872
wcsprm::ctype
char(* ctype)[72]
Definition: wcs.h:1824
pvcard::m
int m
Definition: wcs.h:1780
wcsprm::m_csyer
double * m_csyer
Definition: wcs.h:1933
wcsprm::wcsname
char wcsname[72]
Definition: wcs.h:1863
wcsprm::radesys
char radesys[72]
Definition: wcs.h:1882
wcsprm::naxis
int naxis
Definition: wcs.h:1817
wcsmix
int wcsmix(struct wcsprm *wcs, int mixpix, int mixcel, const double vspan[], double vstep, int viter, double world[], double phi[], double theta[], double imgcrd[], double pixcrd[])
Hybrid coordinate transformation.
pvcard::value
double value
Definition: wcs.h:1781
wcsbchk
int wcsbchk(struct wcsprm *wcs, int bounds)
Enable/disable bounds checking.
wcsprm::tab
struct tabprm * tab
Definition: wcs.h:1899
wcsprm::xposure
double xposure
Definition: wcs.h:1875
wcsprm::colnum
int colnum
Definition: wcs.h:1854
wcsperr
int wcsperr(const struct wcsprm *wcs, const char *prefix)
Print error messages from a wcsprm struct.
wcsprm::m_naxis
int m_naxis
Definition: wcs.h:1925
wcsprm::plephem
char plephem[72]
Definition: wcs.h:1865
wcsprm::cunit
char(* cunit)[72]
Definition: wcs.h:1823
wcsprm::npvmax
int npvmax
Definition: wcs.h:1833
wcsprm::m_czphs
double * m_czphs
Definition: wcs.h:1933
wcsprm::aux
struct auxprm * aux
Definition: wcs.h:1893
linprm
Linear transformation parameters.
Definition: lin.h:631
wtbarr::i
int i
Definition: getwcstab.h:171
WCSERR_BAD_WORLD
@ WCSERR_BAD_WORLD
Definition: wcs.h:1766
wcsprm::npsmax
int npsmax
Definition: wcs.h:1837
auxprm::hgln_obs
double hgln_obs
Definition: wcs.h:1802
wcsprm::m_colax
int * m_colax
Definition: wcs.h:1931
wcsprm::bepoch
double bepoch
Definition: wcs.h:1873
pvcard
Store for PVi_ma keyrecords.
Definition: wcs.h:1778
wcsprm::crder
double * crder
Definition: wcs.h:1858
wcserr
Error message handling.
Definition: wcserr.h:223
wcsprm::equinox
double equinox
Definition: wcs.h:1883
wcsp2s
int wcsp2s(struct wcsprm *wcs, int ncoord, int nelem, const double pixcrd[], double imgcrd[], double phi[], double theta[], double world[], int stat[])
Pixel-to-world transformation.
wcsnps
int wcsnps(int n)
Memory allocation for PSi_ma.
wcsprm::csyer
double * csyer
Definition: wcs.h:1859
wcsfree
int wcsfree(struct wcsprm *wcs)
Destructor for the wcsprm struct.
pscard
Store for PSi_ma keyrecords.
Definition: wcs.h:1788
wcs_errmsg
const char * wcs_errmsg[]
Status return messages.
wcsprm::lonpole
double lonpole
Definition: wcs.h:1826
wcsprm::m_cdelt
double * m_cdelt
Definition: wcs.h:1926
wcsprm::velosys
double velosys
Definition: wcs.h:1886
wcsprm::cdelt
double * cdelt
Definition: wcs.h:1820
wcsprm::m_cunit
char(* m_cunit)[72]
Definition: wcs.h:1927
wcsprm::ssyssrc
char ssyssrc[72]
Definition: wcs.h:1888
wcsprm::wtb
struct wtbarr * wtb
Definition: wcs.h:1900
WCSERR_MEMORY
@ WCSERR_MEMORY
Definition: wcs.h:1754
lin.h
wcsprm::velref
int velref
Definition: wcs.h:1848
wcssptr
int wcssptr(struct wcsprm *wcs, int *i, char ctype[9])
Spectral axis translation.
wcsprm::m_crval
double * m_crval
Definition: wcs.h:1926
wcsprm::ntab
int ntab
Definition: wcs.h:1897
WCSERR_SINGULAR_MTX
@ WCSERR_SINGULAR_MTX
Definition: wcs.h:1755
wcsprm::czphs
double * czphs
Definition: wcs.h:1860
wcsprm::mjdref
double mjdref[2]
Definition: wcs.h:1868
wcsprm::nwtb
int nwtb
Definition: wcs.h:1898
wcsini
int wcsini(int alloc, int naxis, struct wcsprm *wcs)
Default constructor for the wcsprm struct.
auxprm
Additional auxiliary parameters.
Definition: wcs.h:1798