WCSLIB 8.4
|
#include "spx.h"
Go to the source code of this file.
Data Structures | |
struct | spcprm |
Spectral transformation parameters. More... | |
Macros | |
#define | SPCLEN (sizeof(struct spcprm)/sizeof(int)) |
Size of the spcprm struct in int units. | |
#define | spcini_errmsg spc_errmsg |
Deprecated. | |
#define | spcprt_errmsg spc_errmsg |
Deprecated. | |
#define | spcset_errmsg spc_errmsg |
Deprecated. | |
#define | spcx2s_errmsg spc_errmsg |
Deprecated. | |
#define | spcs2x_errmsg spc_errmsg |
Deprecated. | |
Enumerations | |
enum | spcenq_enum { SPCENQ_SET = 2 , SPCENQ_BYP = 4 } |
enum | spc_errmsg_enum { SPCERR_NO_CHANGE = -1 , SPCERR_SUCCESS = 0 , SPCERR_NULL_POINTER = 1 , SPCERR_BAD_SPEC_PARAMS = 2 , SPCERR_BAD_X = 3 , SPCERR_BAD_SPEC = 4 } |
Functions | |
int | spcini (struct spcprm *spc) |
Default constructor for the spcprm struct. | |
int | spcfree (struct spcprm *spc) |
Destructor for the spcprm struct. | |
int | spcsize (const struct spcprm *spc, int sizes[2]) |
Compute the size of a spcprm struct. | |
int | spcenq (const struct spcprm *spc, int enquiry) |
enquire about the state of a spcprm struct. | |
int | spcprt (const struct spcprm *spc) |
Print routine for the spcprm struct. | |
int | spcperr (const struct spcprm *spc, const char *prefix) |
Print error messages from a spcprm struct. | |
int | spcset (struct spcprm *spc) |
Setup routine for the spcprm struct. | |
int | spcx2s (struct spcprm *spc, int nx, int sx, int sspec, const double x[], double spec[], int stat[]) |
Transform to spectral coordinates. | |
int | spcs2x (struct spcprm *spc, int nspec, int sspec, int sx, const double spec[], double x[], int stat[]) |
Transform spectral coordinates. | |
int | spctype (const char ctype[9], char stype[], char scode[], char sname[], char units[], char *ptype, char *xtype, int *restreq, struct wcserr **err) |
Spectral CTYPEia keyword analysis. | |
int | spcspxe (const char ctypeS[9], double crvalS, double restfrq, double restwav, char *ptype, char *xtype, int *restreq, double *crvalX, double *dXdS, struct wcserr **err) |
Spectral keyword analysis. | |
int | spcxpse (const char ctypeS[9], double crvalX, double restfrq, double restwav, char *ptype, char *xtype, int *restreq, double *crvalS, double *dSdX, struct wcserr **err) |
Spectral keyword synthesis. | |
int | spctrne (const char ctypeS1[9], double crvalS1, double cdeltS1, double restfrq, double restwav, char ctypeS2[9], double *crvalS2, double *cdeltS2, struct wcserr **err) |
Spectral keyword translation. | |
int | spcaips (const char ctypeA[9], int velref, char ctype[9], char specsys[9]) |
Translate AIPS-convention spectral keywords. | |
int | spctyp (const char ctype[9], char stype[], char scode[], char sname[], char units[], char *ptype, char *xtype, int *restreq) |
int | spcspx (const char ctypeS[9], double crvalS, double restfrq, double restwav, char *ptype, char *xtype, int *restreq, double *crvalX, double *dXdS) |
int | spcxps (const char ctypeS[9], double crvalX, double restfrq, double restwav, char *ptype, char *xtype, int *restreq, double *crvalS, double *dSdX) |
int | spctrn (const char ctypeS1[9], double crvalS1, double cdeltS1, double restfrq, double restwav, char ctypeS2[9], double *crvalS2, double *cdeltS2) |
Variables | |
const char * | spc_errmsg [] |
Status return messages. | |
Routines in this suite implement the part of the FITS World Coordinate System (WCS) standard that deals with spectral coordinates, as described in
These routines define methods to be used for computing spectral world coordinates from intermediate world coordinates (a linear transformation of image pixel coordinates), and vice versa. They are based on the spcprm 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.
Routine spcini() is provided to initialize the spcprm struct with default values, spcfree() reclaims any memory that may have been allocated to store an error message, spcsize() computes its total size including allocated memory, spcenq() returns information about the state of the struct, and spcprt() prints its contents.
spcperr() prints the error message(s) (if any) stored in a spcprm struct.
A setup routine, spcset(), computes intermediate values in the spcprm struct from parameters in it that were supplied by the user. The struct always needs to be set up by spcset() but it need not be called explicitly - refer to the explanation of spcprm::flag.
spcx2s() and spcs2x() implement the WCS spectral coordinate transformations. In fact, they are high level driver routines for the lower level spectral coordinate transformation routines described in spx.h.
A number of routines are provided to aid in analysing or synthesising sets of FITS spectral axis keywords:
spctype() checks a spectral CTYPEia
keyword for validity and returns information derived from it.
Spectral keyword analysis routine spcspxe() computes the values of the
Spectral keyword synthesis routine, spcxpse(), computes the
Given a set of spectral keywords, a translation routine, spctrne(), produces the corresponding set for the specified spectral CTYPEia
.
CTYPEia
and VELREF
keyvalues. Spectral variable types -
A few words of explanation are necessary regarding spectral variable types in FITS.
Every FITS spectral axis has three associated spectral variables:
F (Frequency):
FREQ
': frequency AFRQ
': angular frequency ENER
': photon energy WAVN
': wave number VRAD
': radio velocity W (Wavelength in vacuo):
WAVE
': wavelength VOPT
': optical velocity ZOPT
': redshift A (wavelength in Air):
AWAV
': wavelength in air V (Velocity):
VELO
': relativistic velocity BETA
': relativistic beta factor The CTYPEia
keyvalue, and CRVALia
and CDELTia
are expressed as
Note that 'AFRQ
', angular frequency, is additional to the variables defined in WCS Paper III.
For non-grism axes, the CTYPEia
.
For non-grism axes, the CTYPEia
.
Grisms: Grism axes have normal CTYPEia
, either 'GRI
' (in vacuo) or 'GRA
' (in air).
In the algorithm chain, the non-linear transformation occurs between the
When the CTYPEia
are blank. This can never happen for grism axes.
As an example, correlating radio spectrometers always produce spectra that are regularly gridded in frequency; a redshift scale on such a spectrum is non-linear. The required value of CTYPEia
would be 'ZOPT-F2W'
, where the desired ZOPT
' (redshift), the
Air-to-vacuum wavelength conversion:
Please refer to the prologue of spx.h for important comments relating to the air-to-vacuum wavelength conversion.
Argument checking:
The input spectral values are only checked for values that would result in floating point exceptions. In particular, negative frequencies and wavelengths are allowed, as are velocities greater than the speed of light. The same is true for the spectral parameters - rest frequency and wavelength.
Accuracy:
No warranty is given for the accuracy of these routines (refer to the copyright notice); intending users must satisfy for themselves their adequacy for the intended purpose. However, closure effectively to within double precision rounding error was demonstrated by test routine tspc.c which accompanies this software.
#define SPCLEN (sizeof(struct spcprm)/sizeof(int)) |
Size of the spcprm struct in int units.
Size of the spcprm struct in int units, used by the Fortran wrappers.
#define spcini_errmsg spc_errmsg |
Deprecated.
#define spcprt_errmsg spc_errmsg |
Deprecated.
#define spcset_errmsg spc_errmsg |
Deprecated.
#define spcx2s_errmsg spc_errmsg |
Deprecated.
#define spcs2x_errmsg spc_errmsg |
Deprecated.
enum spcenq_enum |
enum spc_errmsg_enum |
int spcini | ( | struct spcprm * | spc | ) |
Default constructor for the spcprm struct.
spcini() sets all members of a spcprm struct to default values. It should be used to initialize every spcprm struct.
PLEASE NOTE: If the spcprm struct has already been initialized, then before reinitializing, it spcfree() should be used to free any memory that may have been allocated to store an error message. A memory leak may otherwise result.
[in,out] | spc | Spectral transformation parameters. |
int spcfree | ( | struct spcprm * | spc | ) |
Destructor for the spcprm struct.
spcfree() frees any memory that may have been allocated to store an error message in the spcprm struct.
[in] | spc | Spectral transformation parameters. |
int spcsize | ( | const struct spcprm * | spc, |
int | sizes[2] ) |
Compute the size of a spcprm struct.
spcsize() computes the full size of a spcprm struct, including allocated memory.
[in] | spc | Spectral 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 spcprm). The second element is the total allocated size, in bytes. This figure includes memory allocated for the constituent struct, spcprm::err. It is not an error for the struct not to have been set up via spcset(). |
int spcenq | ( | const struct spcprm * | spc, |
int | enquiry ) |
enquire about the state of a spcprm struct.
spcenq() may be used to obtain information about the state of a spcprm struct. The function returns a true/false answer for the enquiry asked.
[in] | spc | Spectral transformation parameters. |
[in] | enquiry | Enquiry according to the following parameters: These may be combined by logical OR, e.g. SPCENQ_MEM | SPCENQ_SET. The enquiry result will be the logical AND of the individual results. |
int spcprt | ( | const struct spcprm * | spc | ) |
Print routine for the spcprm struct.
spcprt() prints the contents of a spcprm struct using wcsprintf(). Mainly intended for diagnostic purposes.
[in] | spc | Spectral transformation parameters. |
int spcperr | ( | const struct spcprm * | spc, |
const char * | prefix ) |
Print error messages from a spcprm struct.
spcperr() prints the error message(s) (if any) stored in a spcprm struct. If there are no errors then nothing is printed. It uses wcserr_prt(), q.v.
[in] | spc | Spectral transformation parameters. |
[in] | prefix | If non-NULL, each output line will be prefixed with this string. |
int spcset | ( | struct spcprm * | spc | ) |
Setup routine for the spcprm struct.
spcset() sets up a spcprm struct according to information supplied within it.
Note that this routine need not be called directly; it will be invoked by spcx2s() and spcs2x() if spcprm::flag is anything other than a predefined magic value.
spcset() normally operates regardless of the value of spcprm::flag; i.e. even if a struct was previously set up it will be reset unconditionally. However, a spcprm struct may be put into "bypass" mode by invoking spcset() initially with spcprm::flag == 1 (rather than 0). spcset() will return immediately if invoked on a struct in that state. To take a struct out of bypass mode, simply reset spcprm::flag to zero. See also spcenq().
[in,out] | spc | Spectral transformation parameters. |
int spcx2s | ( | struct spcprm * | spc, |
int | nx, | ||
int | sx, | ||
int | sspec, | ||
const double | x[], | ||
double | spec[], | ||
int | stat[] ) |
Transform to spectral coordinates.
spcx2s() transforms intermediate world coordinates to spectral coordinates.
[in,out] | spc | Spectral transformation parameters. |
[in] | nx | Vector length. |
[in] | sx | Vector stride. |
[in] | sspec | Vector stride. |
[in] | x | Intermediate world coordinates, in SI units. |
[out] | spec | Spectral coordinates, in SI units. |
[out] | stat | Status return value status for each vector element:
|
int spcs2x | ( | struct spcprm * | spc, |
int | nspec, | ||
int | sspec, | ||
int | sx, | ||
const double | spec[], | ||
double | x[], | ||
int | stat[] ) |
Transform spectral coordinates.
spcs2x() transforms spectral world coordinates to intermediate world coordinates.
[in,out] | spc | Spectral transformation parameters. |
[in] | nspec | Vector length. |
[in] | sspec | Vector stride. |
[in] | sx | Vector stride. |
[in] | spec | Spectral coordinates, in SI units. |
[out] | x | Intermediate world coordinates, in SI units. |
[out] | stat | Status return value status for each vector element:
|
int spctype | ( | const char | ctype[9], |
char | stype[], | ||
char | scode[], | ||
char | sname[], | ||
char | units[], | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq, | ||
struct wcserr ** | err ) |
Spectral CTYPEia
keyword analysis.
spctype() checks whether a CTYPEia
keyvalue is a valid spectral axis type and if so returns information derived from it relating to the associated
The return arguments are guaranteed not be modified if CTYPEia
is not a valid spectral type; zero-pointers may be specified for any that are not of interest.
A deprecated form of this function, spctyp(), lacks the wcserr** parameter.
[in] | ctype | The CTYPEia keyvalue, (eight characters with null termination). |
[out] | stype | The four-letter name of the ![]() |
[out] | scode | The three-letter spectral algorithm code copied or translated from ctype. Logarithmic ('LOG ') and tabular ('TAB ') codes are also recognized. If a non-zero pointer is given, the array must accomodate a null-terminated string of length 4. |
[out] | sname | Descriptive name of the ![]() |
[out] | units | SI units of the ![]() |
[out] | ptype | Character code for the ![]() |
[out] | xtype | Character code for the ![]() LOG ') and tabular ('TAB ') axes. |
[out] | restreq | Multivalued flag that indicates whether rest frequency or wavelength is required to compute spectral variables for this CTYPEia :
![]() ![]() restreq%3 != 0
|
[out] | err | If enabled, for function return values > 1, this struct will contain a detailed error message, see wcserr_enable(). May be NULL if an error message is not desired. Otherwise, the user is responsible for deleting the memory allocated for the wcserr struct. |
CTYPEia
). int spcspxe | ( | const char | ctypeS[9], |
double | crvalS, | ||
double | restfrq, | ||
double | restwav, | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq, | ||
double * | crvalX, | ||
double * | dXdS, | ||
struct wcserr ** | err ) |
Spectral keyword analysis.
spcspxe() analyses the CTYPEia
and CRVALia
FITS spectral axis keyword values and returns information about the associated
A deprecated form of this function, spcspx(), lacks the wcserr** parameter.
[in] | ctypeS | Spectral axis type, i.e. the CTYPEia keyvalue, (eight characters with null termination). For non-grism axes, the character code for the ![]() CTYPEia ) may be set to '?' (it will not be reset). |
[in] | crvalS | Value of the ![]() CRVALia keyvalue, SI units. |
[in] | restfrq,restwav | Rest frequency [Hz] and rest wavelength in vacuo [m], only one of which need be given, the other should be set to zero. |
[out] | ptype | Character code for the ![]() |
[out] | xtype | Character code for the ![]() |
[out] | restreq | Multivalued flag that indicates whether rest frequency or wavelength is required to compute spectral variables for this CTYPEia , as for spctype(). |
[out] | crvalX | Value of the ![]() |
[out] | dXdS | The derivative, ![]() CDELTia keyvalue by this to get the pixel spacing in the ![]() |
[out] | err | If enabled, for function return values > 1, this struct will contain a detailed error message, see wcserr_enable(). May be NULL if an error message is not desired. Otherwise, the user is responsible for deleting the memory allocated for the wcserr struct. |
int spcxpse | ( | const char | ctypeS[9], |
double | crvalX, | ||
double | restfrq, | ||
double | restwav, | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq, | ||
double * | crvalS, | ||
double * | dSdX, | ||
struct wcserr ** | err ) |
Spectral keyword synthesis.
spcxpse(), for the spectral axis type specified and the value provided for the CRVALia
and also the derivative CDELTia
. See above for an explanation of the
A deprecated form of this function, spcxps(), lacks the wcserr** parameter.
[in] | ctypeS | The required spectral axis type, i.e. the CTYPEia keyvalue, (eight characters with null termination). For non-grism axes, the character code for the ![]() CTYPEia ) may be set to '?' (it will not be reset). |
[in] | crvalX | Value of the ![]() CRVALia keyvalue), SI units. |
[in] | restfrq,restwav | Rest frequency [Hz] and rest wavelength in vacuo [m], only one of which need be given, the other should be set to zero. |
[out] | ptype | Character code for the ![]() |
[out] | xtype | Character code for the ![]() |
[out] | restreq | Multivalued flag that indicates whether rest frequency or wavelength is required to compute spectral variables for this CTYPEia , as for spctype(). |
[out] | crvalS | Value of the ![]() CRVALia keyvalue), SI units. |
[out] | dSdX | The derivative, ![]() ![]() CDELTia keyvalue. |
[out] | err | If enabled, for function return values > 1, this struct will contain a detailed error message, see wcserr_enable(). May be NULL if an error message is not desired. Otherwise, the user is responsible for deleting the memory allocated for the wcserr struct. |
int spctrne | ( | const char | ctypeS1[9], |
double | crvalS1, | ||
double | cdeltS1, | ||
double | restfrq, | ||
double | restwav, | ||
char | ctypeS2[9], | ||
double * | crvalS2, | ||
double * | cdeltS2, | ||
struct wcserr ** | err ) |
Spectral keyword translation.
spctrne() translates a set of FITS spectral axis keywords into the corresponding set for the specified spectral axis type. For example, a 'FREQ
' axis may be translated into 'ZOPT-F2W'
and vice versa.
A deprecated form of this function, spctrn(), lacks the wcserr** parameter.
[in] | ctypeS1 | Spectral axis type, i.e. the CTYPEia keyvalue, (eight characters with null termination). For non-grism axes, the character code for the ![]() CTYPEia ) may be set to '?' (it will not be reset). |
[in] | crvalS1 | Value of the ![]() CRVALia keyvalue, SI units. |
[in] | cdeltS1 | Increment of the ![]() |
[in] | restfrq,restwav | Rest frequency [Hz] and rest wavelength in vacuo [m], only one of which need be given, the other should be set to zero. Neither are required if the translation is between wave-characteristic types, or between velocity-characteristic types. E.g., required for 'FREQ ' -> 'ZOPT-F2W' , but not required for 'VELO-F2V' -> 'ZOPT-F2W' . |
[in,out] | ctypeS2 | Required spectral axis type (eight characters with null termination). The first four characters are required to be given and are never modified. The remaining four, the algorithm code, are completely determined by, and must be consistent with, ctypeS1 and the first four characters of ctypeS2. A non-zero status value will be returned if they are inconsistent (see below). However, if the final three characters are specified as "???", or if just the eighth character is specified as '?', the correct algorithm code will be substituted (applies for grism axes as well as non-grism). |
[out] | crvalS2 | Value of the new ![]() CRVALia keyvalue, SI units. |
[out] | cdeltS2 | Increment of the new ![]() CDELTia keyvalue, SI units. |
[out] | err | If enabled, for function return values > 1, this struct will contain a detailed error message, see wcserr_enable(). May be NULL if an error message is not desired. Otherwise, the user is responsible for deleting the memory allocated for the wcserr struct. |
int spcaips | ( | const char | ctypeA[9], |
int | velref, | ||
char | ctype[9], | ||
char | specsys[9] ) |
Translate AIPS-convention spectral keywords.
spcaips() translates AIPS-convention spectral CTYPEia
and VELREF
keyvalues.
[in] | ctypeA | CTYPEia keyvalue possibly containing an AIPS-convention spectral code (eight characters, need not be null-terminated). |
[in] | velref | AIPS-convention VELREF code. It has the following integer values:
VELREF are also recognized:
VELO ' axis, a radio convention velocity (VRAD) is denoted by adding 256 to VELREF , otherwise an optical velocity (VOPT) is indicated (this is not applicable to 'FREQ ' or 'FELO ' axes). Setting velref to 0 or 256 chooses between optical and radio velocity without specifying a Doppler frame, provided that a frame is encoded in ctypeA. If not, i.e. for ctypeA = 'VELO ', ctype will be returned as 'VELO '. VELREF takes precedence over CTYPEia in defining the Doppler frame, e.g. ctypeA = 'VELO-HEL'
velref = 1
returns ctype = ' VOPT ' with specsys set to 'LSRK'. If omitted from the header, the default value of VELREF is 0. |
[out] | ctype | Translated CTYPEia keyvalue, or a copy of ctypeA if no translation was performed (in which case any trailing blanks in ctypeA will be replaced with nulls). |
[out] | specsys | Doppler reference frame indicated by VELREF or else by CTYPEia with value corresponding to the SPECSYS keyvalue in the FITS WCS standard. May be returned blank if neither specifies a Doppler frame, e.g. ctypeA = 'FELO ' and velref%256 == 0. |
VELREF
. int spctyp | ( | const char | ctype[9], |
char | stype[], | ||
char | scode[], | ||
char | sname[], | ||
char | units[], | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq ) |
int spcspx | ( | const char | ctypeS[9], |
double | crvalS, | ||
double | restfrq, | ||
double | restwav, | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq, | ||
double * | crvalX, | ||
double * | dXdS ) |
int spcxps | ( | const char | ctypeS[9], |
double | crvalX, | ||
double | restfrq, | ||
double | restwav, | ||
char * | ptype, | ||
char * | xtype, | ||
int * | restreq, | ||
double * | crvalS, | ||
double * | dSdX ) |
int spctrn | ( | const char | ctypeS1[9], |
double | crvalS1, | ||
double | cdeltS1, | ||
double | restfrq, | ||
double | restwav, | ||
char | ctypeS2[9], | ||
double * | crvalS2, | ||
double * | cdeltS2 ) |
|
extern |
Status return messages.
Error messages to match the status value returned from each function.