WCSLIB: dis.h Source File

WCSLIB 8.9

Loading...
Searching...
No Matches
dis.h
Go to the documentation of this file.
1/*============================================================================
2 WCSLIB 8.9 - an implementation of the FITS WCS standard.
3 Copyright (C) 1995-2026, Mark Calabretta
4
5 This file is part of WCSLIB.
6
7 WCSLIB is free software: you can redistribute it and/or modify it under the
8 terms of the GNU Lesser General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or (at your option)
10 any later version.
11
12 WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with WCSLIB. If not, see http://www.gnu.org/licenses.
19
20 Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
21 http://www.atnf.csiro.au/computing/software/wcs
22 $Id: dis.h,v 8.9 2026/06/18 13:00:03 mcalabre Exp $
23*=============================================================================
24*
25* WCSLIB 8.9 - C routines that implement the FITS World Coordinate System
26* (WCS) standard. Refer to the README file provided with WCSLIB for an
27* overview of the library.
28*
29*
30* Summary of the dis routines
31* ---------------------------
32* Routines in this suite implement extensions to the FITS World Coordinate
33* System (WCS) standard proposed by
34*
35= "Representations of distortions in FITS world coordinate systems",
36= Calabretta, M.R. et al. (WCS Paper IV, draft dated 2004/04/22),
37= available from http://www.atnf.csiro.au/computing/software/wcs
38*
39* In brief, a distortion function may occupy one of two positions in the WCS
40* algorithm chain. Prior distortions precede the linear transformation
41* matrix, whether it be PCi_ja or CDi_ja, and sequent distortions follow it.
42* WCS Paper IV defines FITS keywords used to specify parameters for predefined
43* distortion functions. The following are used for prior distortions:
44*
45= CPDISja ...(string-valued, identifies the distortion function)
46= DPja ...(record-valued, parameters)
47= CPERRja ...(floating-valued, maximum value)
48*
49* Their counterparts for sequent distortions are CQDISia, DQia, and CQERRia.
50* An additional floating-valued keyword, DVERRa, records the maximum value of
51* the combined distortions.
52*
53* DPja and DQia are "record-valued". Syntactically, the keyvalues are
54* standard FITS strings, but they are to be interpreted in a special way.
55* The general form is
56*
57= DPja = '<field-specifier>: <float>'
58*
59* where the field-specifier consists of a sequence of fields separated by
60* periods, and the ': ' between the field-specifier and the floating-point
61* value is part of the record syntax. For example:
62*
63= DP1 = 'AXIS.1: 1'
64*
65* Certain field-specifiers are defined for all distortion functions, while
66* others are defined only for particular distortions. Refer to WCS Paper IV
67* for further details. wcspih() parses all distortion keywords and loads them
68* into a disprm struct for analysis by disset() which knows (or possibly does
69* not know) how to interpret them. Of the Paper IV distortion functions, only
70* the general Polynomial distortion is currently implemented here.
71*
72* TPV - the TPV "projection":
73* ---------------------------
74* The distortion function component of the TPV celestial "projection" is also
75* supported. The TPV projection, originally proposed in a draft of WCS Paper
76* II, consists of a TAN projection with sequent polynomial distortion, the
77* coefficients of which are encoded in PVi_ma keyrecords. Full details may be
78* found at
79*
80= http://fits.gsfc.nasa.gov/registry/tpvwcs/tpv.html
81*
82* Internally, wcsset() changes TPV to a TAN projection, translates the PVi_ma
83* keywords to DQia and loads them into a disprm struct. These DQia keyrecords
84* have the form
85*
86= DQia = 'TPV.m: <value>'
87*
88* where i, a, m, and the value for each DQia match each PVi_ma. Consequently,
89* WCSLIB would handle a FITS header containing these keywords, along with
90* CQDISia = 'TPV' and the required DQia.NAXES and DQia.AXIS.ihat keywords.
91*
92* Note that, as defined, TPV assumes that CDi_ja is used to define the linear
93* transformation. The section on historical idiosyncrasies (below) cautions
94* about translating CDi_ja to PCi_ja plus CDELTia in this case.
95*
96* SIP - Simple Imaging Polynomial:
97* --------------------------------
98* These routines also support the Simple Imaging Polynomial (SIP), whose
99* design was influenced by early drafts of WCS Paper IV. It is described in
100* detail in
101*
102= http://fits.gsfc.nasa.gov/registry/sip.html
103*
104* SIP, which is defined only as a prior distortion for 2-D celestial images,
105* has the interesting feature that it records an approximation to the inverse
106* polynomial distortion function. This is used by disx2p() to provide an
107* initial estimate for its more precise iterative inversion. The
108* special-purpose keywords used by SIP are parsed and translated by wcspih()
109* as follows:
110*
111= A_p_q = <value> -> DP1 = 'SIP.FWD.p_q: <value>'
112= AP_p_q = <value> -> DP1 = 'SIP.REV.p_q: <value>'
113= B_p_q = <value> -> DP2 = 'SIP.FWD.p_q: <value>'
114= BP_p_q = <value> -> DP2 = 'SIP.REV.p_q: <value>'
115= A_DMAX = <value> -> DPERR1 = <value>
116= B_DMAX = <value> -> DPERR2 = <value>
117*
118* SIP's A_ORDER and B_ORDER keywords are not used. WCSLIB would recognise a
119* FITS header containing the above keywords, along with CPDISja = 'SIP' and
120* the required DPja.NAXES keywords.
121*
122* DSS - Digitized Sky Survey:
123* ---------------------------
124* The Digitized Sky Survey resulted from the production of the Guide Star
125* Catalogue for the Hubble Space Telescope. Plate solutions based on a
126* polynomial distortion function were encoded in FITS using non-standard
127* keywords. Sect. 5.2 of WCS Paper IV describes how DSS coordinates may be
128* translated to a sequent Polynomial distortion using two auxiliary variables.
129* That translation is based on optimising the non-distortion component of the
130* plate solution.
131*
132* Following Paper IV, wcspih() translates the non-distortion component of DSS
133* coordinates to standard WCS keywords (CRPIXja, PCi_ja, CRVALia, etc), and
134* fills a wcsprm struct with their values. It encodes the DSS polynomial
135* coefficients as
136*
137= AMDXm = <value> -> DQ1 = 'AMD.m: <value>'
138= AMDYm = <value> -> DQ2 = 'AMD.m: <value>'
139*
140* WCSLIB would recognise a FITS header containing the above keywords, along
141* with CQDISia = 'DSS' and the required DQia.NAXES keywords.
142*
143* WAT - the TNX and ZPX "projections":
144* ------------------------------------
145* The TNX and ZPX "projections" add a polynomial distortion function to the
146* standard TAN and ZPN projections respectively. Unusually, the polynomial
147* may be expressed as the sum of Chebyshev or Legendre polynomials, or as a
148* simple sum of monomials, as described in
149*
150= http://fits.gsfc.nasa.gov/registry/tnx/tnx-doc.html
151= http://fits.gsfc.nasa.gov/registry/zpxwcs/zpx.html
152*
153* The polynomial coefficients are encoded in special-purpose WATi_n keywords
154* as a set of continued strings, thus providing the name for this distortion
155* type. WATi_n are parsed and translated by wcspih() into the following set:
156*
157= DQi = 'WAT.POLY: <value>'
158= DQi = 'WAT.XMIN: <value>'
159= DQi = 'WAT.XMAX: <value>'
160= DQi = 'WAT.YMIN: <value>'
161= DQi = 'WAT.YMAX: <value>'
162= DQi = 'WAT.CHBY.m_n: <value>' or
163= DQi = 'WAT.LEGR.m_n: <value>' or
164= DQi = 'WAT.MONO.m_n: <value>'
165*
166* along with CQDISia = 'WAT' and the required DPja.NAXES keywords. For ZPX,
167* the ZPN projection parameters are also encoded in WATi_n, and wcspih()
168* translates these to standard PVi_ma.
169*
170* Note that, as defined, TNX and ZPX assume that CDi_ja is used to define the
171* linear transformation. The section on historical idiosyncrasies (below)
172* cautions about translating CDi_ja to PCi_ja plus CDELTia in this case.
173*
174* TPD - Template Polynomial Distortion:
175* -------------------------------------
176* The "Template Polynomial Distortion" (TPD) is a superset of the TPV, SIP,
177* DSS, and WAT (TNX & ZPX) polynomial distortions that also supports 1-D usage
178* and inversions. Like TPV, SIP, and DSS, the form of the polynomial is fixed
179* (the "template") and only the coefficients for the required terms are set
180* non-zero. TPD generalizes TPV in going to 9th degree, SIP by accomodating
181* TPV's linear and radial terms, and DSS in both respects. While in theory
182* the degree of the WAT polynomial distortion in unconstrained, in practice it
183* is limited to values that can be handled by TPD.
184*
185* Within WCSLIB, TPV, SIP, DSS, and WAT are all implemented as special cases
186* of TPD. Indeed, TPD was developed precisely for that purpose. WAT
187* distortions expressed as the sum of Chebyshev or Legendre polynomials are
188* expanded for TPD as a simple sum of monomials. Moreover, the general
189* Polynomial distortion is translated and implemented internally as TPD
190* whenever possible.
191*
192* However, WCSLIB also recognizes 'TPD' as a distortion function in its own
193* right (i.e. a recognized value of CPDISja or CQDISia), for use as both prior
194* and sequent distortions. Its DPja and DQia keyrecords have the form
195*
196= DPja = 'TPD.FWD.m: <value>'
197= DPja = 'TPD.REV.m: <value>'
198*
199* for the forward and reverse distortion functions. Moreover, like the
200* general Polynomial distortion, TPD supports auxiliary variables, though only
201* as a linear transformation of pixel coordinates (p1,p2):
202*
203= x = a0 + a1*p1 + a2*p2
204= y = b0 + b1*p1 + b2*p2
205*
206* where the coefficients of the auxiliary variables (x,y) are recorded as
207*
208= DPja = 'AUX.1.COEFF.0: a0' ...default 0.0
209= DPja = 'AUX.1.COEFF.1: a1' ...default 1.0
210= DPja = 'AUX.1.COEFF.2: a2' ...default 0.0
211= DPja = 'AUX.2.COEFF.0: b0' ...default 0.0
212= DPja = 'AUX.2.COEFF.1: b1' ...default 0.0
213= DPja = 'AUX.2.COEFF.2: b2' ...default 1.0
214*
215* Though nowhere near as powerful, in typical applications TPD is considerably
216* faster than the general Polynomial distortion. As TPD has a finite and not
217* too large number of possible terms (60), the coefficients for each can be
218* stored (by disset()) in a fixed location in the disprm::dparm[] array. A
219* large part of the speedup then arises from evaluating the polynomial using
220* Horner's scheme.
221*
222* Separate implementations for polynomials of each degree, and conditionals
223* for 1-D polynomials and 2-D polynomials with and without the radial
224* variable, ensure that unused terms mostly do not impose a significant
225* computational overhead.
226*
227* The TPD terms are as follows
228*
229= 0: 1 4: xx 12: xxxx 24: xxxxxx 40: xxxxxxxx
230= 5: xy 13: xxxy 25: xxxxxy 41: xxxxxxxy
231= 1: x 6: yy 14: xxyy 26: xxxxyy 42: xxxxxxyy
232= 2: y 15: xyyy 27: xxxyyy 43: xxxxxyyy
233= 3: r 7: xxx 16: yyyy 28: xxyyyy 44: xxxxyyyy
234= 8: xxy 29: xyyyyy 45: xxxyyyyy
235= 9: xyy 17: xxxxx 30: yyyyyy 46: xxyyyyyy
236= 10: yyy 18: xxxxy 47: xyyyyyyy
237= 11: rrr 19: xxxyy 31: xxxxxxx 48: yyyyyyyy
238= 20: xxyyy 32: xxxxxxy
239= 21: xyyyy 33: xxxxxyy 49: xxxxxxxxx
240= 22: yyyyy 34: xxxxyyy 50: xxxxxxxxy
241= 23: rrrrr 35: xxxyyyy 51: xxxxxxxyy
242= 36: xxyyyyy 52: xxxxxxyyy
243= 37: xyyyyyy 53: xxxxxyyyy
244= 38: yyyyyyy 54: xxxxyyyyy
245= 39: rrrrrrr 55: xxxyyyyyy
246= 56: xxyyyyyyy
247= 57: xyyyyyyyy
248= 58: yyyyyyyyy
249= 59: rrrrrrrrr
250*
251* where r = sqrt(xx + yy). Note that even powers of r are excluded since they
252* can be accomodated by powers of (xx + yy).
253*
254* Note here that "x" refers to the axis to which the distortion function is
255* attached, with "y" being the complementary axis. So, for example, with
256* longitude on axis 1 and latitude on axis 2, for TPD attached to axis 1, "x"
257* refers to axis 1 and "y" to axis 2. For TPD attached to axis 2, "x" refers
258* to axis 2, and "y" to axis 1.
259*
260* TPV uses all terms up to 39. The m in its PVi_ma keywords translates
261* directly to the TPD coefficient number.
262*
263* SIP uses all terms except for 0, 3, 11, 23, 39, and 59, with terms 1 and 2
264* only used for the inverse. Its A_p_q, etc. keywords must be translated
265* using a map.
266*
267* DSS uses terms 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 17, 19, and 21. The presence
268* of a non-zero constant term arises through the use of auxiliary variables
269* with origin offset from the reference point of the TAN projection. However,
270* in the translation given by WCS Paper IV, the distortion polynomial is zero,
271* or very close to zero, at the reference pixel itself. The mapping between
272* DSS's AMDXm (or AMDYm) keyvalues and TPD coefficients, while still simple,
273* is not quite as straightforward as for TPV and SIP.
274*
275* WAT uses all but the radial terms, namely 3, 11, 23, 39, and 59. While the
276* mapping between WAT's monomial coefficients and TPD is fairly simple, for
277* its expression in terms of a sum of Chebyshev or Legendre polynomials it is
278* much less so.
279*
280* Historical idiosyncrasies:
281* --------------------------
282* In addition to the above, some historical distortion functions have further
283* idiosyncrasies that must be taken into account when translating them to TPD.
284*
285* WCS Paper IV specifies that a distortion function returns a correction to be
286* added to pixel coordinates (prior distortion) or intermediate pixel
287* coordinates (sequent distortion). The correction is meant to be small so
288* that ignoring the distortion function, i.e. setting the correction to zero,
289* produces a commensurately small error.
290*
291* However, rather than an additive correction, some historical distortion
292* functions (TPV, DSS) define a polynomial that returns the corrected
293* coordinates directly.
294*
295* The difference between the two approaches is readily accounted for simply by
296* adding or subtracting 1 from the coefficient of the first degree term of the
297* polynomial. However, it opens the way for considerable confusion.
298*
299* Additional to the formalism of WCS Paper IV, both the Polynomial and TPD
300* distortion functions recognise a keyword
301*
302= DPja = 'DOCORR: 0'
303*
304* which is meant to apply generally to indicate that the distortion function
305* returns the corrected coordinates directly. Any other value for DOCORR (or
306* its absence) indicates that the distortion function returns an additive
307* correction.
308*
309* WCS Paper IV also specifies that the independent variables of a distortion
310* function are pixel coordinates (prior distortion) or intermediate pixel
311* coordinates (sequent distortion).
312*
313* On the contrary, the independent variables of the SIP polynomial are pixel
314* coordinate offsets from the reference pixel. This is readily handled via
315* the renormalisation parameters
316*
317= DPja = 'OFFSET.jhat: <value>'
318*
319* where the value corresponds to CRPIXja.
320*
321* Likewise, because TPV, TNX, and ZPX are defined in terms of CDi_ja, the
322* independent variables of the polynomial are intermediate world coordinates
323* rather than intermediate pixel coordinates. Because sequent distortions
324* are always applied before CDELTia, if CDi_ja is translated to PCi_ja plus
325* CDELTia, then either CDELTia must be unity, or the distortion polynomial
326* coefficients must be adjusted to account for the change of scale.
327*
328* Summary of the dis routines:
329* ----------------------------
330* These routines apply the distortion functions defined by the extension to
331* the FITS WCS standard proposed in Paper IV. They are based on the disprm
332* struct which contains all information needed for the computations. The
333* struct contains some members that must be set by the user, and others that
334* are maintained by these routines, somewhat like a C++ class but with no
335* encapsulation.
336*
337* dpfill(), dpkeyi(), and dpkeyd() are provided to manage the dpkey struct.
338*
339* disndp(), disini(), disinit(), discpy(), and disfree() are provided to
340* manage the disprm struct, dissize() computes its total size including
341* allocated memory, disenq() returns information about the state of the
342* struct, and disprt() prints its contents.
343*
344* disperr() prints the error message(s) (if any) stored in a disprm struct.
345*
346* wcshdo() normally writes SIP and TPV headers in their native form if at all
347* possible. However, dishdo() may be used to set a flag that tells it to
348* write the header in the form of the TPD translation used internally.
349*
350* A setup routine, disset(), computes intermediate values in the disprm struct
351* from parameters in it that were supplied by the user. The struct always
352* needs to be set up by disset(), though disset() need not be called
353* explicitly - refer to the explanation of disprm::flag.
354*
355* disp2x() and disx2p() implement the WCS distortion functions, disp2x() using
356* separate functions, such as dispoly() and tpd7(), to do the computation.
357*
358* An auxiliary routine, diswarp(), computes various measures of the distortion
359* over a specified range of coordinates.
360*
361* PLEASE NOTE: Distortions are not yet handled by wcsbth(), or wcscompare().
362*
363*
364* disndp() - Memory allocation for DPja and DQia
365* ----------------------------------------------
366* disndp() sets or gets the value of NDPMAX (default 256). This global
367* variable controls the maximum number of dpkey structs, for holding DPja or
368* DQia keyvalues, that disini() should allocate space for. It is also used by
369* disinit() as the default value of ndpmax.
370*
371* PLEASE NOTE: This function is not thread-safe.
372*
373* Given:
374* n int Value of NDPMAX; ignored if < 0. Use a value less
375* than zero to get the current value.
376*
377* Function return value:
378* int Current value of NDPMAX.
379*
380*
381* dpfill() - Fill the contents of a dpkey struct
382* ----------------------------------------------
383* dpfill() is a utility routine to aid in filling the contents of the dpkey
384* struct. No checks are done on the validity of the inputs.
385*
386* WCS Paper IV specifies the syntax of a record-valued keyword as
387*
388= keyword = '<field-specifier>: <float>'
389*
390* However, some DPja and DQia record values, such as those of DPja.NAXES and
391* DPja.AXIS.j, are intrinsically integer-valued. While FITS header parsers
392* are not expected to know in advance which of DPja and DQia are integral and
393* which are floating point, if the record's value parses as an integer (i.e.
394* without decimal point or exponent), then preferably enter it into the dpkey
395* struct as an integer. Either way, it doesn't matter as disset() accepts
396* either data type for all record values.
397*
398* Given and returned:
399* dp struct dpkey*
400* Store for DPja and DQia keyvalues.
401*
402* Given:
403* keyword const char *
404* field const char *
405* These arguments are concatenated with an intervening
406* "." to construct the full record field name, i.e.
407* including the keyword name, DPja or DQia (but
408* excluding the colon delimiter which is NOT part of the
409* name). Either may be given as a NULL pointer. Set
410* both NULL to omit setting this component of the
411* struct.
412*
413* j int Axis number (1-relative), i.e. the j in DPja or
414* i in DQia. Can be given as 0, in which case the axis
415* number will be obtained from the keyword component of
416* the field name which must either have been given or
417* preset.
418*
419* If j is non-zero, and keyword was given, then the
420* value of j will be used to fill in the axis number.
421*
422* type int Data type of the record's value
423* 0: Integer,
424* 1: Floating point.
425*
426* i int For type == 0, the integer value of the record.
427*
428* f double For type == 1, the floating point value of the record.
429*
430* Function return value:
431* int Status return value:
432* 0: Success.
433*
434*
435* dpkeyi() - Get the data value in a dpkey struct as int
436* ------------------------------------------------------
437* dpkeyi() returns the data value in a dpkey struct as an integer value.
438*
439* Given and returned:
440* dp const struct dpkey *
441* Parsed contents of a DPja or DQia keyrecord.
442*
443* Function return value:
444* int The record's value as int.
445*
446*
447* dpkeyd() - Get the data value in a dpkey struct as double
448* ---------------------------------------------------------
449* dpkeyd() returns the data value in a dpkey struct as a floating point
450* value.
451*
452* Given and returned:
453* dp const struct dpkey *
454* Parsed contents of a DPja or DQia keyrecord.
455*
456* Function return value:
457* double The record's value as double.
458*
459*
460* disini() - Default constructor for the disprm struct
461* ----------------------------------------------------
462* disini() is a thin wrapper on disinit(). It invokes it with ndpmax set
463* to -1 which causes it to use the value of the global variable NDPMAX. It
464* is thereby potentially thread-unsafe if NDPMAX is altered dynamically via
465* disndp(). Use disinit() for a thread-safe alternative in this case.
466*
467*
468* disinit() - Default constructor for the disprm struct
469* ----------------------------------------------------
470* disinit() allocates memory for arrays in a disprm struct and sets all
471* members of the struct to default values.
472*
473* PLEASE NOTE: every disprm struct must be initialized by disinit(), possibly
474* repeatedly. On the first invokation, and only the first invokation,
475* disprm::flag must be set to -1 to initialize memory management, regardless
476* of whether disinit() will actually be used to allocate memory.
477*
478* Given:
479* alloc int If true, allocate memory unconditionally for arrays in
480* the disprm struct.
481*
482* If false, it is assumed that pointers to these arrays
483* have been set by the user except if they are null
484* pointers in which case memory will be allocated for
485* them regardless. (In other words, setting alloc true
486* saves having to initalize these pointers to zero.)
487*
488* naxis int The number of world coordinate axes, used to determine
489* array sizes.
490*
491* Given and returned:
492* dis struct disprm*
493* Distortion function parameters. Note that, in order
494* to initialize memory management disprm::flag must be
495* set to -1 when dis is initialized for the first time
496* (memory leaks may result if it had already been
497* initialized).
498*
499* Given:
500* ndpmax int The number of DPja or DQia keywords to allocate space
501* for. If set to -1, the value of the global variable
502* NDPMAX will be used. This is potentially
503* thread-unsafe if disndp() is being used dynamically to
504* alter its value.
505*
506* Function return value:
507* int Status return value:
508* 0: Success.
509* 1: Null disprm pointer passed.
510* 2: Memory allocation failed.
511*
512* For returns > 1, a detailed error message is set in
513* disprm::err if enabled, see wcserr_enable().
514*
515*
516* discpy() - Copy routine for the disprm struct
517* ---------------------------------------------
518* discpy() does a deep copy of one disprm struct to another, using disinit()
519* to allocate memory unconditionally for its arrays if required. Only the
520* "information to be provided" part of the struct is copied; a call to
521* disset() is required to initialize the remainder.
522*
523* Given:
524* alloc int If true, allocate memory unconditionally for arrays in
525* the destination. Otherwise, it is assumed that
526* pointers to these arrays have been set by the user
527* except if they are null pointers in which case memory
528* will be allocated for them regardless.
529*
530* dissrc const struct disprm*
531* Struct to copy from.
532*
533* Given and returned:
534* disdst struct disprm*
535* Struct to copy to. disprm::flag should be set to -1
536* if disdst was not previously initialized (memory leaks
537* may result if it was previously initialized).
538*
539* Function return value:
540* int Status return value:
541* 0: Success.
542* 1: Null disprm pointer passed.
543* 2: Memory allocation failed.
544*
545* For returns > 1, a detailed error message is set in
546* disprm::err if enabled, see wcserr_enable().
547*
548*
549* disfree() - Destructor for the disprm struct
550* --------------------------------------------
551* disfree() frees memory allocated for the disprm arrays by disinit().
552* disinit() keeps a record of the memory it allocates and disfree() will only
553* attempt to free this.
554*
555* PLEASE NOTE: disfree() must not be invoked on a disprm struct that was not
556* initialized by disinit().
557*
558* Given and returned:
559* dis struct disprm*
560* Distortion function parameters.
561*
562* Function return value:
563* int Status return value:
564* 0: Success.
565* 1: Null disprm pointer passed.
566*
567*
568* dissize() - Compute the size of a disprm struct
569* -----------------------------------------------
570* dissize() computes the full size of a disprm struct, including allocated
571* memory.
572*
573* Given:
574* dis const struct disprm*
575* Distortion function parameters.
576*
577* If NULL, the base size of the struct and the allocated
578* size are both set to zero.
579*
580* Returned:
581* sizes int[2] The first element is the base size of the struct as
582* returned by sizeof(struct disprm). The second element
583* is the total allocated size, in bytes, assuming that
584* the allocation was done by disini(). This figure
585* includes memory allocated for members of constituent
586* structs, such as disprm::dp.
587*
588* It is not an error for the struct not to have been set
589* up via tabset(), which normally results in additional
590* memory allocation.
591*
592* Function return value:
593* int Status return value:
594* 0: Success.
595*
596*
597* disenq() - enquire about the state of a disprm struct
598* -----------------------------------------------------
599* disenq() may be used to obtain information about the state of a disprm
600* struct. The function returns a true/false answer for the enquiry asked.
601*
602* Given:
603* dis const struct disprm*
604* Distortion function parameters.
605*
606* enquiry int Enquiry according to the following parameters:
607* DISENQ_MEM: memory in the struct is being managed by
608* WCSLIB (see disinit()).
609* DISENQ_SET: the struct has been set up by disset().
610* DISENQ_BYP: the struct is in bypass mode (see
611* disset()).
612* These may be combined by logical OR, e.g.
613* DISENQ_MEM | DISENQ_SET. The enquiry result will be
614* the logical AND of the individual results.
615*
616* Function return value:
617* int Enquiry result:
618* 0: No.
619* 1: Yes.
620*
621*
622* disprt() - Print routine for the disprm struct
623* ----------------------------------------------
624* disprt() prints the contents of a disprm struct using wcsprintf(). Mainly
625* intended for diagnostic purposes.
626*
627* Given:
628* dis const struct disprm*
629* Distortion function parameters.
630*
631* Function return value:
632* int Status return value:
633* 0: Success.
634* 1: Null disprm pointer passed.
635*
636*
637* disperr() - Print error messages from a disprm struct
638* -----------------------------------------------------
639* disperr() prints the error message(s) (if any) stored in a disprm struct.
640* If there are no errors then nothing is printed. It uses wcserr_prt(), q.v.
641*
642* Given:
643* dis const struct disprm*
644* Distortion function parameters.
645*
646* prefix const char *
647* If non-NULL, each output line will be prefixed with
648* this string.
649*
650* Function return value:
651* int Status return value:
652* 0: Success.
653* 1: Null disprm pointer passed.
654*
655*
656* dishdo() - write FITS headers using TPD
657* ---------------------------------------
658* dishdo() sets a flag that tells wcshdo() to write FITS headers in the form
659* of the TPD translation used internally. Normally SIP and TPV would be
660* written in their native form if at all possible.
661*
662* Given and returned:
663* dis struct disprm*
664* Distortion function parameters.
665*
666* Function return value:
667* int Status return value:
668* 0: Success.
669* 1: Null disprm pointer passed.
670* 3: No TPD translation.
671*
672*
673* disset() - Setup routine for the disprm struct
674* ----------------------------------------------
675* disset(), sets up the disprm struct according to information supplied within
676* it - refer to the explanation of disprm::flag.
677*
678* Note that this routine need not be called directly; it will be invoked by
679* disp2x() and disx2p() if the disprm::flag is anything other than a
680* predefined magic value.
681*
682* disset() normally operates regardless of the value of disprm::flag; i.e.
683* even if a struct was previously set up it will be reset unconditionally.
684* However, a disprm struct may be put into "bypass" mode by invoking disset()
685* initially with disprm::flag == 1 (rather than 0). disset() will return
686* immediately if invoked on a struct in that state. To take a struct out of
687* bypass mode, simply reset disprm::flag to zero. See also disenq().
688*
689* Given and returned:
690* dis struct disprm*
691* Distortion function parameters.
692*
693* Function return value:
694* int Status return value:
695* 0: Success.
696* 1: Null disprm pointer passed.
697* 2: Memory allocation failed.
698* 3: Invalid parameter.
699*
700* For returns > 1, a detailed error message is set in
701* disprm::err if enabled, see wcserr_enable().
702*
703*
704* disp2x() - Apply distortion function
705* ------------------------------------
706* disp2x() applies the distortion functions. By definition, the distortion
707* is in the pixel-to-world direction.
708*
709* Depending on the point in the algorithm chain at which it is invoked,
710* disp2x() may transform pixel coordinates to corrected pixel coordinates, or
711* intermediate pixel coordinates to corrected intermediate pixel coordinates,
712* or image coordinates to corrected image coordinates.
713*
714*
715* Given and returned:
716* dis struct disprm*
717* Distortion function parameters.
718*
719* Given:
720* rawcrd const double[naxis]
721* Array of coordinates.
722*
723* Returned:
724* discrd double[naxis]
725* Array of coordinates to which the distortion functions
726* have been applied.
727*
728* Function return value:
729* int Status return value:
730* 0: Success.
731* 1: Null disprm pointer passed.
732* 2: Memory allocation failed.
733* 3: Invalid parameter.
734* 4: Distort error.
735*
736* For returns > 1, a detailed error message is set in
737* disprm::err if enabled, see wcserr_enable().
738*
739*
740* disx2p() - Apply de-distortion function
741* ---------------------------------------
742* disx2p() applies the inverse of the distortion functions. By definition,
743* the de-distortion is in the world-to-pixel direction.
744*
745* Depending on the point in the algorithm chain at which it is invoked,
746* disx2p() may transform corrected pixel coordinates to pixel coordinates, or
747* corrected intermediate pixel coordinates to intermediate pixel coordinates,
748* or corrected image coordinates to image coordinates.
749*
750* disx2p() iteratively solves for the inverse using disp2x(). It assumes
751* that the distortion is small and the functions are well-behaved, being
752* continuous and with continuous derivatives. Also that, to first order
753* in the neighbourhood of the solution, discrd[j] ~= a + b*rawcrd[j], i.e.
754* independent of rawcrd[i], where i != j. This is effectively equivalent to
755* assuming that the distortion functions are separable to first order.
756* Furthermore, a is assumed to be small, and b close to unity.
757*
758* If disprm::disx2p() is defined, then disx2p() uses it to provide an initial
759* estimate for its more precise iterative inversion.
760*
761* Given and returned:
762* dis struct disprm*
763* Distortion function parameters.
764*
765* Given:
766* discrd const double[naxis]
767* Array of coordinates.
768*
769* Returned:
770* rawcrd double[naxis]
771* Array of coordinates to which the inverse distortion
772* functions have been applied.
773*
774* Function return value:
775* int Status return value:
776* 0: Success.
777* 1: Null disprm pointer passed.
778* 2: Memory allocation failed.
779* 3: Invalid parameter.
780* 5: De-distort error.
781*
782* For returns > 1, a detailed error message is set in
783* disprm::err if enabled, see wcserr_enable().
784*
785*
786* diswarp() - Compute measures of distortion
787* ------------------------------------------
788* diswarp() computes various measures of the distortion over a specified range
789* of coordinates.
790*
791* For prior distortions, the measures may be interpreted simply as an offset
792* in pixel coordinates. For sequent distortions, the interpretation depends
793* on the nature of the linear transformation matrix (PCi_ja or CDi_ja). If
794* the latter introduces a scaling, then the measures will also be scaled.
795* Note also that the image domain, which is rectangular in pixel coordinates,
796* may be rotated, skewed, and/or stretched in intermediate pixel coordinates,
797* and in general cannot be defined using pixblc[] and pixtrc[].
798*
799* PLEASE NOTE: the measures of total distortion may be essentially meaningless
800* if there are multiple sequent distortions with different scaling.
801*
802* See also linwarp().
803*
804* Given and returned:
805* dis struct disprm*
806* Distortion function parameters.
807*
808* Given:
809* pixblc const double[naxis]
810* Start of the range of pixel coordinates (for prior
811* distortions), or intermediate pixel coordinates (for
812* sequent distortions). May be specified as a NULL
813* pointer which is interpreted as (1,1,...).
814*
815* pixtrc const double[naxis]
816* End of the range of pixel coordinates (prior) or
817* intermediate pixel coordinates (sequent).
818*
819* pixsamp const double[naxis]
820* If positive or zero, the increment on the particular
821* axis, starting at pixblc[]. Zero is interpreted as a
822* unit increment. pixsamp may also be specified as a
823* NULL pointer which is interpreted as all zeroes, i.e.
824* unit increments on all axes.
825*
826* If negative, the grid size on the particular axis (the
827* absolute value being rounded to the nearest integer).
828* For example, if pixsamp is (-128.0,-128.0,...) then
829* each axis will be sampled at 128 points between
830* pixblc[] and pixtrc[] inclusive. Use caution when
831* using this option on non-square images.
832*
833* Returned:
834* nsamp int* The number of pixel coordinates sampled.
835*
836* Can be specified as a NULL pointer if not required.
837*
838* maxdis double[naxis]
839* For each individual distortion function, the
840* maximum absolute value of the distortion.
841*
842* Can be specified as a NULL pointer if not required.
843*
844* maxtot double* For the combination of all distortion functions, the
845* maximum absolute value of the distortion.
846*
847* Can be specified as a NULL pointer if not required.
848*
849* avgdis double[naxis]
850* For each individual distortion function, the
851* mean value of the distortion.
852*
853* Can be specified as a NULL pointer if not required.
854*
855* avgtot double* For the combination of all distortion functions, the
856* mean value of the distortion.
857*
858* Can be specified as a NULL pointer if not required.
859*
860* rmsdis double[naxis]
861* For each individual distortion function, the
862* root mean square deviation of the distortion.
863*
864* Can be specified as a NULL pointer if not required.
865*
866* rmstot double* For the combination of all distortion functions, the
867* root mean square deviation of the distortion.
868*
869* Can be specified as a NULL pointer if not required.
870*
871* Function return value:
872* int Status return value:
873* 0: Success.
874* 1: Null disprm pointer passed.
875* 2: Memory allocation failed.
876* 3: Invalid parameter.
877* 4: Distort error.
878*
879*
880* disprm struct - Distortion parameters
881* -------------------------------------
882* The disprm struct contains all of the information required to apply a set of
883* distortion functions. It consists of certain members that must be set by
884* the user ("given") and others that are set by the WCSLIB routines
885* ("returned"). While the addresses of the arrays themselves may be set by
886* disinit() if it (optionally) allocates memory, their contents must be set by
887* the user.
888*
889* int flag
890* (Given and returned) This flag must be set to zero (or 1, see disset())
891* whenever any of the following disprm members are set or changed:
892*
893* - disprm::naxis,
894* - disprm::dtype,
895* - disprm::ndp,
896* - disprm::dp.
897*
898* This signals the initialization routine, disset(), to recompute the
899* returned members of the disprm struct. disset() will reset flag to
900* indicate that this has been done.
901*
902* PLEASE NOTE: flag must be set to -1 when disinit() is called for the
903* first time for a particular disprm struct in order to initialize memory
904* management. It must ONLY be used on the first initialization otherwise
905* memory leaks may result.
906*
907* int naxis
908* (Given or returned) Number of pixel and world coordinate elements.
909*
910* If disinit() is used to initialize the disprm struct (as would normally
911* be the case) then it will set naxis from the value passed to it as a
912* function argument. The user should not subsequently modify it.
913*
914* char (*dtype)[72]
915* (Given) Pointer to the first element of an array of char[72] containing
916* the name of the distortion function for each axis.
917*
918* int ndp
919* (Given) The number of entries in the disprm::dp[] array.
920*
921* int ndpmax
922* (Given) The length of the disprm::dp[] array.
923*
924* ndpmax will be set by disinit() if it allocates memory for disprm::dp[],
925* otherwise it must be set by the user. See also disndp().
926*
927* struct dpkey dp
928* (Given) Address of the first element of an array of length ndpmax of
929* dpkey structs.
930*
931* As a FITS header parser encounters each DPja or DQia keyword it should
932* load it into a dpkey struct in the array and increment ndp. However,
933* note that a single disprm struct must hold only DPja or DQia keyvalues,
934* not both. disset() interprets them as required by the particular
935* distortion function.
936*
937* double *maxdis
938* (Given) Pointer to the first element of an array of double specifying
939* the maximum absolute value of the distortion for each axis computed over
940* the whole image.
941*
942* It is not necessary to reset the disprm struct (via disset()) when
943* disprm::maxdis is changed.
944*
945* double totdis
946* (Given) The maximum absolute value of the combination of all distortion
947* functions specified as an offset in pixel coordinates computed over the
948* whole image.
949*
950* It is not necessary to reset the disprm struct (via disset()) when
951* disprm::totdis is changed.
952*
953* int *docorr
954* (Returned) Pointer to the first element of an array of int containing
955* flags that indicate the mode of correction for each axis.
956*
957* If docorr is zero, the distortion function returns the corrected
958* coordinates directly. Any other value indicates that the distortion
959* function computes a correction to be added to pixel coordinates (prior
960* distortion) or intermediate pixel coordinates (sequent distortion).
961*
962* int *Nhat
963* (Returned) Pointer to the first element of an array of int containing
964* the number of coordinate axes that form the independent variables of the
965* distortion function for each axis.
966*
967* int **axmap
968* (Returned) Pointer to the first element of an array of int* containing
969* pointers to the first elements of the axis mapping arrays for each axis.
970*
971* An axis mapping associates the independent variables of a distortion
972* function with the 0-relative image axis number. For example, consider
973* an image with a spectrum on the first axis (axis 0), followed by RA
974* (axis 1), Dec (axis2), and time (axis 3) axes. For a distortion in
975* (RA,Dec) and no distortion on the spectral or time axes, the axis
976* mapping arrays, axmap[j][], would be
977*
978= j=0: [-1, -1, -1, -1] ...no distortion on spectral axis,
979= 1: [ 1, 2, -1, -1] ...RA distortion depends on RA and Dec,
980= 2: [ 2, 1, -1, -1] ...Dec distortion depends on Dec and RA,
981= 3: [-1, -1, -1, -1] ...no distortion on time axis,
982*
983* where -1 indicates that there is no corresponding independent
984* variable.
985*
986* double **offset
987* (Returned) Pointer to the first element of an array of double*
988* containing pointers to the first elements of arrays of offsets used to
989* renormalize the independent variables of the distortion function for
990* each axis.
991*
992* The offsets are subtracted from the independent variables before
993* scaling.
994*
995* double **scale
996* (Returned) Pointer to the first element of an array of double*
997* containing pointers to the first elements of arrays of scales used to
998* renormalize the independent variables of the distortion function for
999* each axis.
1000*
1001* The scale is applied to the independent variables after the offsets are
1002* subtracted.
1003*
1004* int **iparm
1005* (Returned) Pointer to the first element of an array of int*
1006* containing pointers to the first elements of the arrays of integer
1007* distortion parameters for each axis.
1008*
1009* double **dparm
1010* (Returned) Pointer to the first element of an array of double*
1011* containing pointers to the first elements of the arrays of floating
1012* point distortion parameters for each axis.
1013*
1014* int i_naxis
1015* (Returned) Dimension of the internal arrays (normally equal to naxis).
1016*
1017* int ndis
1018* (Returned) The number of distortion functions.
1019*
1020* struct wcserr *err
1021* (Returned) If enabled, when an error status is returned, this struct
1022* contains detailed information about the error, see wcserr_enable().
1023*
1024* int (**disp2x)(DISP2X_ARGS)
1025* (For internal use only.)
1026* int (**disx2p)(DISX2P_ARGS)
1027* (For internal use only.)
1028* int m_flag
1029* (For internal use only.)
1030* int m_naxis
1031* (For internal use only.)
1032* char (*m_dtype)[72]
1033* (For internal use only.)
1034* double **m_dp
1035* (For internal use only.)
1036* double *m_maxdis
1037* (For internal use only.)
1038*
1039*
1040* dpkey struct - Store for DPja and DQia keyvalues
1041* ------------------------------------------------
1042* The dpkey struct is used to pass the parsed contents of DPja or DQia
1043* keyrecords to disset() via the disprm struct. A disprm struct must hold
1044* only DPja or DQia keyvalues, not both.
1045*
1046* All members of this struct are to be set by the user.
1047*
1048* char field[72]
1049* (Given) The full field name of the record, including the keyword name.
1050* Note that the colon delimiter separating the field name and the value in
1051* record-valued keyvalues is not part of the field name. For example, in
1052* the following:
1053*
1054= DP3A = 'AXIS.1: 2'
1055*
1056* the full record field name is "DP3A.AXIS.1", and the record's value
1057* is 2.
1058*
1059* int j
1060* (Given) Axis number (1-relative), i.e. the j in DPja or i in DQia.
1061*
1062* int type
1063* (Given) The data type of the record's value
1064* - 0: Integer (stored as an int),
1065* - 1: Floating point (stored as a double).
1066*
1067* union value
1068* (Given) A union comprised of
1069* - dpkey::i,
1070* - dpkey::f,
1071*
1072* the record's value.
1073*
1074*
1075* Global variable: const char *dis_errmsg[] - Status return messages
1076* ------------------------------------------------------------------
1077* Error messages to match the status value returned from each function.
1078*
1079*===========================================================================*/
1080
1081#ifndef WCSLIB_DIS
1082#define WCSLIB_DIS
1083
1084#ifdef __cplusplus
1085extern "C" {
1086#endif
1087
1088 enum disenq_enum {
1089 DISENQ_MEM = 1, // disprm struct memory is managed by WCSLIB.
1090 DISENQ_SET = 2, // disprm struct has been set up.
1091 DISENQ_BYP = 4, // disprm struct is in bypass mode.
1092};
1093
1094extern const char *dis_errmsg[];
1095
1096 enum dis_errmsg_enum {
1097 DISERR_SUCCESS = 0, // Success.
1098 DISERR_NULL_POINTER = 1, // Null disprm pointer passed.
1099 DISERR_MEMORY = 2, // Memory allocation failed.
1100 DISERR_BAD_PARAM = 3, // Invalid parameter value.
1101 DISERR_DISTORT = 4, // Distortion error.
1102 DISERR_DEDISTORT = 5 // De-distortion error.
1103};
1104
1105// For use in declaring distortion function prototypes (= DISX2P_ARGS).
1106#define DISP2X_ARGS int inverse, const int iparm[], const double dparm[], \
1107int ncrd, const double rawcrd[], double *discrd
1108
1109// For use in declaring de-distortion function prototypes (= DISP2X_ARGS).
1110#define DISX2P_ARGS int inverse, const int iparm[], const double dparm[], \
1111int ncrd, const double discrd[], double *rawcrd
1112
1113
1114// Struct used for storing DPja and DQia keyvalues.
1115 struct dpkey {
1116 char field[72]; // Full record field name (no colon).
1117 int j; // Axis number, as in DPja (1-relative).
1118 int type; // Data type of value.
1119 union {
1120 int i; // Integer record value.
1121 double f; // Floating point record value.
1122 } value; // Record value.
1123};
1124
1125// Size of the dpkey struct in int units, used by the Fortran wrappers.
1126#define DPLEN (sizeof(struct dpkey)/sizeof(int))
1127
1128
1129 struct disprm {
1130 // Initialization flag (see the prologue above).
1131 //--------------------------------------------------------------------------
1132 int flag; // Set to zero to force initialization.
1133
1134 // Parameters to be provided (see the prologue above).
1135 //--------------------------------------------------------------------------
1136 int naxis; // The number of pixel coordinate elements,
1137 // given by NAXIS.
1138 char (*dtype)[72]; // For each axis, the distortion type.
1139 int ndp; // Number of DPja or DQia keywords, and the
1140 int ndpmax; // number for which space was allocated.
1141 struct dpkey *dp; // DPja or DQia keyvalues (not both).
1142 double totdis; // The maximum combined distortion.
1143 double *maxdis; // For each axis, the maximum distortion.
1144
1145 // Information derived from the parameters supplied.
1146 //--------------------------------------------------------------------------
1147 int *docorr; // For each axis, the mode of correction.
1148 int *Nhat; // For each axis, the number of coordinate
1149 // axes that form the independent variables
1150 // of the distortion function.
1151 int **axmap; // For each axis, the axis mapping array.
1152 double **offset; // For each axis, renormalization offsets.
1153 double **scale; // For each axis, renormalization scales.
1154 int **iparm; // For each axis, the array of integer
1155 // distortion parameters.
1156 double **dparm; // For each axis, the array of floating
1157 // point distortion parameters.
1158 int i_naxis; // Dimension of the internal arrays.
1159 int ndis; // The number of distortion functions.
1160
1161 // Error messaging, if enabled.
1162 //--------------------------------------------------------------------------
1163 struct wcserr *err;
1164
1165 //--------------------------------------------------------------------------
1166 // Private - the remainder are for internal use.
1167 //--------------------------------------------------------------------------
1168 int (**disp2x)(DISP2X_ARGS); // For each axis, pointers to the
1169 int (**disx2p)(DISX2P_ARGS); // distortion function and its inverse.
1170
1171 int m_flag, m_naxis; // The remainder are for memory management.
1172 char (*m_dtype)[72];
1173 struct dpkey *m_dp;
1174 double *m_maxdis;
1175};
1176
1177// Size of the disprm struct in int units, used by the Fortran wrappers.
1178#define DISLEN (sizeof(struct disprm)/sizeof(int))
1179
1180
1181 int disndp(int n);
1182
1183 int dpfill(struct dpkey *dp, const char *keyword, const char *field, int j,
1184 int type, int i, double f);
1185
1186 int dpkeyi(const struct dpkey *dp);
1187
1188 double dpkeyd(const struct dpkey *dp);
1189
1190 int disini(int alloc, int naxis, struct disprm *dis);
1191
1192 int disinit(int alloc, int naxis, struct disprm *dis, int ndpmax);
1193
1194 int discpy(int alloc, const struct disprm *dissrc, struct disprm *disdst);
1195
1196 int disfree(struct disprm *dis);
1197
1198 int dissize(const struct disprm *dis, int sizes[2]);
1199
1200 int disenq(const struct disprm *dis, int enquiry);
1201
1202 int disprt(const struct disprm *dis);
1203
1204 int disperr(const struct disprm *dis, const char *prefix);
1205
1206 int dishdo(struct disprm *dis);
1207
1208 int disset(struct disprm *dis);
1209
1210 int disp2x(struct disprm *dis, const double rawcrd[], double discrd[]);
1211
1212 int disx2p(struct disprm *dis, const double discrd[], double rawcrd[]);
1213
1214 int diswarp(struct disprm *dis, const double pixblc[], const double pixtrc[],
1215 const double pixsamp[], int *nsamp,
1216 double maxdis[], double *maxtot,
1217 double avgdis[], double *avgtot,
1218 double rmsdis[], double *rmstot);
1219
1220#ifdef __cplusplus
1221}
1222#endif
1223
1224#endif // WCSLIB_DIS
disp2x
int disp2x(struct disprm *dis, const double rawcrd[], double discrd[])
Apply distortion function.
dpkeyd
double dpkeyd(const struct dpkey *dp)
Get the data value in a dpkey struct as double.
DISP2X_ARGS
#define DISP2X_ARGS
Definition dis.h:1106
dis_errmsg_enum
dis_errmsg_enum
Definition dis.h:1096
DISERR_MEMORY
@ DISERR_MEMORY
Definition dis.h:1099
DISERR_NULL_POINTER
@ DISERR_NULL_POINTER
Definition dis.h:1098
DISERR_DEDISTORT
@ DISERR_DEDISTORT
Definition dis.h:1102
DISERR_BAD_PARAM
@ DISERR_BAD_PARAM
Definition dis.h:1100
DISERR_DISTORT
@ DISERR_DISTORT
Definition dis.h:1101
DISERR_SUCCESS
@ DISERR_SUCCESS
Definition dis.h:1097
disinit
int disinit(int alloc, int naxis, struct disprm *dis, int ndpmax)
Default constructor for the disprm struct.
discpy
int discpy(int alloc, const struct disprm *dissrc, struct disprm *disdst)
Copy routine for the disprm struct.
dpfill
int dpfill(struct dpkey *dp, const char *keyword, const char *field, int j, int type, int i, double f)
Fill the contents of a dpkey struct.
disenq_enum
disenq_enum
Definition dis.h:1088
DISENQ_MEM
@ DISENQ_MEM
Definition dis.h:1089
DISENQ_SET
@ DISENQ_SET
Definition dis.h:1090
DISENQ_BYP
@ DISENQ_BYP
Definition dis.h:1091
dpkeyi
int dpkeyi(const struct dpkey *dp)
Get the data value in a dpkey struct as int.
dissize
int dissize(const struct disprm *dis, int sizes[2])
Compute the size of a disprm struct.
disfree
int disfree(struct disprm *dis)
Destructor for the disprm struct.
disini
int disini(int alloc, int naxis, struct disprm *dis)
Default constructor for the disprm struct.
diswarp
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.
disndp
int disndp(int n)
Memory allocation for DPja and DQia.
dishdo
int dishdo(struct disprm *dis)
write FITS headers using TPD.
disx2p
int disx2p(struct disprm *dis, const double discrd[], double rawcrd[])
Apply de-distortion function.
DISX2P_ARGS
#define DISX2P_ARGS
Definition dis.h:1110
disperr
int disperr(const struct disprm *dis, const char *prefix)
Print error messages from a disprm struct.
disset
int disset(struct disprm *dis)
Setup routine for the disprm struct.
disenq
int disenq(const struct disprm *dis, int enquiry)
enquire about the state of a disprm struct.
dis_errmsg
const char * dis_errmsg[]
Status return messages.
disprt
int disprt(const struct disprm *dis)
Print routine for the disprm struct.
disprm
Distortion parameters.
Definition dis.h:1129
disprm::iparm
int ** iparm
Definition dis.h:1154
disprm::totdis
double totdis
Definition dis.h:1142
disprm::m_maxdis
double * m_maxdis
Definition dis.h:1174
disprm::naxis
int naxis
Definition dis.h:1136
disprm::dparm
double ** dparm
Definition dis.h:1156
disprm::offset
double ** offset
Definition dis.h:1152
disprm::m_dtype
char(* m_dtype)[72]
Definition dis.h:1172
disprm::docorr
int * docorr
Definition dis.h:1147
disprm::disp2x
int(** disp2x)(DISP2X_ARGS)
Definition dis.h:1168
disprm::flag
int flag
Definition dis.h:1132
disprm::scale
double ** scale
Definition dis.h:1153
disprm::i_naxis
int i_naxis
Definition dis.h:1158
disprm::axmap
int ** axmap
Definition dis.h:1151
disprm::ndpmax
int ndpmax
Definition dis.h:1140
disprm::m_naxis
int m_naxis
Definition dis.h:1171
disprm::ndis
int ndis
Definition dis.h:1159
disprm::maxdis
double * maxdis
Definition dis.h:1143
disprm::Nhat
int * Nhat
Definition dis.h:1148
disprm::ndp
int ndp
Definition dis.h:1139
disprm::err
struct wcserr * err
Definition dis.h:1163
disprm::m_dp
struct dpkey * m_dp
Definition dis.h:1173
disprm::dp
struct dpkey * dp
Definition dis.h:1141
disprm::disx2p
int(** disx2p)(DISX2P_ARGS)
Definition dis.h:1169
disprm::dtype
char(* dtype)[72]
Definition dis.h:1138
disprm::m_flag
int m_flag
Definition dis.h:1171
dpkey
Store for DPja and DQia keyvalues.
Definition dis.h:1115
dpkey::i
int i
Definition dis.h:1120
dpkey::value
union dpkey::@163151235071365315013241052316307044002104101272 value
dpkey::type
int type
Definition dis.h:1118
dpkey::j
int j
Definition dis.h:1117
dpkey::f
double f
Definition dis.h:1121
dpkey::field
char field[72]
Definition dis.h:1116
wcserr
Error message handling.
Definition wcserr.h:243