WCSLIB 8.4
|
Go to the source code of this file.
Data Structures | |
struct | pvcard |
Store for PVi_ma keyrecords. More... | |
struct | pscard |
Store for PSi_ma keyrecords. More... | |
struct | auxprm |
Additional auxiliary parameters. More... | |
struct | wcsprm |
Coordinate transformation parameters. More... | |
Macros | |
#define | WCSSUB_LONGITUDE 0x1001 |
Mask for extraction of longitude axis by wcssub(). | |
#define | WCSSUB_LATITUDE 0x1002 |
Mask for extraction of latitude axis by wcssub(). | |
#define | WCSSUB_CUBEFACE 0x1004 |
Mask for extraction of CUBEFACE axis by wcssub(). | |
#define | WCSSUB_CELESTIAL 0x1007 |
Mask for extraction of celestial axes by wcssub(). | |
#define | WCSSUB_SPECTRAL 0x1008 |
Mask for extraction of spectral axis by wcssub(). | |
#define | WCSSUB_STOKES 0x1010 |
Mask for extraction of STOKES axis by wcssub(). | |
#define | WCSSUB_TIME 0x1020 |
#define | WCSCOMPARE_ANCILLARY 0x0001 |
#define | WCSCOMPARE_TILING 0x0002 |
#define | WCSCOMPARE_CRPIX 0x0004 |
#define | PVLEN (sizeof(struct pvcard)/sizeof(int)) |
#define | PSLEN (sizeof(struct pscard)/sizeof(int)) |
#define | AUXLEN (sizeof(struct auxprm)/sizeof(int)) |
#define | WCSLEN (sizeof(struct wcsprm)/sizeof(int)) |
Size of the wcsprm struct in int units. | |
#define | wcscopy(alloc, wcssrc, wcsdst) |
Copy routine for the wcsprm struct. | |
#define | wcsini_errmsg wcs_errmsg |
Deprecated. | |
#define | wcssub_errmsg wcs_errmsg |
Deprecated. | |
#define | wcscopy_errmsg wcs_errmsg |
Deprecated. | |
#define | wcsfree_errmsg wcs_errmsg |
Deprecated. | |
#define | wcsprt_errmsg wcs_errmsg |
Deprecated. | |
#define | wcsset_errmsg wcs_errmsg |
Deprecated. | |
#define | wcsp2s_errmsg wcs_errmsg |
Deprecated. | |
#define | wcss2p_errmsg wcs_errmsg |
Deprecated. | |
#define | wcsmix_errmsg wcs_errmsg |
Deprecated. | |
Enumerations | |
enum | wcsenq_enum { WCSENQ_MEM = 1 , WCSENQ_SET = 2 , WCSENQ_BYP = 4 , WCSENQ_CHK = 8 } |
enum | wcs_errmsg_enum { WCSERR_SUCCESS = 0 , WCSERR_NULL_POINTER = 1 , WCSERR_MEMORY = 2 , WCSERR_SINGULAR_MTX = 3 , WCSERR_BAD_CTYPE = 4 , WCSERR_BAD_PARAM = 5 , WCSERR_BAD_COORD_TRANS = 6 , WCSERR_ILL_COORD_TRANS = 7 , WCSERR_BAD_PIX = 8 , WCSERR_BAD_WORLD = 9 , WCSERR_BAD_WORLD_COORD = 10 , WCSERR_NO_SOLUTION = 11 , WCSERR_BAD_SUBIMAGE = 12 , WCSERR_NON_SEPARABLE = 13 , WCSERR_UNSET = 14 } |
Functions | |
int | wcsnpv (int n) |
Memory allocation for PVi_ma . | |
int | wcsnps (int n) |
Memory allocation for PSi_ma . | |
int | wcsini (int alloc, int naxis, struct wcsprm *wcs) |
Default constructor for the wcsprm struct. | |
int | wcsinit (int alloc, int naxis, struct wcsprm *wcs, int npvmax, int npsmax, int ndpmax) |
Default constructor for the wcsprm struct. | |
int | wcsauxi (int alloc, struct wcsprm *wcs) |
Default constructor for the auxprm struct. | |
int | wcssub (int alloc, const struct wcsprm *wcssrc, int *nsub, int axes[], struct wcsprm *wcsdst) |
Subimage extraction routine for the wcsprm struct. | |
int | wcscompare (int cmp, double tol, const struct wcsprm *wcs1, const struct wcsprm *wcs2, int *equal) |
Compare two wcsprm structs for equality. | |
int | wcsfree (struct wcsprm *wcs) |
Destructor for the wcsprm struct. | |
int | wcstrim (struct wcsprm *wcs) |
Free unused arrays in the wcsprm struct. | |
int | wcssize (const struct wcsprm *wcs, int sizes[2]) |
Compute the size of a wcsprm struct. | |
int | auxsize (const struct auxprm *aux, int sizes[2]) |
Compute the size of a auxprm struct. | |
int | wcsenq (const struct wcsprm *wcs, int enquiry) |
enquire about the state of a wcsprm struct. | |
int | wcsprt (const struct wcsprm *wcs) |
Print routine for the wcsprm struct. | |
int | wcsperr (const struct wcsprm *wcs, const char *prefix) |
Print error messages from a wcsprm struct. | |
int | wcsbchk (struct wcsprm *wcs, int bounds) |
Enable/disable bounds checking. | |
int | wcsset (struct wcsprm *wcs) |
Setup routine for the wcsprm struct. | |
int | wcsp2s (struct wcsprm *wcs, int ncoord, int nelem, const double pixcrd[], double imgcrd[], double phi[], double theta[], double world[], int stat[]) |
Pixel-to-world transformation. | |
int | wcss2p (struct wcsprm *wcs, int ncoord, int nelem, const double world[], double phi[], double theta[], double imgcrd[], double pixcrd[], int stat[]) |
World-to-pixel transformation. | |
int | wcsmix (struct wcsprm *wcs, int mixpix, int mixcel, const double vspan[2], double vstep, int viter, double world[], double phi[], double theta[], double imgcrd[], double pixcrd[]) |
Hybrid coordinate transformation. | |
int | wcsccs (struct wcsprm *wcs, double lng2p1, double lat2p1, double lng1p2, const char *clng, const char *clat, const char *radesys, double equinox, const char *alt) |
Change celestial coordinate system. | |
int | wcssptr (struct wcsprm *wcs, int *i, char ctype[9]) |
Spectral axis translation. | |
const char * | wcslib_version (int vers[3]) |
Variables | |
const char * | wcs_errmsg [] |
Status return messages. | |
Routines in this suite implement the FITS World Coordinate System (WCS) standard which defines methods to be used for computing world coordinates from image pixel coordinates, and vice versa. The standard, and proposed extensions for handling distortions, are described in
These routines are based on the wcsprm 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.
wcsnpv(), wcsnps(), wcsini(), wcsinit(), wcssub(), wcsfree(), and wcstrim(), are provided to manage the wcsprm struct, wcssize() computes its total size including allocated memory, wcsenq() returns information about the state of the struct, and wcsprt() prints its contents. wcscopy(), which does a deep copy of one wcsprm struct to another, is defined as a preprocessor macro function that invokes wcssub().
wcsperr() prints the error message(s) (if any) stored in a wcsprm struct, and the linprm, celprm, prjprm, spcprm, and tabprm structs that it contains.
A setup routine, wcsset(), computes intermediate values in the wcsprm struct from parameters in it that were supplied by the user. The struct always needs to be set up by wcsset() but this need not be called explicitly - refer to the explanation of wcsprm::flag.
wcsp2s() and wcss2p() implement the WCS world coordinate transformations. In fact, they are high level driver routines for the WCS linear, logarithmic, celestial, spectral and tabular transformation routines described in lin.h, log.h, cel.h, spc.h and tab.h.
Given either the celestial longitude or latitude plus an element of the pixel coordinate a hybrid routine, wcsmix(), iteratively solves for the unknown elements.
wcsccs() changes the celestial coordinate system of a wcsprm struct, for example, from equatorial to galactic, and wcssptr() translates the spectral axis. For example, a 'FREQ
' axis may be translated into 'ZOPT-F2W'
and vice versa.
wcslib_version() returns the WCSLIB version number.
Quadcube projections:
The quadcube projections (TSC
, CSC
, QSC
) may be represented in FITS in either of two ways:
a: The six faces may be laid out in one plane and numbered as follows:
Faces 2, 3 and 4 may appear on one side or the other (or both). The world-to-pixel routines map faces 2, 3 and 4 to the left but the pixel-to-world routines accept them on either side.
b: The "COBE" convention in which the six faces are stored in a three-dimensional structure using a CUBEFACE
axis indexed from 0 to 5 as above.
These routines support both methods; wcsset() determines which is being used by the presence or absence of a CUBEFACE
axis in ctype[]. wcsp2s() and wcss2p() translate the CUBEFACE
axis representation to the single plane representation understood by the lower-level WCSLIB projection routines.
#define WCSSUB_LONGITUDE 0x1001 |
#define WCSSUB_LATITUDE 0x1002 |
#define WCSSUB_CUBEFACE 0x1004 |
#define WCSSUB_CELESTIAL 0x1007 |
#define WCSSUB_SPECTRAL 0x1008 |
#define WCSSUB_STOKES 0x1010 |
#define WCSSUB_TIME 0x1020 |
#define WCSCOMPARE_ANCILLARY 0x0001 |
#define WCSCOMPARE_TILING 0x0002 |
#define WCSCOMPARE_CRPIX 0x0004 |
#define PVLEN (sizeof(struct pvcard)/sizeof(int)) |
#define PSLEN (sizeof(struct pscard)/sizeof(int)) |
#define AUXLEN (sizeof(struct auxprm)/sizeof(int)) |
#define WCSLEN (sizeof(struct wcsprm)/sizeof(int)) |
Size of the wcsprm struct in int units.
Size of the wcsprm struct in int units, used by the Fortran wrappers.
#define wcscopy | ( | alloc, | |
wcssrc, | |||
wcsdst ) |
Copy routine for the wcsprm struct.
wcscopy() does a deep copy of one wcsprm struct to another. As of WCSLIB 3.6, it is implemented as a preprocessor macro that invokes wcssub() with the nsub and axes pointers both set to zero.
#define wcsini_errmsg wcs_errmsg |
Deprecated.
#define wcssub_errmsg wcs_errmsg |
Deprecated.
#define wcscopy_errmsg wcs_errmsg |
Deprecated.
#define wcsfree_errmsg wcs_errmsg |
Deprecated.
#define wcsprt_errmsg wcs_errmsg |
Deprecated.
#define wcsset_errmsg wcs_errmsg |
Deprecated.
#define wcsp2s_errmsg wcs_errmsg |
Deprecated.
#define wcss2p_errmsg wcs_errmsg |
Deprecated.
#define wcsmix_errmsg wcs_errmsg |
Deprecated.
enum wcsenq_enum |
enum wcs_errmsg_enum |
int wcsnpv | ( | int | n | ) |
Memory allocation for PVi_ma
.
wcsnpv() sets or gets the value of NPVMAX (default 64). This global variable controls the number of pvcard structs, for holding PVi_ma
keyvalues, that wcsini() should allocate space for. It is also used by wcsinit() as the default value of npvmax.
PLEASE NOTE: This function is not thread-safe.
[in] | n | Value of NPVMAX; ignored if < 0. Use a value less than zero to get the current value. |
int wcsnps | ( | int | n | ) |
Memory allocation for PSi_ma
.
wcsnps() sets or gets the value of NPSMAX (default 8). This global variable controls the number of pscard structs, for holding PSi_ma
keyvalues, that wcsini() should allocate space for. It is also used by wcsinit() as the default value of npsmax.
PLEASE NOTE: This function is not thread-safe.
[in] | n | Value of NPSMAX; ignored if < 0. Use a value less than zero to get the current value. |
int wcsini | ( | int | alloc, |
int | naxis, | ||
struct wcsprm * | wcs ) |
Default constructor for the wcsprm struct.
wcsini() is a thin wrapper on wcsinit(). It invokes it with npvmax, npsmax, and ndpmax set to -1 which causes it to use the values of the global variables NDPMAX, NPSMAX, and NDPMAX. It is thereby potentially thread-unsafe if these variables are altered dynamically via wcsnpv(), wcsnps(), and disndp(). Use wcsinit() for a thread-safe alternative in this case.
int wcsinit | ( | int | alloc, |
int | naxis, | ||
struct wcsprm * | wcs, | ||
int | npvmax, | ||
int | npsmax, | ||
int | ndpmax ) |
Default constructor for the wcsprm struct.
wcsinit() optionally allocates memory for arrays in a wcsprm struct and sets all members of the struct to default values.
PLEASE NOTE: every wcsprm struct should be initialized by wcsinit(), possibly repeatedly. On the first invokation, and only the first invokation, wcsprm::flag must be set to -1 to initialize memory management, regardless of whether wcsinit() will actually be used to allocate memory.
[in] | alloc | If true, allocate memory unconditionally for the crpix, etc. arrays. Please note that memory is never allocated by wcsinit() for the auxprm, tabprm, nor wtbarr structs. If false, it is assumed that pointers to these arrays have been set by the user except if they are null pointers in which case memory will be allocated for them regardless. (In other words, setting alloc true saves having to initalize these pointers to zero.) |
[in] | naxis | The number of world coordinate axes. This is used to determine the length of the various wcsprm vectors and matrices and therefore the amount of memory to allocate for them. |
[in,out] | wcs | Coordinate transformation parameters. Note that, in order to initialize memory management, wcsprm::flag should be set to -1 when wcs is initialized for the first time (memory leaks may result if it had already been initialized). |
[in] | npvmax | The number of PVi_ma keywords to allocate space for. If set to -1, the value of the global variable NPVMAX will be used. This is potentially thread-unsafe if wcsnpv() is being used dynamically to alter its value. |
[in] | npsmax | The number of PSi_ma keywords to allocate space for. If set to -1, the value of the global variable NPSMAX will be used. This is potentially thread-unsafe if wcsnps() is being used dynamically to alter its value. |
[in] | ndpmax | The number of DPja or DQia keywords to allocate space for. If set to -1, the value of the global variable NDPMAX will be used. This is potentially thread-unsafe if disndp() is being used dynamically to alter its value. |
int wcsauxi | ( | int | alloc, |
struct wcsprm * | wcs ) |
Default constructor for the auxprm struct.
wcsauxi() optionally allocates memory for an auxprm struct, attaches it to wcsprm, and sets all members of the struct to default values.
[in] | alloc | If true, allocate memory unconditionally for the auxprm struct. If false, it is assumed that wcsprm::aux has already been set to point to an auxprm struct, in which case the user is responsible for managing that memory. However, if wcsprm::aux is a null pointer, memory will be allocated regardless. (In other words, setting alloc true saves having to initalize the pointer to zero.) |
[in,out] | wcs | Coordinate transformation parameters. |
int wcssub | ( | int | alloc, |
const struct wcsprm * | wcssrc, | ||
int * | nsub, | ||
int | axes[], | ||
struct wcsprm * | wcsdst ) |
Subimage extraction routine for the wcsprm struct.
wcssub() extracts the coordinate description for a subimage from a wcsprm struct. It does a deep copy, using wcsinit() to allocate memory for its arrays if required. Only the "information to be provided" part of the struct is extracted. Consequently, wcsset() need not have been, and won't be invoked on the struct from which the subimage is extracted. A call to wcsset() is required to set up the subimage struct.
The world coordinate system of the subimage must be separable in the sense that the world coordinates at any point in the subimage must depend only on the pixel coordinates of the axes extracted. In practice, this means that the linear transformation matrix of the original image must not contain non-zero off-diagonal terms that associate any of the subimage axes with any of the non-subimage axes. Likewise, if any distortions are associated with the subimage axes, they must not depend on any of the axes that are not being extracted.
Note that while the required elements of the tabprm array are extracted, the wtbarr array is not. (Thus it is not appropriate to call wcssub() after wcstab() but before filling the tabprm structs - refer to wcshdr.h.)
wcssub() can also add axes to a wcsprm struct. The new axes will be created using the defaults set by wcsinit() which produce a simple, unnamed, linear axis with world coordinate equal to the pixel coordinate. These default values can be changed afterwards, before invoking wcsset().
[in] | alloc | If true, allocate memory for the crpix, etc. arrays in the destination. Otherwise, it is assumed that pointers to these arrays have been set by the user except if they are null pointers in which case memory will be allocated for them regardless. |
[in] | wcssrc | Struct to extract from. |
[in,out] | nsub | |
[in,out] | axes | Vector of length *nsub containing the image axis numbers (1-relative) to extract. Order is significant; axes[0] is the axis number of the input image that corresponds to the first axis in the subimage, etc. Use an axis number of 0 to create a new axis using the defaults set by wcsinit(). They can be changed later. nsub (the pointer) may be set to zero, and so also may *nsub, which is interpreted to mean all axes in the input image; the number of axes will be returned if nsub != 0x0. axes itself (the pointer) may be set to zero to indicate the first *nsub axes in their original order. Set both nsub (or *nsub) and axes to zero to do a deep copy of one wcsprm struct to another. Subimage extraction by coordinate axis type may be done by setting the elements of axes[] to the following special preprocessor macro values:
On return, *nsub will be set to the number of axes in the subimage; this may be zero if there were no axes of the required type(s) (in which case no memory will be allocated). axes[] will contain the axis numbers that were extracted, or 0 for newly created axes. The vector length must be sufficient to contain all axis numbers. No checks are performed to verify that the coordinate axes are consistent, this is done by wcsset(). |
[in,out] | wcsdst | Struct describing the subimage. wcsprm::flag should be set to -1 if wcsdst was not previously initialized (memory leaks may result if it was previously initialized). |
Notes:
Combinations of subimage axes of particular types may be extracted in the same order as they occur in the input image by combining preprocessor codes, for example
would extract the longitude, latitude, and spectral axes in the same order as the input image. If one of each were present, *nsub = 3 would be returned.
For convenience, WCSSUB_CELESTIAL is defined as the combination WCSSUB_LONGITUDE | WCSSUB_LATITUDE | WCSSUB_CUBEFACE.
The codes may also be negated to extract all but the types specified, for example
The last of these specifies all axis types other than spectral or Stokes. Extraction is done in the order specified by axes[] a longitude axis (if present) would be extracted first (via axes[0]) and not subsequently (via axes[3]). Likewise for the latitude and cubeface axes in this example.
From the foregoing, it is apparent that the value of *nsub returned may be less than or greater than that given. However, it will never exceed the number of axes in the input image (plus the number of newly-created axes if any were specified on input).
int wcscompare | ( | int | cmp, |
double | tol, | ||
const struct wcsprm * | wcs1, | ||
const struct wcsprm * | wcs2, | ||
int * | equal ) |
Compare two wcsprm structs for equality.
wcscompare() compares two wcsprm structs for equality.
[in] | cmp | A bit field controlling the strictness of the comparison. When 0, all fields must be identical. The following constants may be or'ed together to relax the comparison:
|
[in] | tol | Tolerance for comparison of floating-point values. For example, for tol == 1e-6, all floating-point values in the structs must be equal to the first 6 decimal places. A value of 0 implies exact equality. |
[in] | wcs1 | The first wcsprm struct to compare. |
[in] | wcs2 | The second wcsprm struct to compare. |
[out] | equal | Non-zero when the given structs are equal. |
int wcsfree | ( | struct wcsprm * | wcs | ) |
Destructor for the wcsprm struct.
wcsfree() frees memory allocated for the wcsprm arrays by wcsinit() and/or wcsset(). wcsinit() records the memory it allocates and wcsfree() will only attempt to free this.
PLEASE NOTE: wcsfree() must not be invoked on a wcsprm struct that was not initialized by wcsinit().
[in,out] | wcs | Coordinate transformation parameters. |
int wcstrim | ( | struct wcsprm * | wcs | ) |
Free unused arrays in the wcsprm struct.
wcstrim() frees memory allocated by wcsinit() for arrays in the wcsprm struct that remains unused after it has been set up by wcsset().
The free'd array members are associated with FITS WCS keyrecords that are rarely used and usually just bloat the struct: wcsprm::crota, wcsprm::colax, wcsprm::cname, wcsprm::crder, wcsprm::csyer, wcsprm::czphs, and wcsprm::cperi. If unused, wcsprm::pv, wcsprm::ps, and wcsprm::cd are also freed.
Once these arrays have been freed, a test such as
must be protected as follows
In addition, if wcsprm::npv is non-zero but less than wcsprm::npvmax, then the unused space in wcsprm::pv will be recovered (using realloc()). Likewise for wcsprm::ps.
[in,out] | wcs | Coordinate transformation parameters. |
int wcssize | ( | const struct wcsprm * | wcs, |
int | sizes[2] ) |
Compute the size of a wcsprm struct.
wcssize() computes the full size of a wcsprm struct, including allocated memory.
[in] | wcs | Coordinate transformation parameters. If NULL, the base size of the struct and the allocated size are both set to zero. |
[out] | sizes | The first element is the base size of the struct as returned by sizeof(struct wcsprm). The second element is the total allocated size, in bytes, assuming that the allocation was done by wcsini(). This figure includes memory allocated for members of constituent structs, such as wcsprm::lin. It is not an error for the struct not to have been set up via wcsset(), which normally results in additional memory allocation. |
int auxsize | ( | const struct auxprm * | aux, |
int | sizes[2] ) |
Compute the size of a auxprm struct.
auxsize() computes the full size of an auxprm struct, including allocated memory.
[in] | aux | Auxiliary coordinate information. If NULL, the base size of the struct and the allocated size are both set to zero. |
[out] | sizes | The first element is the base size of the struct as returned by sizeof(struct auxprm). The second element is the total allocated size, in bytes, currently zero. |
int wcsenq | ( | const struct wcsprm * | wcs, |
int | enquiry ) |
enquire about the state of a wcsprm struct.
wcsenq() may be used to obtain information about the state of a wcsprm struct. The function returns a true/false answer for the enquiry asked.
[in] | wcs | Coordinate transformation parameters. |
[in] | enquiry | Enquiry according to the following parameters:
|
int wcsprt | ( | const struct wcsprm * | wcs | ) |
Print routine for the wcsprm struct.
wcsprt() prints the contents of a wcsprm struct using wcsprintf(). Mainly intended for diagnostic purposes.
[in] | wcs | Coordinate transformation parameters. |
int wcsperr | ( | const struct wcsprm * | wcs, |
const char * | prefix ) |
Print error messages from a wcsprm struct.
wcsperr() prints the error message(s), if any, stored in a wcsprm struct, and the linprm, celprm, prjprm, spcprm, and tabprm structs that it contains. If there are no errors then nothing is printed. It uses wcserr_prt(), q.v.
[in] | wcs | Coordinate transformation parameters. |
[in] | prefix | If non-NULL, each output line will be prefixed with this string. |
int wcsbchk | ( | struct wcsprm * | wcs, |
int | bounds ) |
Enable/disable bounds checking.
wcsbchk() is used to control bounds checking in the projection routines. Note that wcsset() always enables bounds checking. wcsbchk() will invoke wcsset() on the wcsprm struct beforehand if necessary.
[in,out] | wcs | Coordinate transformation parameters. |
[in] | bounds | If bounds&1 then enable strict bounds checking for the spherical-to-Cartesian (s2x) transformation for the AZP, SZP, TAN, SIN , ZPN, and COP projections. If bounds&2 then enable strict bounds checking for the Cartesian-to-spherical (x2s) transformation for the HPX and XPH projections. If bounds&4 then enable bounds checking on the native coordinates returned by the Cartesian-to-spherical (x2s) transformations using prjchk(). Zero it to disable all checking. |
int wcsset | ( | struct wcsprm * | wcs | ) |
Setup routine for the wcsprm struct.
wcsset() sets up a wcsprm struct according to information supplied within it (refer to the description of the wcsprm struct).
wcsset() recognizes the NCP
projection and converts it to the equivalent SIN
projection and likewise translates GLS
into SFL
. It also translates the AIPS spectral types ('FREQ-LSR'
, 'FELO-HEL'
, etc.), possibly changing the input header keywords wcsprm::ctype and/or wcsprm::specsys if necessary.
Note that this routine need not be called directly; it will be invoked by wcsp2s() and wcss2p() if the wcsprm::flag is anything other than a predefined magic value.
wcsset() normally operates regardless of the value of wcsprm::flag; i.e. even if a struct was previously set up it will be reset unconditionally. However, a wcsprm struct may be put into "bypass" mode by invoking wcsset() initially with wcsprm::flag == 1 (rather than 0). wcsset() will return immediately if invoked on a struct in that state. To take a struct out of bypass mode, simply reset wcsprm::flag to zero. See also wcsenq().
[in,out] | wcs | Coordinate transformation parameters. |
Notes:
int wcsp2s | ( | struct wcsprm * | wcs, |
int | ncoord, | ||
int | nelem, | ||
const double | pixcrd[], | ||
double | imgcrd[], | ||
double | phi[], | ||
double | theta[], | ||
double | world[], | ||
int | stat[] ) |
Pixel-to-world transformation.
wcsp2s() transforms pixel coordinates to world coordinates.
[in,out] | wcs | Coordinate transformation parameters. |
[in] | ncoord,nelem | The number of coordinates, each of vector length nelem but containing wcs.naxis coordinate elements. Thus nelem must equal or exceed the value of the NAXIS keyword unless ncoord == 1, in which case nelem is not used. |
[in] | pixcrd | Array of pixel coordinates. |
[out] | imgcrd | Array of intermediate world coordinates. For celestial axes, imgcrd[][wcs.lng] and imgcrd[][wcs.lat] are the projected ![]() ![]() |
[out] | phi,theta | Longitude and latitude in the native coordinate system of the projection [deg]. |
[out] | world | Array of world coordinates. For celestial axes, world[][wcs.lng] and world[][wcs.lat] are the celestial longitude and latitude [deg]. For spectral axes, world[][wcs.spec] is the spectral coordinate, in SI units. For time axes, world[][wcs.time] is the time coordinate. |
[out] | stat | Status return value for each coordinate:
|
int wcss2p | ( | struct wcsprm * | wcs, |
int | ncoord, | ||
int | nelem, | ||
const double | world[], | ||
double | phi[], | ||
double | theta[], | ||
double | imgcrd[], | ||
double | pixcrd[], | ||
int | stat[] ) |
World-to-pixel transformation.
wcss2p() transforms world coordinates to pixel coordinates.
[in,out] | wcs | Coordinate transformation parameters. |
[in] | ncoord,nelem | The number of coordinates, each of vector length nelem but containing wcs.naxis coordinate elements. Thus nelem must equal or exceed the value of the NAXIS keyword unless ncoord == 1, in which case nelem is not used. |
[in] | world | Array of world coordinates. For celestial axes, world[][wcs.lng] and world[][wcs.lat] are the celestial longitude and latitude [deg]. For spectral axes, world[][wcs.spec] is the spectral coordinate, in SI units. For time axes, world[][wcs.time] is the time coordinate. |
[out] | phi,theta | Longitude and latitude in the native coordinate system of the projection [deg]. |
[out] | imgcrd | Array of intermediate world coordinates. For celestial axes, imgcrd[][wcs.lng] and imgcrd[][wcs.lat] are the projected ![]() ![]() CUBEFACE axis the face number is also returned in imgcrd[][wcs.cubeface]. For spectral axes, imgcrd[][wcs.spec] is the intermediate spectral coordinate, in SI units. For time axes, imgcrd[][wcs.time] is the intermediate time coordinate. |
[out] | pixcrd | Array of pixel coordinates. |
[out] | stat | Status return value for each coordinate:
|
int wcsmix | ( | struct wcsprm * | wcs, |
int | mixpix, | ||
int | mixcel, | ||
const double | vspan[2], | ||
double | vstep, | ||
int | viter, | ||
double | world[], | ||
double | phi[], | ||
double | theta[], | ||
double | imgcrd[], | ||
double | pixcrd[] ) |
Hybrid coordinate transformation.
wcsmix(), given either the celestial longitude or latitude plus an element of the pixel coordinate, solves for the remaining elements by iterating on the unknown celestial coordinate element using wcss2p(). Refer also to the notes below.
[in,out] | wcs | Indices for the celestial coordinates obtained by parsing the wcsprm::ctype[]. |
[in] | mixpix | Which element of the pixel coordinate is given. |
[in] | mixcel | Which element of the celestial coordinate is given:
|
[in] | vspan | Solution interval for the celestial coordinate [deg]. The ordering of the two limits is irrelevant. Longitude ranges may be specified with any convenient normalization, for example [-120,+120] is the same as [240,480], except that the solution will be returned with the same normalization, i.e. lie within the interval specified. |
[in] | vstep | Step size for solution search [deg]. If zero, a sensible, although perhaps non-optimal default will be used. |
[in] | viter | If a solution is not found then the step size will be halved and the search recommenced. viter controls how many times the step size is halved. The allowed range is 5 - 10. |
[in,out] | world | World coordinate elements. world[wcs.lng] and world[wcs.lat] are the celestial longitude and latitude [deg]. Which is given and which returned depends on the value of mixcel. All other elements are given. |
[out] | phi,theta | Longitude and latitude in the native coordinate system of the projection [deg]. |
[out] | imgcrd | Image coordinate elements. imgcrd[wcs.lng] and imgcrd[wcs.lat] are the projected ![]() ![]() |
[in,out] | pixcrd | Pixel coordinate. The element indicated by mixpix is given and the remaining elements are returned. |
Notes:
Initially the specified solution interval is checked to see if it's a "crossing" interval. If it isn't, a search is made for a crossing solution by iterating on the unknown celestial coordinate starting at the upper limit of the solution interval and decrementing by the specified step size. A crossing is indicated if the trial value of the pixel coordinate steps through the value specified. If a crossing interval is found then the solution is determined by a modified form of "regula falsi" division of the crossing interval. If no crossing interval was found within the specified solution interval then a search is made for a "non-crossing" solution as may arise from a point of tangency. The process is complicated by having to make allowance for the discontinuities that occur in all map projections.
Once one solution has been determined others may be found by subsequent invokations of wcsmix() with suitably restricted solution intervals.
Note the circumstance that arises when the solution point lies at a native pole of a projection in which the pole is represented as a finite curve, for example the zenithals and conics. In such cases two or more valid solutions may exist but wcsmix() only ever returns one.
Because of its generality wcsmix() is very compute-intensive. For compute-limited applications more efficient special-case solvers could be written for simple projections, for example non-oblique cylindrical projections.
int wcsccs | ( | struct wcsprm * | wcs, |
double | lng2p1, | ||
double | lat2p1, | ||
double | lng1p2, | ||
const char * | clng, | ||
const char * | clat, | ||
const char * | radesys, | ||
double | equinox, | ||
const char * | alt ) |
Change celestial coordinate system.
wcsccs() changes the celestial coordinate system of a wcsprm struct. For example, from equatorial to galactic coordinates.
Parameters that define the spherical coordinate transformation, essentially being three Euler angles, must be provided. Thereby wcsccs() does not need prior knowledge of specific celestial coordinate systems. It also has the advantage of making it completely general.
Auxiliary members of the wcsprm struct relating to equatorial celestial coordinate systems may also be changed.
Only orthodox spherical coordinate systems are supported. That is, they must be right-handed, with latitude increasing from zero at the equator to +90 degrees at the pole. This precludes systems such as aziumuth and zenith distance, which, however, could be handled as negative azimuth and elevation.
PLEASE NOTE: Information in the wcsprm struct relating to the original coordinate system will be overwritten and therefore lost. If this is undesirable, invoke wcsccs() on a copy of the struct made with wcssub(). The wcsprm struct is reset on return with an explicit call to wcsset().
[in,out] | wcs | Coordinate transformation parameters. Particular "values to be given" elements of the wcsprm struct are modified. |
[in] | lng2p1,lat2p1 | Longitude and latitude in the new celestial coordinate system of the pole (i.e. latitude +90) of the original system [deg]. See notes 1 and 2 below. |
[in] | lng1p2 | Longitude in the original celestial coordinate system of the pole (i.e. latitude +90) of the new system [deg]. See note 1 below. |
[in] | clng,clat | Longitude and latitude identifiers of the new CTYPEia celestial axis codes, without trailing dashes. For example, "RA" and "DEC" or "GLON" and "GLAT". Up to four characters are used, longer strings need not be null-terminated. |
[in] | radesys | Used when transforming to equatorial coordinates, identified by clng == "RA" and clat = "DEC". May be set to the null pointer to preserve the current value. Up to 71 characters are used, longer strings need not be null-terminated. If the new coordinate system is anything other than equatorial, then wcsprm::radesys will be cleared. |
[in] | equinox | Used when transforming to equatorial coordinates. May be set to zero to preserve the current value. If the new coordinate system is not equatorial, then wcsprm::equinox will be marked as undefined. |
[in] | alt | Character code for alternate coordinate descriptions (i.e. the 'a' in keyword names such as CTYPEia ). This is blank for the primary coordinate description, or one of the 26 upper-case letters, A-Z. May be set to the null pointer, or null string if no change is required. |
Notes:
Follows the prescription given in WCS Paper II, Sect. 2.7 for changing celestial coordinates.
The implementation takes account of indeterminacies that arise in that prescription in the particular cases where one of the poles of the new system is at the fiducial point, or one of them is at the native pole.
If lat2p1 == +90, i.e. where the poles of the two coordinate systems coincide, then the spherical coordinate transformation becomes a simple change in origin of longitude given by lng2 = lng1 + (lng2p1 - lng1p2 - 180), and lat2 = lat1, where (lng2,lat2) are coordinates in the new system, and (lng1,lat1) are coordinates in the original system.
Likewise, if lat2p1 == -90, then lng2 = -lng1 + (lng2p1 + lng1p2), and lat2 = -lat1.
For example, if the original coordinate system is B1950 equatorial and the desired new coordinate system is galactic, then
(lng2p1,lat2p1) are the galactic coordinates of the B1950 celestial pole, defined by the IAU to be (123.0,+27.4), and lng1p2 is the B1950 right ascension of the galactic pole, defined as 192.25. Clearly these coordinates are fixed for a particular coordinate transformation.
(clng,clat) would be 'GLON
' and 'GLAT
', these being the FITS standard identifiers for galactic coordinates.
4. The coordinates required for some common transformations (obtained from https://ned.ipac.caltech.edu/coordinate_calculator) are as follows:
int wcssptr | ( | struct wcsprm * | wcs, |
int * | i, | ||
char | ctype[9] ) |
Spectral axis translation.
wcssptr() translates the spectral axis in a wcsprm struct. For example, a 'FREQ
' axis may be translated into 'ZOPT-F2W'
and vice versa.
PLEASE NOTE: Information in the wcsprm struct relating to the original coordinate system will be overwritten and therefore lost. If this is undesirable, invoke wcssptr() on a copy of the struct made with wcssub(). The wcsprm struct is reset on return with an explicit call to wcsset().
[in,out] | wcs | Coordinate transformation parameters. |
[in,out] | i | Index of the spectral axis (0-relative). If given < 0 it will be set to the first spectral axis identified from the ctype[] keyvalues in the wcsprm struct. |
[in,out] | ctype | Desired spectral CTYPEia . Wildcarding may be used as for the ctypeS2 argument to spctrn() as described in the prologue of spc.h, i.e. if the final three characters are specified as "???", or if just the eighth character is specified as '?', the correct algorithm code will be substituted and returned. |
const char * wcslib_version | ( | int | vers[3] | ) |
|
extern |
Status return messages.
Error messages to match the status value returned from each function.