WCSLIB: dis.h Source File

WCSLIB 8.7

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