|
| int | disndp (int n) |
| | Memory allocation for DPja and DQia. More...
|
| |
| int | dpfill (struct dpkey *dp, const char *keyword, const char *field, int j, int type, int ival, double fval) |
| | Fill the contents of a dpkey struct. More...
|
| |
| int | disini (int alloc, int naxis, struct disprm *dis) |
| | Default constructor for the disprm struct. More...
|
| |
| int | discpy (int alloc, const struct disprm *dissrc, struct disprm *disdst) |
| | Copy routine for the disprm struct. More...
|
| |
| int | disfree (struct disprm *dis) |
| | Destructor for the disprm struct. More...
|
| |
| int | disprt (const struct disprm *dis) |
| | Print routine for the disprm struct. More...
|
| |
| int | disset (struct disprm *dis) |
| | Setup routine for the disprm struct. More...
|
| |
| int | disp2x (struct disprm *dis, const double rawcrd[], double discrd[]) |
| | Apply distortion function. More...
|
| |
| int | disx2p (struct disprm *dis, const double discrd[], double rawcrd[]) |
| | Apply de-distortion function. More...
|
| |
| 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. More...
|
| |
| int | polyset (int j, struct disprm *dis) |
| |
| int | pol2tpd (int j, struct disprm *dis) |
| |
| int | dispoly (DISP2X_ARGS) |
| |
| int | tpdset (int j, struct disprm *dis) |
| |
| int | tpvset (int j, struct disprm *dis) |
| | (Internal use only.) More...
|
| |
| int | sipset (int j, struct disprm *dis) |
| |
| int | tpd1 (DISP2X_ARGS) |
| |
| int | tpd2 (DISP2X_ARGS) |
| |
| int | tpd3 (DISP2X_ARGS) |
| |
| int | tpd4 (DISP2X_ARGS) |
| |
| int | tpd5 (DISP2X_ARGS) |
| |
| int | tpd6 (DISP2X_ARGS) |
| |
| int | tpd7 (DISP2X_ARGS) |
| |
| int | tpd8 (DISP2X_ARGS) |
| |
| int | tpd9 (DISP2X_ARGS) |
| |
These routines apply the distortion functions defined by the extension to the FITS WCS standard proposed in Paper IV. They are based on the disprm struct which contains all information needed for the computations. The struct contains some members that must be set by the user, and others that are maintained by these routines, somewhat like a C++ class but with no encapsulation.
disndp(), dpfill(), disini(), discpy(), and disfree() are provided to manage the disprm struct, and another, disprt(), prints its contents.
A setup routine, disset(), computes intermediate values in the disprm struct from parameters in it that were supplied by the user. The struct always needs to be set up by disset(), though disset() need not be called explicitly - refer to the explanation of disprm::flag.
disp2x() and disx2p() implement the WCS distortion functions, disp2x() using separate functions, such as dispoly() and tpd7(), to do the computation.
An auxiliary routine, diswarp(), computes various measures of the distortion over a specified range of coordinates.
PLEASE NOTE:
wcscompare(), or wcshdo().
| int dpfill |
( |
struct dpkey * |
dp, |
|
|
const char * |
keyword, |
|
|
const char * |
field, |
|
|
int |
j, |
|
|
int |
type, |
|
|
int |
ival, |
|
|
double |
fval |
|
) |
| |
dpfill() is a utility routine to aid in filling the contents of the dpkey struct. No checks are done on the validity of the inputs.
WCS Paper IV specifies the syntax of a record-valued keyword as
1 keyword = '<field-specifier>: <float>'
However, some DPja and DQia record values, such as those of DPja.NAXES and DPja.AXIS.j, are intrinsically integer-valued. While FITS header parsers are not expected to know in advance which of DPja and DQia are integral and which are floating point, if the record's value parses as an integer (i.e. without decimal point or exponent), then preferably enter it into the dpkey struct as an integer. Either way, it doesn't matter as disset() accepts either data type for all record values.
- Parameters
-
| [in,out] | dp | Store for DPja and DQia keyvalues. |
| [in] | keyword | |
| [in] | field | These arguments are concatenated with an intervening "." to construct the full record field name, i.e. including the keyword name, DPja or DQia (but excluding the colon delimiter which is NOT part of the name). Either may be given as a NULL pointer. Set both NULL to omit setting this component of the struct. |
| [in] | j | Axis number (1-relative), i.e. the j in DPja or i in DQia. Can be given as 0, in which case the axis number will be obtained from the keyword component of the field name which must either have been given or preset. |
| [in] | type | Data type of the record's value
- 0: Integer,
- 1: Floating point.
|
| [in] | ival | For type == 0, the integer value of the record. |
| [in] | fval | For type == 1, the floating point value of the record. |
- Returns
- Status return value:
| int disx2p |
( |
struct disprm * |
dis, |
|
|
const double |
discrd[], |
|
|
double |
rawcrd[] |
|
) |
| |
disx2p() applies the inverse of the distortion functions. By definition, the de-distortion is in the world-to-pixel direction.
Depending on the point in the algorithm chain at which it is invoked, disx2p() may transform corrected pixel coordinates to pixel coordinates, or corrected intermediate pixel coordinates to intermediate pixel coordinates, or corrected image coordinates to image coordinates.
disx2p() iteratively solves for the inverse using disp2x(). It assumes that the distortion is small and the functions are well-behaved, being continuous and with continuous derivatives. Also that, to first order in the neighbourhood of the solution, discrd[j] ~= a + b*rawcrd[j], i.e. independent of rawcrd[i], where i != j. This is effectively equivalent to assuming that the distortion functions are separable to first order. Furthermore, a is assumed to be small, and b close to unity.
- Parameters
-
| [in,out] | dis | Distortion function parameters. |
| [in] | discrd | Array of coordinates. |
| [out] | rawcrd | Array of coordinates to which the inverse distortion functions have been applied. |
- Returns
- Status return value:
- 0: Success.
- 1: Null disprm pointer passed.
- 2: Memory allocation failed.
- 3: Invalid parameter.
- 5: De-distort error.
For returns > 1, a detailed error message is set in disprm::err if enabled, see wcserr_enable().
| 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 |
|
) |
| |
diswarp() computes various measures of the distortion over a specified range of coordinates.
For prior distortions, the measures may be interpreted simply as an offset in pixel coordinates. For sequent distortions, the interpretation depends on the nature of the linear transformation matrix (PCi_ja or CDi_ja). If the latter introduces a scaling, then the measures will also be scaled. Note also that the image domain, which is rectangular in pixel coordinates, may be rotated, skewed, and/or stretched in intermediate pixel coordinates, and in general cannot be defined using pixblc[] and pixtrc[].
PLEASE NOTE: the measures of total distortion may be essentially meaningless if there are multiple sequent distortions with different scaling.
See also linwarp().
- Parameters
-
| [in,out] | dis | Distortion function parameters. |
| [in] | pixblc | Start of the range of pixel coordinates (for prior distortions), or intermediate pixel coordinates (for sequent distortions). May be specified as a NULL pointer which is interpreted as (1,1,...). |
| [in] | pixtrc | End of the range of pixel coordinates (prior) or intermediate pixel coordinates (sequent). |
| [in] | pixsamp | If positive or zero, the increment on the particular axis, starting at pixblc[]. Zero is interpreted as a unit increment. pixsamp may also be specified as a NULL pointer which is interpreted as all zeroes, i.e. unit increments on all axes.
If negative, the grid size on the particular axis (the absolute value being rounded to the nearest integer). For example, if pixsamp is (-128.0,-128.0,...) then each axis will be sampled at 128 points between pixblc[] and pixtrc[] inclusive. Use caution when using this option on non-square images. |
| [out] | nsamp | The number of pixel coordinates sampled.
Can be specified as a NULL pointer if not required. |
| [out] | maxdis | For each individual distortion function, the maximum absolute value of the distortion.
Can be specified as a NULL pointer if not required. |
| [out] | maxtot | For the combination of all distortion functions, the maximum absolute value of the distortion.
Can be specified as a NULL pointer if not required. |
| [out] | avgdis | For each individual distortion function, the mean value of the distortion.
Can be specified as a NULL pointer if not required. |
| [out] | avgtot | For the combination of all distortion functions, the mean value of the distortion.
Can be specified as a NULL pointer if not required. |
| [out] | rmsdis | For each individual distortion function, the root mean square deviation of the distortion.
Can be specified as a NULL pointer if not required. |
| [out] | rmstot | For the combination of all distortion functions, the root mean square deviation of the distortion.
Can be specified as a NULL pointer if not required. |
- Returns
- Status return value:
- 0: Success.
- 1: Null disprm pointer passed.
- 2: Memory allocation failed.
- 3: Invalid parameter.
- 4: Distort error.