WCSLIB  4.25.1
dis.h
Go to the documentation of this file.
1 /*============================================================================
2 
3  WCSLIB 5.2 - an implementation of the FITS WCS standard.
4  Copyright (C) 1995-2015, 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: dis.h,v 5.2 2015/04/15 12:35:07 mcalabre Exp $
26 *=============================================================================
27 *
28 * WCSLIB 5.2 - experimental C routines that implement proposed extensions to
29 * the FITS World Coordinate System (WCS) standard. Refer to
30 *
31 * "Representations of distortions in FITS world coordinate systems",
32 * Calabretta, M.R. et al. (Paper IV), draft dated 2004/04/22 available from
33 * http://www.atnf.csiro.au/people/Mark.Calabretta
34 *
35 * The distortion function component of the TPV "projection" is also supported.
36 * The TPV projection, originally proposed in a draft of WCS Paper II, consists
37 * of a TAN projection with sequent polynomial distortion, the coefficients of
38 * which are encoded in PVi_ma keyrecords. Full details may be found at the
39 * registry of FITS conventions:
40 *
41 * http://fits.gsfc.nasa.gov/registry/tpvwcs/tpv.html
42 *
43 * Refer to the README file provided with WCSLIB for an overview of the
44 * library.
45 *
46 *
47 * Summary of the dis routines
48 * ---------------------------
49 * These routines apply the distortion functions defined by the extension to
50 * the FITS WCS standard proposed in Paper IV. They are based on the disprm
51 * struct which contains all information needed for the computations. The
52 * struct contains some members that must be set by the user, and others that
53 * are maintained by these routines, somewhat like a C++ class but with no
54 * encapsulation.
55 *
56 * disndp(), dpfill(), disini(), discpy(), and disfree() are provided to manage
57 * the disprm struct, and another, disprt(), prints its contents.
58 *
59 * A setup routine, disset(), computes intermediate values in the disprm struct
60 * from parameters in it that were supplied by the user. The struct always
61 * needs to be set up by disset(), though disset() need not be called
62 * explicitly - refer to the explanation of disprm::flag.
63 *
64 * disp2x() and disx2p() implement the WCS distortion functions, disp2x() using
65 * separate functions, such as dispoly() and tpv7(), to do the computation.
66 *
67 * An auxiliary routine, diswarp(), computes various measures of the distortion
68 * over a specified range of coordinates.
69 *
70 * PLEASE NOTE: Distortions are not currently handled by wcspih(), wcsbth(),
71 * wcssub(), wcscompare(), or wcshdo().
72 *
73 *
74 * disndp() - Memory allocation for DPja and DQia
75 * ----------------------------------------------
76 * disndp() changes the value of NDPMAX (default 256). This global variable
77 * controls the number of dpkey structs, for holding DPja or DQia keyvalues,
78 * that disini() should allocate space for.
79 *
80 * PLEASE NOTE: This function is not thread-safe.
81 *
82 * Given:
83 * n int Value of NDPMAX; ignored if < 0.
84 *
85 * Function return value:
86 * int Current value of NDPMAX.
87 *
88 *
89 * dpfill() - Fill the contents of a dpkey struct
90 * ----------------------------------------------
91 * dpfill() is a utility routine to aid in filling the contents of the dpkey
92 * struct. No checks are done on the validity of the inputs.
93 *
94 * Given and returned:
95 * dp struct dpkey*
96 * Store for DPja and DQia keyrecords.
97 *
98 * Given:
99 * keyword const char *
100 * field const char *
101 * These arguments are concatenated with an intervening
102 * "." to construct the full record field name, i.e.
103 * including the keyword name, DPja or DQia (but
104 * excluding the colon delimiter which is NOT part of the
105 * name). Either may be given as a NULL pointer. Set
106 * both NULL to omit setting this component of the
107 * struct.
108 *
109 * j int Axis number (1-relative), i.e. the j in DPja or
110 * i in DQia. Can be given as 0, in which case the axis
111 * number will be obtained from the keyword component of
112 * the field name which must either have been given or
113 * preset.
114 *
115 * type int Data type of the record's value
116 * 1: Integer,
117 * 2: Floating point.
118 *
119 * ival int For type == 1, the integer value of the record.
120 *
121 * fval double For type == 1, the floating point value of the record.
122 *
123 * Function return value:
124 * int Status return value:
125 * 0: Success.
126 *
127 *
128 * disini() - Default constructor for the disprm struct
129 * ----------------------------------------------------
130 * disini() allocates memory for arrays in a disprm struct and sets all members
131 * of the struct to default values. Memory is allocated for up to NDPMAX DPja
132 * or DQia keywords per WCS representation. This may be changed via disndp()
133 * before disini() is called.
134 *
135 * PLEASE NOTE: every disprm struct must be initialized by disini(), possibly
136 * repeatedly. On the first invokation, and only the first invokation,
137 * disprm::flag must be set to -1 to initialize memory management, regardless
138 * of whether disini() will actually be used to allocate memory.
139 *
140 * Given:
141 * alloc int If true, allocate memory unconditionally for arrays in
142 * the disprm struct.
143 *
144 * If false, it is assumed that pointers to these arrays
145 * have been set by the user except if they are null
146 * pointers in which case memory will be allocated for
147 * them regardless. (In other words, setting alloc true
148 * saves having to initalize these pointers to zero.)
149 *
150 * naxis int The number of world coordinate axes, used to determine
151 * array sizes.
152 *
153 * Given and returned:
154 * dis struct disprm*
155 * Distortion function parameters. Note that, in order
156 * to initialize memory management disprm::flag must be
157 * set to -1 when dis is initialized for the first time
158 * (memory leaks may result if it had already been
159 * initialized).
160 *
161 * Function return value:
162 * int Status return value:
163 * 0: Success.
164 * 1: Null disprm pointer passed.
165 * 2: Memory allocation failed.
166 *
167 * For returns > 1, a detailed error message is set in
168 * disprm::err if enabled, see wcserr_enable().
169 *
170 *
171 * discpy() - Copy routine for the disprm struct
172 * ---------------------------------------------
173 * discpy() does a deep copy of one disprm struct to another, using disini() to
174 * allocate memory unconditionally for its arrays if required. Only the
175 * "information to be provided" part of the struct is copied; a call to
176 * disset() is required to initialize the remainder.
177 *
178 * Given:
179 * alloc int If true, allocate memory unconditionally for arrays in
180 * the destination. Otherwise, it is assumed that
181 * pointers to these arrays have been set by the user
182 * except if they are null pointers in which case memory
183 * will be allocated for them regardless.
184 *
185 * dissrc const struct disprm*
186 * Struct to copy from.
187 *
188 * Given and returned:
189 * disdst struct disprm*
190 * Struct to copy to. disprm::flag should be set to -1
191 * if disdst was not previously initialized (memory leaks
192 * may result if it was previously initialized).
193 *
194 * Function return value:
195 * int Status return value:
196 * 0: Success.
197 * 1: Null disprm pointer passed.
198 * 2: Memory allocation failed.
199 *
200 * For returns > 1, a detailed error message is set in
201 * disprm::err if enabled, see wcserr_enable().
202 *
203 *
204 * disfree() - Destructor for the disprm struct
205 * --------------------------------------------
206 * disfree() frees memory allocated for the disprm arrays by disini().
207 * disini() keeps a record of the memory it allocates and disfree() will only
208 * attempt to free this.
209 *
210 * PLEASE NOTE: disfree() must not be invoked on a disprm struct that was not
211 * initialized by disini().
212 *
213 * Given:
214 * dis struct disprm*
215 * Distortion function parameters.
216 *
217 * Function return value:
218 * int Status return value:
219 * 0: Success.
220 * 1: Null disprm pointer passed.
221 *
222 *
223 * disprt() - Print routine for the disprm struct
224 * ----------------------------------------------
225 * disprt() prints the contents of a disprm struct using wcsprintf(). Mainly
226 * intended for diagnostic purposes.
227 *
228 * Given:
229 * dis const struct disprm*
230 * Distortion function parameters.
231 *
232 * Function return value:
233 * int Status return value:
234 * 0: Success.
235 * 1: Null disprm pointer passed.
236 *
237 *
238 * disset() - Setup routine for the disprm struct
239 * ----------------------------------------------
240 * disset(), sets up the disprm struct according to information supplied within
241 * it - refer to the explanation of disprm::flag.
242 *
243 * Note that this routine need not be called directly; it will be invoked by
244 * disp2x() and disx2p() if the disprm::flag is anything other than a
245 * predefined magic value.
246 *
247 * Given and returned:
248 * dis struct disprm*
249 * Distortion function parameters.
250 *
251 * Function return value:
252 * int Status return value:
253 * 0: Success.
254 * 1: Null disprm pointer passed.
255 * 2: Memory allocation failed.
256 * 3: Invalid parameter.
257 *
258 * For returns > 1, a detailed error message is set in
259 * disprm::err if enabled, see wcserr_enable().
260 *
261 *
262 * disp2x() - Apply distortion function
263 * ------------------------------------
264 * disp2x() applies the distortion functions. By definition, the distortion
265 * is in the pixel-to-world direction.
266 *
267 * Depending on the point in the algorithm chain at which it is invoked,
268 * disp2x() may transform pixel coordinates to corrected pixel coordinates, or
269 * intermediate pixel coordinates to corrected intermediate pixel coordinates,
270 * or image coordinates to corrected image coordinates.
271 *
272 *
273 * Given and returned:
274 * dis struct disprm*
275 * Distortion function parameters.
276 *
277 * Given:
278 * rawcrd const double[naxis]
279 * Array of coordinates.
280 *
281 * Returned:
282 * discrd double[naxis]
283 * Array of coordinates to which the distortion functions
284 * have been applied.
285 *
286 * Function return value:
287 * int Status return value:
288 * 0: Success.
289 * 1: Null disprm pointer passed.
290 * 2: Memory allocation failed.
291 * 3: Invalid parameter.
292 * 4: Distort error.
293 *
294 * For returns > 1, a detailed error message is set in
295 * disprm::err if enabled, see wcserr_enable().
296 *
297 *
298 * disx2p() - Apply de-distortion function
299 * ---------------------------------------
300 * disx2p() applies the inverse of the distortion functions. By definition,
301 * the de-distortion is in the world-to-pixel direction.
302 *
303 * Depending on the point in the algorithm chain at which it is invoked,
304 * disx2p() may transform corrected pixel coordinates to pixel coordinates, or
305 * corrected intermediate pixel coordinates to intermediate pixel coordinates,
306 * or corrected image coordinates to image coordinates.
307 *
308 * disx2p() iteratively solves for the inverse using disp2x(). It assumes
309 * that the distortion is small and the functions are well-behaved, being
310 * continuous and with continuous derivatives. Also that, to first order
311 * in the neighbourhood of the solution, discrd[j] ~= a + b*rawcrd[j], i.e.
312 * independent of rawcrd[i], where i != j. This is effectively equivalent to
313 * assuming that the distortion functions are separable to first order.
314 * Furthermore, a is assumed to be small, and b close to unity.
315 *
316 * Given and returned:
317 * dis struct disprm*
318 * Distortion function parameters.
319 *
320 * Given:
321 * discrd const double[naxis]
322 * Array of coordinates.
323 *
324 * Returned:
325 * rawcrd double[naxis]
326 * Array of coordinates to which the inverse distortion
327 * functions have been applied.
328 *
329 * Function return value:
330 * int Status return value:
331 * 0: Success.
332 * 1: Null disprm pointer passed.
333 * 2: Memory allocation failed.
334 * 3: Invalid parameter.
335 * 5: De-distort error.
336 *
337 * For returns > 1, a detailed error message is set in
338 * disprm::err if enabled, see wcserr_enable().
339 *
340 *
341 * diswarp() - Compute measures of distortion
342 * ------------------------------------------
343 * diswarp() computes various measures of the distortion over a specified range
344 * of coordinates.
345 *
346 * For prior distortions, the measures may be interpreted simply as an offset
347 * in pixel coordinates. For sequent distortions, the interpretation depends
348 * on the nature of the linear transformation matrix (PCi_ja or CDi_ja). If
349 * the latter introduces a scaling, then the measures will also be scaled.
350 * Note also that the image domain, which is rectangular in pixel coordinates,
351 * may be rotated, skewed, and/or stretched in intermediate pixel coordinates,
352 * and in general cannot be defined using pixblc[] and pixtrc[].
353 *
354 * PLEASE NOTE: the measures of total distortion may be essentially meaningless
355 * if there are multiple sequent distortions with different scaling.
356 *
357 * See also linwarp().
358 *
359 * Given and returned:
360 * dis struct disprm*
361 * Distortion function parameters.
362 *
363 * Given:
364 * pixblc const double[naxis]
365 * Start of the range of pixel coordinates (for prior
366 * distortions), or intermediate pixel coordinates (for
367 * sequent distortions). May be specified as a NULL
368 * pointer which is interpreted as (1,1,...).
369 *
370 * pixtrc const double[naxis]
371 * End of the range of pixel coordinates (prior) or
372 * intermediate pixel coordinates (sequent).
373 *
374 * pixsamp const double[naxis]
375 * If positive or zero, the increment on the particular
376 * axis, starting at pixblc[]. Zero is interpreted as a
377 * unit increment. pixsamp may also be specified as a
378 * NULL pointer which is interpreted as all zeroes, i.e.
379 * unit increments on all axes.
380 *
381 * If negative, the grid size on the particular axis (the
382 * absolute value being rounded to the nearest integer).
383 * For example, if pixsamp is (-128.0,-128.0,...) then
384 * each axis will be sampled at 128 points between
385 * pixblc[] and pixtrc[] inclusive. Use caution when
386 * using this option on non-square images.
387 *
388 * Returned:
389 * nsamp int* The number of pixel coordinates sampled.
390 *
391 * Can be specified as a NULL pointer if not required.
392 *
393 * maxdis double[naxis]
394 * For each individual distortion function, the
395 * maximum absolute value of the distortion.
396 *
397 * Can be specified as a NULL pointer if not required.
398 *
399 * maxtot double* For the combination of all distortion functions, the
400 * maximum absolute value of the distortion.
401 *
402 * Can be specified as a NULL pointer if not required.
403 *
404 * avgdis double[naxis]
405 * For each individual distortion function, the
406 * mean value of the distortion.
407 *
408 * Can be specified as a NULL pointer if not required.
409 *
410 * avgtot double* For the combination of all distortion functions, the
411 * mean value of the distortion.
412 *
413 * Can be specified as a NULL pointer if not required.
414 *
415 * rmsdis double[naxis]
416 * For each individual distortion function, the
417 * root mean square deviation of the distortion.
418 *
419 * Can be specified as a NULL pointer if not required.
420 *
421 * rmstot double* For the combination of all distortion functions, the
422 * root mean square deviation of the distortion.
423 *
424 * Can be specified as a NULL pointer if not required.
425 *
426 * Function return value:
427 * int Status return value:
428 * 0: Success.
429 * 1: Null disprm pointer passed.
430 * 2: Memory allocation failed.
431 * 3: Invalid parameter.
432 * 4: Distort error.
433 *
434 *
435 * disprm struct - Distortion parameters
436 * -------------------------------------
437 * The disprm struct contains all of the information required to apply a set of
438 * distortion functions. It consists of certain members that must be set by
439 * the user ("given") and others that are set by the WCSLIB routines
440 * ("returned"). While the addresses of the arrays themselves may be set by
441 * disini() if it (optionally) allocates memory, their contents must be set by
442 * the user.
443 *
444 * int flag
445 * (Given and returned) This flag must be set to zero whenever any of the
446 * following members of the disprm struct are set or modified:
447 *
448 * - disprm::naxis,
449 * - disprm::dtype,
450 * - disprm::ndp,
451 * - disprm::dp.
452 *
453 * This signals the initialization routine, disset(), to recompute the
454 * returned members of the disprm struct. disset() will reset flag to
455 * indicate that this has been done.
456 *
457 * PLEASE NOTE: flag must be set to -1 when disini() is called for the
458 * first time for a particular disprm struct in order to initialize memory
459 * management. It must ONLY be used on the first initialization otherwise
460 * memory leaks may result.
461 *
462 * int naxis
463 * (Given or returned) Number of pixel and world coordinate elements.
464 *
465 * If disini() is used to initialize the disprm struct (as would normally
466 * be the case) then it will set naxis from the value passed to it as a
467 * function argument. The user should not subsequently modify it.
468 *
469 * char (*dtype)[16]
470 * (Given) Pointer to the first element of an array of char[16] containing
471 * the name of the distortion function for each axis.
472 *
473 * int ndp
474 * (Given) The number of entries in the disprm::dp[] array.
475 *
476 * int ndpmax
477 * (Given) The length of the disprm::dp[] array.
478 *
479 * ndpmax will be set by disini() if it allocates memory for disprm::dp[],
480 * otherwise it must be set by the user. See also disndp().
481 *
482 * struct dpkey dp
483 * (Given) Address of the first element of an array of length ndpmax of
484 * dpkey structs.
485 *
486 * As a FITS header parser encounters each DPja or DQia keyword it should
487 * load it into a dpkey struct in the array and increment ndp. disset()
488 * interprets these as required.
489 *
490 * double *maxdis
491 * (Given) Pointer to the first element of an array of double specifying
492 * the maximum absolute value of the distortion for each axis computed over
493 * the whole image.
494 *
495 * It is not necessary to reset the disprm struct (via disset()) when
496 * disprm::maxdis is changed.
497 *
498 * double totdis
499 * (Given) The maximum absolute value of the combination of all distortion
500 * functions specified as an offset in pixel coordinates computed over the
501 * whole image.
502 *
503 * It is not necessary to reset the disprm struct (via disset()) when
504 * disprm::totdis is changed.
505 *
506 * int **axmap
507 * (Returned) Pointer to the first element of an array of int* containing
508 * pointers to the first elements of the axis mapping arrays for each axis.
509 *
510 * An axis mapping associates the independent variables of a distortion
511 * function with the 1-relative image axis number. For example, consider
512 * an image with a spectrum on the first axis, followed by RA, Dec, and
513 * time axes. For a distortion in (RA,Dec) and no distortion on the
514 * spectral or time axes, the axis mapping arrays, axmap[j][], would be
515 *
516 = j=0: [0, 0, 0, 0] ...no distortion on spectral axis,
517 = 1: [2, 3, 0, 0] ...RA distortion depends on RA and Dec,
518 = 2: [3, 2, 0, 0] ...Dec distortion depends on Dec and RA,
519 = 3: [0, 0, 0, 0] ...no distortion on time axis,
520 *
521 * where zero indicates that there is no corresponding independent
522 * variable.
523 *
524 * int *Nhat
525 * (Returned) Pointer to the first element of an array of int* containing
526 * the number of coordinate axes that form the independent variables of the
527 * distortion function.
528 *
529 * double **offset
530 * (Returned) Pointer to the first element of an array of double*
531 * containing an offset used to renormalize the independent variables of
532 * the distortion function for each axis.
533 *
534 * The offsets are subtracted from the independent variables before
535 * scaling.
536 *
537 * double **scale
538 * (Returned) Pointer to the first element of an array of double*
539 * containing a scale used to renormalize the independent variables of the
540 * distortion function for each axis.
541 *
542 * The scale is applied to the independent variables after the offsets are
543 * subtracted.
544 *
545 * int **iparm
546 * (Returned) Pointer to the first element of an array of int*
547 * containing pointers to the first elements of the arrays of integer
548 * distortion parameters for each axis.
549 *
550 * double **dparm
551 * (Returned) Pointer to the first element of an array of double*
552 * containing pointers to the first elements of the arrays of floating
553 * point distortion parameters for each axis.
554 *
555 * int i_naxis
556 * (Returned) Dimension of the internal arrays (normally equal to naxis).
557 *
558 * int ndis
559 * (Returned) The number of distortion functions.
560 *
561 * struct wcserr *err
562 * (Returned) If enabled, when an error status is returned, this struct
563 * contains detailed information about the error, see wcserr_enable().
564 *
565 * int (**disp2x)(DISP2X_ARGS)
566 * (For internal use only.)
567 * int (**disx2p)(DISX2P_ARGS)
568 * (For internal use only.)
569 * double *tmpmem
570 * (For internal use only.)
571 * int m_flag
572 * (For internal use only.)
573 * int m_naxis
574 * (For internal use only.)
575 * char (*m_dtype)[16]
576 * (For internal use only.)
577 * double **m_dp
578 * (For internal use only.)
579 * double *m_maxdis
580 * (For internal use only.)
581 *
582 *
583 * dpkey struct - Store for DPja and DQia keyrecords
584 * -------------------------------------------------
585 * The dpkey struct is used to pass the parsed contents of DPja and DQia
586 * keyrecords to disset() via the disprm struct.
587 *
588 * All members of this struct are to be set by the user.
589 *
590 * char field[72]
591 * (Given) The full field name of the record, including the keyword name.
592 * Note that the colon delimiter separating the field name and the value in
593 * record-valued keyvalues is not part of the field name. For example, in
594 * the following:
595 *
596 = DP3A = 'AXIS.1: 2'
597 *
598 * the full record field name is "DP3A.AXIS.1", and the record's value
599 * is 2.
600 *
601 * int j
602 * (Given) Axis number (1-relative), i.e. the j in DPja or i in DQia.
603 *
604 * int type
605 * (Given) The data type of the record's value
606 * - 0: Integer (stored as an int),
607 * - 1: Floating point (stored as a double).
608 *
609 * union value
610 * (Given) A union comprised of
611 * - dpkey::ival,
612 * - dpkey::fval,
613 *
614 * the record's value.
615 *
616 *
617 * Global variable: const char *dis_errmsg[] - Status return messages
618 * ------------------------------------------------------------------
619 * Error messages to match the status value returned from each function.
620 *
621 *===========================================================================*/
622 
623 #ifndef WCSLIB_DIS
624 #define WCSLIB_DIS
625 
626 #ifdef __cplusplus
627 extern "C" {
628 #endif
629 
630 
631 extern const char *dis_errmsg[];
632 
634  DISERR_SUCCESS = 0, /* Success. */
635  DISERR_NULL_POINTER = 1, /* Null disprm pointer passed. */
636  DISERR_MEMORY = 2, /* Memory allocation failed. */
637  DISERR_BAD_PARAM = 3, /* Invalid parameter value. */
638  DISERR_DISTORT = 4, /* Distortion error. */
639  DISERR_DEDISTORT = 5 /* De-distortion error. */
640 };
641 
642 /* For use in declaring distortion function prototypes. */
643 #define DISP2X_ARGS const int iparm[], const double dparm[], int ncrd, \
644 const double rawcrd[], double *discrd
645 
646 /* For use in declaring de-distortion function prototypes. */
647 #define DISX2P_ARGS const int iparm[], const double dparm[], int ncrd, \
648 const double discrd[], double rawcrd[]
649 
650 
651 /* Struct used for storing DPja and DQia keyvalues. */
652 struct dpkey {
653  char field[72]; /* Full record field name (no colon). */
654  int j; /* Axis number, as in DPja (1-relative). */
655  int type; /* Data type of value. */
656  union {
657  int i; /* Integer record value. */
658  double f; /* Floating point record value. */
659  } value; /* Record value. */
660 };
661 
662 /* Size of the dpkey struct in int units, used by the Fortran wrappers. */
663 #define DPLEN (sizeof(struct dpkey)/sizeof(int))
664 
665 
666 struct disprm {
667  /* Initialization flag (see the prologue above). */
668  /*------------------------------------------------------------------------*/
669  int flag; /* Set to zero to force initialization. */
670 
671  /* Parameters to be provided (see the prologue above). */
672  /*------------------------------------------------------------------------*/
673  int naxis; /* The number of pixel coordinate elements, */
674  /* given by NAXIS. */
675  char (*dtype)[16]; /* For each axis, the distortion type. */
676  int ndp; /* Number of DPja or DQia keywords, and the */
677  int ndpmax; /* number for which space was allocated. */
678  struct dpkey *dp; /* DPja and DQia keyvalues. */
679  double *maxdis; /* For each axis, the maximum distortion. */
680  double totdis; /* The maximum combined distortion. */
681 
682  /* Information derived from the parameters supplied. */
683  /*------------------------------------------------------------------------*/
684  int **axmap; /* For each axis, the axis mapping array. */
685  int *Nhat; /* For each axis, the number of coordinate */
686  /* axes that form the independent variables */
687  /* of the distortion function. */
688  double **offset; /* For each axis, renormalization offsets. */
689  double **scale; /* For each axis, renormalization scales. */
690  int **iparm; /* For each axis, the array of integer */
691  /* distortion parameters. */
692  double **dparm; /* For each axis, the array of floating */
693  /* point distortion parameters. */
694  int i_naxis; /* Dimension of the internal arrays. */
695  int ndis; /* The number of distortion functions. */
696 
697  /* Error handling, if enabled. */
698  /*------------------------------------------------------------------------*/
699  struct wcserr *err;
700 
701  /* Private - the remainder are for internal use. */
702  /*------------------------------------------------------------------------*/
703  int (**disp2x)(DISP2X_ARGS); /* For each axis, pointers to the */
704  int (**disx2p)(DISX2P_ARGS); /* distortion function and its inverse. */
705 
706  double *tmpmem;
707 
708  int m_flag, m_naxis; /* The remainder are for memory management. */
709  char (*m_dtype)[16];
710  struct dpkey *m_dp;
711  double *m_maxdis;
712 };
713 
714 /* Size of the disprm struct in int units, used by the Fortran wrappers. */
715 #define DISLEN (sizeof(struct disprm)/sizeof(int))
716 
717 
718 int disndp(int n);
719 
720 int dpfill(struct dpkey *dp, const char *keyword, const char *field, int j,
721  int type, int ival, double fval);
722 
723 int disini(int alloc, int naxis, struct disprm *dis);
724 
725 int discpy(int alloc, const struct disprm *dissrc, struct disprm *disdst);
726 
727 int disfree(struct disprm *dis);
728 
729 int disprt(const struct disprm *dis);
730 
731 int disset(struct disprm *dis);
732 
733 int disp2x(struct disprm *dis, const double rawcrd[], double discrd[]);
734 
735 int disx2p(struct disprm *dis, const double discrd[], double rawcrd[]);
736 
737 int diswarp(struct disprm *dis, const double pixblc[], const double pixtrc[],
738  const double pixsamp[], int *nsamp,
739  double maxdis[], double *maxtot,
740  double avgdis[], double *avgtot,
741  double rmsdis[], double *rmstot);
742 
743 
744 /* Specialist distortion functions (internal use only). */
745 int polyset(int j, struct disprm *dis);
746 int dispoly(DISP2X_ARGS);
747 
748 int tpvset(int j, struct disprm *dis);
749 int tpv1(DISP2X_ARGS);
750 int tpv2(DISP2X_ARGS);
751 int tpv3(DISP2X_ARGS);
752 int tpv4(DISP2X_ARGS);
753 int tpv5(DISP2X_ARGS);
754 int tpv6(DISP2X_ARGS);
755 int tpv7(DISP2X_ARGS);
756 
757 #ifdef __cplusplus
758 }
759 #endif
760 
761 #endif /* WCSLIB_DIS */
int type
Definition: dis.h:655
int flag
Definition: dis.h:669
Store for DPja and DQia keyrecords.
Definition: dis.h:652
int discpy(int alloc, const struct disprm *dissrc, struct disprm *disdst)
Copy routine for the disprm struct.
int ** iparm
Definition: dis.h:690
Definition: dis.h:638
const char * dis_errmsg[]
Status return messages.
int ** axmap
Definition: dis.h:684
int disp2x(struct disprm *dis, const double rawcrd[], double discrd[])
Apply distortion function.
double ** scale
Definition: dis.h:689
Error message handling.
Definition: wcserr.h:221
int disx2p(struct disprm *dis, const double discrd[], double rawcrd[])
Apply de-distortion function.
Definition: dis.h:637
int dpfill(struct dpkey *dp, const char *keyword, const char *field, int j, int type, int ival, double fval)
Fill the contents of a dpkey struct.
int disset(struct disprm *dis)
Setup routine for the disprm struct.
int naxis
Definition: dis.h:673
int tpv5(DISP2X_ARGS)
(Internal use only.)
struct dpkey * dp
Definition: dis.h:678
int tpv1(DISP2X_ARGS)
(Internal use only.)
int m_flag
Definition: dis.h:708
Definition: dis.h:639
int ndis
Definition: dis.h:695
Distortion parameters.
Definition: dis.h:666
char field[72]
Definition: dis.h:653
int tpv3(DISP2X_ARGS)
(Internal use only.)
char(* dtype)[16]
Definition: dis.h:675
int ndp
Definition: dis.h:676
int j
Definition: dis.h:654
Definition: dis.h:635
int * Nhat
Definition: dis.h:685
int disfree(struct disprm *dis)
Destructor for the disprm struct.
int tpv4(DISP2X_ARGS)
(Internal use only.)
dis_errmsg_enum
Definition: dis.h:633
int m_naxis
Definition: dis.h:708
int disprt(const struct disprm *dis)
Print routine for the disprm struct.
double * tmpmem
Definition: dis.h:706
int i_naxis
Definition: dis.h:694
double * maxdis
Definition: dis.h:679
double totdis
Definition: dis.h:680
int(** disx2p)(DISX2P_ARGS)
Definition: dis.h:704
Definition: dis.h:634
int tpvset(int j, struct disprm *dis)
(Internal use only.)
struct wcserr * err
Definition: dis.h:699
int disini(int alloc, int naxis, struct disprm *dis)
Default constructor for the disprm struct.
int tpv6(DISP2X_ARGS)
(Internal use only.)
union dpkey::@0 value
double f
Definition: dis.h:658
Definition: dis.h:636
int polyset(int j, struct disprm *dis)
int tpv2(DISP2X_ARGS)
(Internal use only.)
struct dpkey * m_dp
Definition: dis.h:710
double * m_maxdis
Definition: dis.h:711
int diswarp(struct disprm *dis, const double pixblc[], const double pixtrc[], const double pixsamp[], int *nsamp, double maxdis[], double *maxtot, double avgdis[], double *avgtot, double rmsdis[], double *rmstot)
Compute measures of distortion.
double ** offset
Definition: dis.h:688
#define DISX2P_ARGS
Definition: dis.h:647
int(** disp2x)(DISP2X_ARGS)
Definition: dis.h:703
int ndpmax
Definition: dis.h:677
int disndp(int n)
Memory allocation for DPja and DQia.
int i
Definition: dis.h:657
int dispoly(DISP2X_ARGS)
char(* m_dtype)[16]
Definition: dis.h:709
int tpv7(DISP2X_ARGS)
(Internal use only.)
#define DISP2X_ARGS
Definition: dis.h:643
double ** dparm
Definition: dis.h:692