00001 /*============================================================================ 00002 00003 WCSLIB 4.4 - an implementation of the FITS WCS standard. 00004 Copyright (C) 1995-2009, Mark Calabretta 00005 00006 This file is part of WCSLIB. 00007 00008 WCSLIB is free software: you can redistribute it and/or modify it under the 00009 terms of the GNU Lesser General Public License as published by the Free 00010 Software Foundation, either version 3 of the License, or (at your option) 00011 any later version. 00012 00013 WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY 00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00016 more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with WCSLIB. If not, see <http://www.gnu.org/licenses/>. 00020 00021 Correspondence concerning WCSLIB may be directed to: 00022 Internet email: mcalabre@atnf.csiro.au 00023 Postal address: Dr. Mark Calabretta 00024 Australia Telescope National Facility, CSIRO 00025 PO Box 76 00026 Epping NSW 1710 00027 AUSTRALIA 00028 00029 Author: Mark Calabretta, Australia Telescope National Facility 00030 http://www.atnf.csiro.au/~mcalabre/index.html 00031 $Id: spc_8h-source.html,v 1.1 2009/09/14 20:25:24 irby Exp $ 00032 *============================================================================= 00033 * 00034 * WCSLIB 4.4 - C routines that implement the spectral coordinate systems 00035 * recognized by the FITS World Coordinate System (WCS) standard. Refer to 00036 * 00037 * "Representations of world coordinates in FITS", 00038 * Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (Paper I) 00039 * 00040 * "Representations of spectral coordinates in FITS", 00041 * Greisen, E.W., Calabretta, M.R., Valdes, F.G., & Allen, S.L. 00042 * 2006, A&A, 446, 747 (Paper III) 00043 * 00044 * Refer to the README file provided with WCSLIB for an overview of the 00045 * library. 00046 * 00047 * 00048 * Summary of the spc routines 00049 * --------------------------- 00050 * These routines implement the part of the FITS WCS standard that deals with 00051 * spectral coordinates. They define methods to be used for computing spectral 00052 * world coordinates from intermediate world coordinates (a linear 00053 * transformation of image pixel coordinates), and vice versa. They are based 00054 * on the spcprm struct which contains all information needed for the 00055 * computations. The struct contains some members that must be set by the 00056 * user, and others that are maintained by these routines, somewhat like a 00057 * C++ class but with no encapsulation. 00058 * 00059 * Routine spcini() is provided to initialize the spcprm struct with default 00060 * values, and another, spcprt(), to print its contents. 00061 * 00062 * A setup routine, spcset(), computes intermediate values in the spcprm struct 00063 * from parameters in it that were supplied by the user. The struct always 00064 * needs to be set up by spcset() but it need not be called explicitly - refer 00065 * to the explanation of spcprm::flag. 00066 * 00067 * spcx2s() and spcs2x() implement the WCS spectral coordinate transformations. 00068 * In fact, they are high level driver routines for the lower level spectral 00069 * coordinate transformation routines described in spx.h. 00070 * 00071 * A number of routines are provided to aid in analysing or synthesising sets 00072 * of FITS spectral axis keywords: 00073 * 00074 * - spctyp() checks a spectral CTYPEia keyword for validity and returns 00075 * information derived from it. 00076 * 00077 * - Spectral keyword analysis routine spcspx() computes the values of the 00078 * X-type spectral variables for the S-type variables supplied. 00079 * 00080 * - Spectral keyword synthesis routine, spcxps(), computes the S-type 00081 * variables for the X-types supplied. 00082 * 00083 * - Given a set of spectral keywords, a translation routine, spctrn(), 00084 * produces the corresponding set for the specified spectral CTYPEia. 00085 * 00086 * Spectral variable types - S, P, and X: 00087 * -------------------------------------- 00088 * A few words of explanation are necessary regarding spectral variable types 00089 * in FITS. 00090 * 00091 * Every FITS spectral axis has three associated spectral variables: 00092 * 00093 * S-type: the spectral variable in which coordinates are to be 00094 * expressed. Each S-type is encoded as four characters and is 00095 * linearly related to one of four basic types as follows: 00096 * 00097 * F: frequency 00098 * 'FREQ': frequency 00099 * 'AFRQ': angular frequency 00100 * 'ENER': photon energy 00101 * 'WAVN': wave number 00102 * 'VRAD': radio velocity 00103 * 00104 * W: wavelength in vacuo 00105 * 'WAVE': wavelength 00106 * 'VOPT': optical velocity 00107 * 'ZOPT': redshift 00108 * 00109 * A: wavelength in air 00110 * 'AWAV': wavelength in air 00111 * 00112 * V: velocity 00113 * 'VELO': relativistic velocity 00114 * 'BETA': relativistic beta factor 00115 * 00116 * The S-type forms the first four characters of the CTYPEia keyvalue, 00117 * and CRVALia and CDELTia are expressed as S-type quantities so that 00118 * they provide a first-order approximation to the S-type variable at 00119 * the reference point. 00120 * 00121 * Note that 'AFRQ', angular frequency, is additional to the variables 00122 * defined in WCS Paper III. 00123 * 00124 * P-type: the basic spectral variable (F, W, A, or V) with which the 00125 * S-type variable is associated (see list above). 00126 * 00127 * For non-grism axes, the P-type is encoded as the eighth character of 00128 * CTYPEia. 00129 * 00130 * X-type: the basic spectral variable (F, W, A, or V) for which the 00131 * spectral axis is linear, grisms excluded (see below). 00132 * 00133 * For non-grism axes, the X-type is encoded as the sixth character of 00134 * CTYPEia. 00135 * 00136 * Grisms: Grism axes have normal S-, and P-types but the axis is linear, 00137 * not in any spectral variable, but in a special "grism parameter". 00138 * The X-type spectral variable is either W or A for grisms in vacuo or 00139 * air respectively, but is encoded as 'w' or 'a' to indicate that an 00140 * additional transformation is required to convert to or from the 00141 * grism parameter. The spectral algorithm code for grisms also has a 00142 * special encoding in CTYPEia, either 'GRI' (in vacuo) or 'GRA' (in air). 00143 * 00144 * In the algorithm chain, the non-linear transformation occurs between the 00145 * X-type and the P-type variables; the transformation between P-type and 00146 * S-type variables is always linear. 00147 * 00148 * When the P-type and X-type variables are the same, the spectral axis is 00149 * linear in the S-type variable and the second four characters of CTYPEia 00150 * are blank. This can never happen for grism axes. 00151 * 00152 * As an example, correlating radio spectrometers always produce spectra that 00153 * are regularly gridded in frequency; a redshift scale on such a spectrum is 00154 * non-linear. The required value of CTYPEia would be 'ZOPT-F2W', where the 00155 * desired S-type is 'ZOPT' (redshift), the P-type is necessarily 'W' 00156 * (wavelength), and the X-type is 'F' (frequency) by the nature of the 00157 * instrument. 00158 * 00159 * Argument checking: 00160 * ------------------ 00161 * The input spectral values are only checked for values that would result in 00162 * floating point exceptions. In particular, negative frequencies and 00163 * wavelengths are allowed, as are velocities greater than the speed of 00164 * light. The same is true for the spectral parameters - rest frequency and 00165 * wavelength. 00166 * 00167 * Accuracy: 00168 * --------- 00169 * No warranty is given for the accuracy of these routines (refer to the 00170 * copyright notice); intending users must satisfy for themselves their 00171 * adequacy for the intended purpose. However, closure effectively to within 00172 * double precision rounding error was demonstrated by test routine tspc.c 00173 * which accompanies this software. 00174 * 00175 * 00176 * spcini() - Default constructor for the spcprm struct 00177 * ---------------------------------------------------- 00178 * spcini() sets all members of a spcprm struct to default values. It should 00179 * be used to initialize every spcprm struct. 00180 * 00181 * Given and returned: 00182 * spc struct spcprm* 00183 * Spectral transformation parameters. 00184 * 00185 * Function return value: 00186 * int Status return value: 00187 * 0: Success. 00188 * 1: Null spcprm pointer passed. 00189 * 00190 * 00191 * spcprt() - Print routine for the spcprm struct 00192 * ---------------------------------------------- 00193 * spcprt() prints the contents of a spcprm struct. 00194 * 00195 * Given: 00196 * spc const struct spcprm* 00197 * Spectral transformation parameters. 00198 * 00199 * Function return value: 00200 * int Status return value: 00201 * 0: Success. 00202 * 1: Null spcprm pointer passed. 00203 * 00204 * 00205 * spcset() - Setup routine for the spcprm struct 00206 * ---------------------------------------------- 00207 * spcset() sets up a spcprm struct according to information supplied within 00208 * it. 00209 * 00210 * Note that this routine need not be called directly; it will be invoked by 00211 * spcx2s() and spcs2x() if spcprm::flag is anything other than a predefined 00212 * magic value. 00213 * 00214 * Given and returned: 00215 * spc struct spcprm* 00216 * Spectral transformation parameters. 00217 * 00218 * Function return value: 00219 * int Status return value: 00220 * 0: Success. 00221 * 1: Null spcprm pointer passed. 00222 * 2: Invalid spectral parameters. 00223 * 00224 * 00225 * spcx2s() - Transform to spectral coordinates 00226 * -------------------------------------------- 00227 * spcx2s() transforms intermediate world coordinates to spectral coordinates. 00228 * 00229 * Given and returned: 00230 * spc struct spcprm* 00231 * Spectral transformation parameters. 00232 * 00233 * Given: 00234 * nx int Vector length. 00235 * sx int Vector stride. 00236 * sspec int Vector stride. 00237 * x const double[] 00238 * Intermediate world coordinates, in SI units. 00239 * 00240 * Returned: 00241 * spec double[] Spectral coordinates, in SI units. 00242 * stat int[] Status return value status for each vector element: 00243 * 0: Success. 00244 * 1: Invalid value of x. 00245 * 00246 * Function return value: 00247 * int Status return value: 00248 * 0: Success. 00249 * 1: Null spcprm pointer passed. 00250 * 2: Invalid spectral parameters. 00251 * 3: One or more of the x coordinates were invalid, 00252 * as indicated by the stat vector. 00253 * 00254 * 00255 * spcs2x() - Transform spectral coordinates 00256 * ----------------------------------------- 00257 * spcs2x() transforms spectral world coordinates to intermediate world 00258 * coordinates. 00259 * 00260 * Given and returned: 00261 * spc struct spcprm* 00262 * Spectral transformation parameters. 00263 * 00264 * Given: 00265 * nspec int Vector length. 00266 * sspec int Vector stride. 00267 * sx int Vector stride. 00268 * spec const double[] 00269 * Spectral coordinates, in SI units. 00270 * 00271 * Returned: 00272 * x double[] Intermediate world coordinates, in SI units. 00273 * stat int[] Status return value status for each vector element: 00274 * 0: Success. 00275 * 1: Invalid value of spec. 00276 * 00277 * Function return value: 00278 * int Status return value: 00279 * 0: Success. 00280 * 1: Null spcprm pointer passed. 00281 * 2: Invalid spectral parameters. 00282 * 4: One or more of the spec coordinates were 00283 * invalid, as indicated by the stat vector. 00284 * 00285 * 00286 * spctyp() - Spectral CTYPEia keyword analysis 00287 * -------------------------------------------- 00288 * spctyp() checks whether a CTYPEia keyvalue is a valid spectral axis type and 00289 * if so returns information derived from it relating to the associated S-, P-, 00290 * and X-type spectral variables (see explanation above). It recognizes and 00291 * translates AIPS-convention spectral CTYPEia keyvalues. 00292 * 00293 * The return arguments are guaranteed not be modified if CTYPEia is not a 00294 * valid spectral type; zero-pointers may be specified for any that are not of 00295 * interest. 00296 * 00297 * Given: 00298 * ctype const char[9] 00299 * The CTYPEia keyvalue, (eight characters with null 00300 * termination). 00301 * 00302 * Returned: 00303 * stype char[] The four-letter name of the S-type spectral variable 00304 * copied or translated from ctype. If a non-zero 00305 * pointer is given, the array must accomodate a null- 00306 * terminated string of length 5. 00307 * scode char[] The three-letter spectral algorithm code copied or 00308 * translated from ctype. Logarithmic ('LOG') and 00309 * tabular ('TAB') codes are also recognized. If a 00310 * non-zero pointer is given, the array must accomodate a 00311 * null-terminated string of length 4. 00312 * sname char[] Descriptive name of the S-type spectral variable. 00313 * If a non-zero pointer is given, the array must 00314 * accomodate a null-terminated string of length 22. 00315 * units char[] SI units of the S-type spectral variable. If a 00316 * non-zero pointer is given, the array must accomodate a 00317 * null-terminated string of length 8. 00318 * ptype char* Character code for the P-type spectral variable 00319 * derived from ctype, one of 'F', 'W', 'A', or 'V'. 00320 * xtype char* Character code for the X-type spectral variable 00321 * derived from ctype, one of 'F', 'W', 'A', or 'V'. 00322 * Also, 'w' and 'a' are synonymous to 'W' and 'A' for 00323 * grisms in vacuo and air respectively. Set to 'L' or 00324 * 'T' for logarithmic ('LOG') and tabular ('TAB') axes. 00325 * restreq int* Multivalued flag that indicates whether rest 00326 * frequency or wavelength is required to compute 00327 * spectral variables for this CTYPEia: 00328 * 0: Not required. 00329 * 1: Required for the conversion between S- and 00330 * P-types (e.g. 'ZOPT-F2W'). 00331 * 2: Required for the conversion between P- and 00332 * X-types (e.g. 'BETA-W2V'). 00333 * 3: Required for the conversion between S- and 00334 * P-types, and between P- and X-types, but not 00335 * between S- and X-types (this applies only for 00336 * 'VRAD-V2F', 'VOPT-V2W', and 'ZOPT-V2W'). 00337 * Thus the rest frequency or wavelength is required for 00338 * spectral coordinate computations (i.e. between S- and 00339 * X-types) only if restreq%3 != 0. 00340 * 00341 * Function return value: 00342 * int Status return value: 00343 * 0: Success. 00344 * 2: Invalid spectral parameters (not a spectral 00345 * CTYPEia). 00346 * 00347 * 00348 * spcspx() - Spectral keyword analysis 00349 * ------------------------------------ 00350 * spcspx() analyses the CTYPEia and CRVALia FITS spectral axis keyword values 00351 * and returns information about the associated X-type spectral variable. 00352 * 00353 * Given: 00354 * ctypeS const char[9] 00355 * Spectral axis type, i.e. the CTYPEia keyvalue, (eight 00356 * characters with null termination). For non-grism 00357 * axes, the character code for the P-type spectral 00358 * variable in the algorithm code (i.e. the eighth 00359 * character of CTYPEia) may be set to '?' (it will not 00360 * be reset). 00361 * crvalS double Value of the S-type spectral variable at the reference 00362 * point, i.e. the CRVALia keyvalue, SI units. 00363 * restfrq, 00364 * restwav double Rest frequency [Hz] and rest wavelength in vacuo [m], 00365 * only one of which need be given, the other should be 00366 * set to zero. Neither are required if the translation 00367 * is between wave-characteristic types, or between 00368 * velocity-characteristic types. E.g., required for 00369 * 'FREQ' -> 'ZOPT-F2W', but not required for 00370 * 'VELO-F2V' -> 'ZOPT-F2W'. 00371 * 00372 * Returned: 00373 * ptype char* Character code for the P-type spectral variable 00374 * derived from ctypeS, one of 'F', 'W', 'A', or 'V'. 00375 * xtype char* Character code for the X-type spectral variable 00376 * derived from ctypeS, one of 'F', 'W', 'A', or 'V'. 00377 * Also, 'w' and 'a' are synonymous to 'W' and 'A' for 00378 * grisms in vacuo and air respectively; crvalX and dXdS 00379 * (see below) will conform to these. 00380 * restreq int* Multivalued flag that indicates whether rest frequency 00381 * or wavelength is required to compute spectral 00382 * variables for this CTYPEia, as for spctyp(). 00383 * crvalX double* Value of the X-type spectral variable at the reference 00384 * point, SI units. 00385 * dXdS double* The derivative, dX/dS, evaluated at the reference 00386 * point, SI units. Multiply the CDELTia keyvalue by 00387 * this to get the pixel spacing in the X-type spectral 00388 * coordinate. 00389 * 00390 * Function return value: 00391 * int Status return value: 00392 * 0: Success. 00393 * 2: Invalid spectral parameters. 00394 * 00395 * 00396 * spcxps() - Spectral keyword synthesis 00397 * ------------------------------------- 00398 * spcxps(), for the spectral axis type specified and the value provided for 00399 * the X-type spectral variable at the reference point, deduces the value of 00400 * the FITS spectral axis keyword CRVALia and also the derivative dS/dX which 00401 * may be used to compute CDELTia. See above for an explanation of the S-, 00402 * P-, and X-type spectral variables. 00403 * 00404 * Given: 00405 * ctypeS const char[9] 00406 * The required spectral axis type, i.e. the CTYPEia 00407 * keyvalue, (eight characters with null termination). 00408 * For non-grism axes, the character code for the P-type 00409 * spectral variable in the algorithm code (i.e. the 00410 * eighth character of CTYPEia) may be set to '?' (it 00411 * will not be reset). 00412 * crvalX double Value of the X-type spectral variable at the reference 00413 * point (N.B. NOT the CRVALia keyvalue), SI units. 00414 * restfrq, 00415 * restwav double Rest frequency [Hz] and rest wavelength in vacuo [m], 00416 * only one of which need be given, the other should be 00417 * set to zero. Neither are required if the translation 00418 * is between wave-characteristic types, or between 00419 * velocity-characteristic types. E.g., required for 00420 * 'FREQ' -> 'ZOPT-F2W', but not required for 00421 * 'VELO-F2V' -> 'ZOPT-F2W'. 00422 * 00423 * Returned: 00424 * ptype char* Character code for the P-type spectral variable 00425 * derived from ctypeS, one of 'F', 'W', 'A', or 'V'. 00426 * xtype char* Character code for the X-type spectral variable 00427 * derived from ctypeS, one of 'F', 'W', 'A', or 'V'. 00428 * Also, 'w' and 'a' are synonymous to 'W' and 'A' for 00429 * grisms; crvalX and cdeltX must conform to these. 00430 * restreq int* Multivalued flag that indicates whether rest frequency 00431 * or wavelength is required to compute spectral 00432 * variables for this CTYPEia, as for spctyp(). 00433 * crvalS double* Value of the S-type spectral variable at the reference 00434 * point (i.e. the appropriate CRVALia keyvalue), SI 00435 * units. 00436 * dSdX double* The derivative, dS/dX, evaluated at the reference 00437 * point, SI units. Multiply this by the pixel spacing 00438 * in the X-type spectral coordinate to get the CDELTia 00439 * keyvalue. 00440 * 00441 * Function return value: 00442 * int Status return value: 00443 * 0: Success. 00444 * 2: Invalid spectral parameters. 00445 * 00446 * 00447 * spctrn() - Spectral keyword translation 00448 * --------------------------------------- 00449 * spctrn() translates a set of FITS spectral axis keywords into the 00450 * corresponding set for the specified spectral axis type. For example, a 00451 * 'FREQ' axis may be translated into 'ZOPT-F2W' and vice versa. 00452 * 00453 * Given: 00454 * ctypeS1 const char[9] 00455 * Spectral axis type, i.e. the CTYPEia keyvalue, (eight 00456 * characters with null termination). For non-grism 00457 * axes, the character code for the P-type spectral 00458 * variable in the algorithm code (i.e. the eighth 00459 * character of CTYPEia) may be set to '?' (it will not 00460 * be reset). AIPS-convention spectral types are 00461 * accepted for ctypeS1 but the Doppler frame encoded 00462 * within them will not be used. 00463 * crvalS1 double Value of the S-type spectral variable at the reference 00464 * point, i.e. the CRVALia keyvalue, SI units. 00465 * cdeltS1 double Increment of the S-type spectral variable at the 00466 * reference point, SI units. 00467 * restfrq, 00468 * restwav double Rest frequency [Hz] and rest wavelength in vacuo [m], 00469 * only one of which need be given, the other should be 00470 * set to zero. Neither are required if the translation 00471 * is between wave-characteristic types, or between 00472 * velocity-characteristic types. E.g., required for 00473 * 'FREQ' -> 'ZOPT-F2W', but not required for 00474 * 'VELO-F2V' -> 'ZOPT-F2W'. 00475 * 00476 * Given and returned: 00477 * ctypeS2 char[9] Required spectral axis type (eight characters with 00478 * null termination). The first four characters are 00479 * required to be given and are never modified. The 00480 * remaining four, the algorithm code, are completely 00481 * determined by, and must be consistent with, ctypeS1 00482 * and the first four characters of ctypeS2. A non-zero 00483 * status value will be returned if they are inconsistent 00484 * (see below). However, if the final three characters 00485 * are specified as "???", or if just the eighth 00486 * character is specified as '?', the correct algorithm 00487 * code will be substituted (applies for grism axes as 00488 * well as non-grism). 00489 * 00490 * AIPS-convention spectral types are not accepted for 00491 * ctypeS2. 00492 * 00493 * Returned: 00494 * crvalS2 double* Value of the new S-type spectral variable at the 00495 * reference point, i.e. the new CRVALia keyvalue, SI 00496 * units. 00497 * cdeltS2 double* Increment of the new S-type spectral variable at the 00498 * reference point, i.e. the new CDELTia keyvalue, SI 00499 * units. 00500 * 00501 * Function return value: 00502 * int Status return value: 00503 * 0: Success. 00504 * 2: Invalid spectral parameters. 00505 * 00506 * A status value of 2 will be returned if restfrq or 00507 * restwav are not specified when required, or if ctypeS1 00508 * or ctypeS2 are self-inconsistent, or have different 00509 * spectral X-type variables. 00510 * 00511 * 00512 * spcprm struct - Spectral transformation parameters 00513 * -------------------------------------------------- 00514 * The spcprm struct contains information required to transform spectral 00515 * coordinates. It consists of certain members that must be set by the user 00516 * ("given") and others that are set by the WCSLIB routines ("returned"). Some 00517 * of the latter are supplied for informational purposes while others are for 00518 * internal use only. 00519 * 00520 * int flag 00521 * (Given and returned) This flag must be set to zero whenever any of the 00522 * following spcprm structure members are set or changed: 00523 * 00524 * - spcprm::type, 00525 * - spcprm::code, 00526 * - spcprm::crval, 00527 * - spcprm::restfrq, 00528 * - spcprm::restwav, 00529 * - spcprm::pv[]. 00530 * 00531 * This signals the initialization routine, spcset(), to recompute the 00532 * returned members of the spcprm struct. spcset() will reset flag to 00533 * indicate that this has been done. 00534 * 00535 * char type[8] 00536 * (Given) Four-letter spectral variable type, e.g "ZOPT" for 00537 * CTYPEia = 'ZOPT-F2W'. (Declared as char[8] for alignment reasons.) 00538 * 00539 * char code[4] 00540 * (Given) Three-letter spectral algorithm code, e.g "F2W" for 00541 * CTYPEia = 'ZOPT-F2W'. 00542 * 00543 * double crval 00544 * (Given) Reference value (CRVALia), SI units. 00545 * 00546 * double restfrq 00547 * (Given) The rest frequency [Hz], and ... 00548 * 00549 * double restwav 00550 * (Given) ... the rest wavelength in vacuo [m], only one of which need be 00551 * given, the other should be set to zero. Neither are required if the 00552 * X and S spectral variables are both wave-characteristic, or both 00553 * velocity-characteristic, types. 00554 * 00555 * double pv[7] 00556 * (Given) Grism parameters for 'GRI' and 'GRA' algorithm codes: 00557 * - 0: G, grating ruling density. 00558 * - 1: m, interference order. 00559 * - 2: alpha, angle of incidence [deg]. 00560 * - 3: n_r, refractive index at the reference wavelength, lambda_r. 00561 * - 4: n'_r, dn/dlambda at the reference wavelength, lambda_r (/m). 00562 * - 5: epsilon, grating tilt angle [deg]. 00563 * - 6: theta, detector tilt angle [deg]. 00564 * 00565 * The remaining members of the spcprm struct are maintained by spcset() and 00566 * must not be modified elsewhere: 00567 * 00568 * double w[6] 00569 * (Returned) Intermediate values: 00570 * - 0: Rest frequency or wavelength (SI). 00571 * - 1: The value of the X-type spectral variable at the reference point 00572 * (SI units). 00573 * - 2: dX/dS at the reference point (SI units). 00574 * The remainder are grism intermediates. 00575 * 00576 * int isGrism 00577 * (Returned) Grism coordinates? 00578 * - 0: no, 00579 * - 1: in vacuum, 00580 * - 2: in air. 00581 * 00582 * int padding 00583 * (An unused variable inserted for alignment purposes only.) 00584 * 00585 * int (*spxX2P)(SPX_ARGS) 00586 * (Returned) The first and ... 00587 * int (*spxP2S)(SPX_ARGS) 00588 * (Returned) ... the second of the pointers to the transformation 00589 * functions in the two-step algorithm chain X -> P -> S in the 00590 * pixel-to-spectral direction where the non-linear transformation is from 00591 * X to P. The argument list, SPX_ARGS, is defined in spx.h. 00592 * 00593 * int (*spxS2P)(SPX_ARGS) 00594 * (Returned) The first and ... 00595 * int (*spxP2X)(SPX_ARGS) 00596 * (Returned) ... the second of the pointers to the transformation 00597 * functions in the two-step algorithm chain S -> P -> X in the 00598 * spectral-to-pixel direction where the non-linear transformation is from 00599 * P to X. The argument list, SPX_ARGS, is defined in spx.h. 00600 * 00601 * 00602 * Global variable: const char *spc_errmsg[] - Status return messages 00603 * ------------------------------------------------------------------ 00604 * Error messages to match the status value returned from each function. 00605 * 00606 *===========================================================================*/ 00607 00608 #ifndef WCSLIB_SPC 00609 #define WCSLIB_SPC 00610 00611 #include "spx.h" 00612 00613 #ifdef __cplusplus 00614 extern "C" { 00615 #endif 00616 00617 00618 extern const char *spc_errmsg[]; 00619 00620 00621 struct spcprm { 00622 /* Initialization flag (see the prologue above). */ 00623 /*------------------------------------------------------------------------*/ 00624 int flag; /* Set to zero to force initialization. */ 00625 00626 /* Parameters to be provided (see the prologue above). */ 00627 /*------------------------------------------------------------------------*/ 00628 char type[8]; /* Four-letter spectral variable type. */ 00629 char code[4]; /* Three-letter spectral algorithm code. */ 00630 00631 double crval; /* Reference value (CRVALia), SI units. */ 00632 double restfrq; /* Rest frequency, Hz. */ 00633 double restwav; /* Rest wavelength, m. */ 00634 00635 double pv[7]; /* Grism parameters: */ 00636 /* 0: G, grating ruling density. */ 00637 /* 1: m, interference order. */ 00638 /* 2: alpha, angle of incidence. */ 00639 /* 3: n_r, refractive index at lambda_r. */ 00640 /* 4: n'_r, dn/dlambda at lambda_r. */ 00641 /* 5: epsilon, grating tilt angle. */ 00642 /* 6: theta, detector tilt angle. */ 00643 00644 /* Information derived from the parameters supplied. */ 00645 /*------------------------------------------------------------------------*/ 00646 double w[6]; /* Intermediate values. */ 00647 /* 0: Rest frequency or wavelength (SI). */ 00648 /* 1: CRVALX (SI units). */ 00649 /* 2: CDELTX/CDELTia = dX/dS (SI units). */ 00650 /* The remainder are grism intermediates. */ 00651 00652 int isGrism; /* Grism coordinates? 1: vacuum, 2: air. */ 00653 int padding; /* (Dummy inserted for alignment purposes.) */ 00654 00655 int (*spxX2P)(SPX_ARGS); /* Pointers to the transformation functions */ 00656 int (*spxP2S)(SPX_ARGS); /* in the two-step algorithm chain in the */ 00657 /* pixel-to-spectral direction. */ 00658 00659 int (*spxS2P)(SPX_ARGS); /* Pointers to the transformation functions */ 00660 int (*spxP2X)(SPX_ARGS); /* in the two-step algorithm chain in the */ 00661 /* spectral-to-pixel direction. */ 00662 }; 00663 00664 /* Size of the spcprm struct in int units, used by the Fortran wrappers. */ 00665 #define SPCLEN (sizeof(struct spcprm)/sizeof(int)) 00666 00667 00668 int spcini(struct spcprm *spc); 00669 00670 int spcprt(const struct spcprm *spc); 00671 00672 int spcset(struct spcprm *spc); 00673 00674 int spcx2s(struct spcprm *spc, int nx, int sx, int sspec, 00675 const double x[], double spec[], int stat[]); 00676 00677 int spcs2x(struct spcprm *spc, int nspec, int sspec, int sx, 00678 const double spec[], double x[], int stat[]); 00679 00680 int spctyp(const char ctype[], char stype[], char scode[], char sname[], 00681 char units[], char *ptype, char *xtype, int *restreq); 00682 00683 int spcspx(const char ctypeS[], double crvalS, double restfrq, double restwav, 00684 char *ptype, char *xtype, int *restreq, double *crvalX, 00685 double *dXdS); 00686 00687 int spcxps(const char ctypeS[], double crvalX, double restfrq, double restwav, 00688 char *ptype, char *xtype, int *restreq, double *crvalS, 00689 double *dSdX); 00690 00691 int spctrn(const char ctypeS1[], double crvalS1, double cdeltS1, 00692 double restfrq, double restwav, char ctypeS2[], double *crvalS2, 00693 double *cdeltS2); 00694 00695 00696 /* Deprecated. */ 00697 #define spcini_errmsg spc_errmsg 00698 #define spcprt_errmsg spc_errmsg 00699 #define spcset_errmsg spc_errmsg 00700 #define spcx2s_errmsg spc_errmsg 00701 #define spcs2x_errmsg spc_errmsg 00702 00703 #ifdef __cplusplus 00704 } 00705 #endif 00706 00707 #endif /* WCSLIB_SPC */