spx.h

Go to the documentation of this file.
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: spx_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 spx routines
00049 * ---------------------------
00050 * specx() is a scalar routine that, given one spectral variable (e.g.
00051 * frequency), computes all the others (e.g. wavelength, velocity, etc.) plus
00052 * the required derivatives of each with respect to the others.  The results
00053 * are returned in the spxprm struct.
00054 *
00055 * The remaining routines are all vector conversions from one spectral
00056 * variable to another.  The API of these functions only differ in whether the
00057 * rest frequency or wavelength need be supplied.
00058 *
00059 * Non-linear:
00060 *   - freqwave()    frequency              ->  vacuum wavelength
00061 *   - wavefreq()    vacuum wavelength      ->  frequency
00062 *
00063 *   - freqawav()    frequency              ->  air wavelength
00064 *   - awavfreq()    air wavelength         ->  frequency
00065 *
00066 *   - freqvelo()    frequency              ->  relativistic velocity
00067 *   - velofreq()    relativistic velocity  ->  frequency
00068 *
00069 *   - waveawav()    vacuum wavelength      ->  air wavelength
00070 *   - awavwave()    air wavelength         ->  vacuum wavelength
00071 *
00072 *   - wavevelo()    vacuum wavelength      ->  relativistic velocity
00073 *   - velowave()    relativistic velocity  ->  vacuum wavelength
00074 *
00075 *   - awavvelo()    air wavelength         ->  relativistic velocity
00076 *   - veloawav()    relativistic velocity  ->  air wavelength
00077 *
00078 * Linear:
00079 *   - freqafrq()    frequency              ->  angular frequency
00080 *   - afrqfreq()    angular frequency      ->  frequency
00081 *
00082 *   - freqener()    frequency              ->  energy
00083 *   - enerfreq()    energy                 ->  frequency
00084 *
00085 *   - freqwavn()    frequency              ->  wave number
00086 *   - wavnfreq()    wave number            ->  frequency
00087 *
00088 *   - freqvrad()    frequency              ->  radio velocity
00089 *   - vradfreq()    radio velocity         ->  frequency
00090 *
00091 *   - wavevopt()    vacuum wavelength      ->  optical velocity
00092 *   - voptwave()    optical velocity       ->  vacuum wavelength
00093 *
00094 *   - wavezopt()    vacuum wavelength      ->  redshift
00095 *   - zoptwave()    redshift               ->  vacuum wavelength
00096 *
00097 *   - velobeta()    relativistic velocity  ->  beta (= v/c)
00098 *   - betavelo()    beta (= v/c)           ->  relativistic velocity
00099 *
00100 * These are the workhorse routines, to be used for fast transformations.
00101 * Conversions may be done "in place" by calling the routine with the output
00102 * vector set to the input.
00103 *
00104 * Argument checking:
00105 * ------------------
00106 * The input spectral values are only checked for values that would result
00107 * in floating point exceptions.  In particular, negative frequencies and
00108 * wavelengths are allowed, as are velocities greater than the speed of
00109 * light.  The same is true for the spectral parameters - rest frequency and
00110 * wavelength.
00111 *
00112 * Accuracy:
00113 * ---------
00114 * No warranty is given for the accuracy of these routines (refer to the
00115 * copyright notice); intending users must satisfy for themselves their
00116 * adequacy for the intended purpose.  However, closure effectively to within
00117 * double precision rounding error was demonstrated by test routine tspec.c
00118 * which accompanies this software.
00119 *
00120 *
00121 * specx() - Spectral cross conversions (scalar)
00122 * ---------------------------------------------
00123 * Given one spectral variable specx() computes all the others, plus the
00124 * required derivatives of each with respect to the others.
00125 *
00126 * Given:
00127 *   type      const char*
00128 *                       The type of spectral variable given by spec, FREQ,
00129 *                       AFRQ, ENER, WAVN, VRAD, WAVE, VOPT, ZOPT, AWAV, VELO,
00130 *                       or BETA (case sensitive).
00131 *   spec      double    The spectral variable given, in SI units.
00132 *   restfrq,
00133 *   restwav   double    Rest frequency [Hz] or rest wavelength in vacuo [m],
00134 *                       only one of which need be given.  The other should be
00135 *                       set to zero.  If both are zero, only a subset of the
00136 *                       spectral variables can be computed, the remainder are
00137 *                       set to zero.  Specifically, given one of FREQ, AFRQ,
00138 *                       ENER, WAVN, WAVE, or AWAV the others can be computed
00139 *                       without knowledge of the rest frequency.  Likewise,
00140 *                       VRAD, VOPT, ZOPT, VELO, and BETA.
00141 *
00142 * Given and returned:
00143 *   specs     struct spxprm*
00144 *                       Data structure containing all spectral variables and
00145 *                       their derivatives, in SI units.
00146 *
00147 * Function return value:
00148 *             int       Status return value:
00149 *                         0: Success.
00150 *                         1: Null spxprm pointer passed.
00151 *                         2: Invalid spectral parameters.
00152 *                         3: Invalid spectral variable.
00153 *
00154 *
00155 * freqafrq(), afrqfreq(), freqener(), enerfreq(), freqwavn(), wavnfreq(),
00156 * freqwave(), wavefreq(), freqawav(), awavfreq(), waveawav(), awavwave(),
00157 * velobeta(), and betavelo() implement vector conversions between wave-like
00158 * or velocity-like spectral types (i.e. conversions that do not need the rest
00159 * frequency or wavelength).  They all have the same API.
00160 *
00161 *
00162 * freqafrq() - Convert frequency to angular frequency (vector)
00163 * ------------------------------------------------------------
00164 * freqafrq() converts frequency to angular frequency.
00165 *
00166 * Given:
00167 *   param     double    Ignored.
00168 *   nspec     int       Vector length.
00169 *   instep,
00170 *   outstep   int       Vector strides.
00171 *   inspec    const double[]
00172 *                       Input spectral variables, in SI units.
00173 *
00174 * Returned:
00175 *   outspec   double[]  Output spectral variables, in SI units.
00176 *   stat      int[]     Status return value for each vector element:
00177 *                         0: Success.
00178 *                         1: Invalid value of inspec.
00179 *
00180 * Function return value:
00181 *             int       Status return value:
00182 *                         0: Success.
00183 *                         2: Invalid spectral parameters.
00184 *                         4: One or more of the inspec coordinates were
00185 *                            invalid, as indicated by the stat vector.
00186 *
00187 *
00188 * freqvelo(), velofreq(), freqvrad(), and vradfreq() implement vector
00189 * conversions between frequency and velocity spectral types.  They all have
00190 * the same API.
00191 *
00192 *
00193 * freqvelo() - Convert frequency to relativistic velocity (vector)
00194 * ----------------------------------------------------------------
00195 * freqvelo() converts frequency to relativistic velocity.
00196 *
00197 * Given:
00198 *   param     double    Rest frequency [Hz].
00199 *   nspec     int       Vector length.
00200 *   instep,
00201 *   outstep   int       Vector strides.
00202 *   inspec    const double[]
00203 *                       Input spectral variables, in SI units.
00204 *
00205 * Returned:
00206 *   outspec   double[]  Output spectral variables, in SI units.
00207 *   stat      int[]     Status return value for each vector element:
00208 *                         0: Success.
00209 *                         1: Invalid value of inspec.
00210 *
00211 * Function return value:
00212 *             int       Status return value:
00213 *                         0: Success.
00214 *                         2: Invalid spectral parameters.
00215 *                         4: One or more of the inspec coordinates were
00216 *                            invalid, as indicated by the stat vector.
00217 *
00218 *
00219 * wavevelo(), velowave(), awavvelo(), veloawav(), wavevopt(), voptwave(),
00220 * wavezopt(), and zoptwave() implement vector conversions between wavelength
00221 * and velocity spectral types.  They all have the same API.
00222 *
00223 *
00224 * wavevelo() - Conversions between wavelength and velocity types (vector)
00225 * -----------------------------------------------------------------------
00226 * wavevelo() converts vacuum wavelength to relativistic velocity.
00227 *
00228 * Given:
00229 *   param     double    Rest wavelength in vacuo [m].
00230 *   nspec     int       Vector length.
00231 *   instep,
00232 *   outstep   int       Vector strides.
00233 *   inspec    const double[]
00234 *                       Input spectral variables, in SI units.
00235 *
00236 * Returned:
00237 *   outspec   double[]  Output spectral variables, in SI units.
00238 *   stat      int[]     Status return value for each vector element:
00239 *                         0: Success.
00240 *                         1: Invalid value of inspec.
00241 *
00242 * Function return value:
00243 *             int       Status return value:
00244 *                         0: Success.
00245 *                         2: Invalid spectral parameters.
00246 *                         4: One or more of the inspec coordinates were
00247 *                            invalid, as indicated by the stat vector.
00248 *
00249 *
00250 * spxprm struct - Spectral variables and their derivatives
00251 * --------------------------------------------------------
00252 * The spxprm struct contains the value of all spectral variables and their
00253 * derivatives.   It is used solely by specx() which constructs it from
00254 * information provided via its function arguments.
00255 *
00256 * This struct should be considered read-only, no members need ever be set nor
00257 * should ever be modified by the user.
00258 *
00259 *   double restfrq
00260 *     (Returned) Rest frequency [Hz].
00261 *
00262 *   double restwav
00263 *     (Returned) Rest wavelength [m].
00264 *
00265 *   int wavetype
00266 *     (Returned) True if wave types have been computed, and ...
00267 *
00268 *   int velotype
00269 *     (Returned) ... true if velocity types have been computed; types are
00270 *     defined below.
00271 *
00272 *     If one or other of spxprm::restfrq and spxprm::restwav is given
00273 *     (non-zero) then all spectral variables may be computed.  If both are
00274 *     given, restfrq is used.  If restfrq and restwav are both zero, only wave
00275 *     characteristic xor velocity type spectral variables may be computed
00276 *     depending on the variable given.   These flags indicate what is
00277 *     available.
00278 *
00279 *   double freq
00280 *     (Returned) Frequency [Hz] (wavetype).
00281 *
00282 *   double afrq
00283 *     (Returned) Angular frequency [rad/s] (wavetype).
00284 *
00285 *   double ener
00286 *     (Returned) Photon energy [J] (wavetype).
00287 *
00288 *   double wavn
00289 *     (Returned) Wave number [/m] (wavetype).
00290 *
00291 *   double vrad
00292 *     (Returned) Radio velocity [m/s] (velotype).
00293 *
00294 *   double wave
00295 *     (Returned) Vacuum wavelength [m] (wavetype).
00296 *
00297 *   double vopt
00298 *     (Returned) Optical velocity [m/s] (velotype).
00299 *
00300 *   double zopt
00301 *     (Returned) Redshift [dimensionless] (velotype).
00302 *
00303 *   double awav
00304 *     (Returned) Air wavelength [m] (wavetype).
00305 *
00306 *   double velo
00307 *     (Returned) Relativistic velocity [m/s] (velotype).
00308 *
00309 *   double beta
00310 *     (Returned) Relativistic beta [dimensionless] (velotype).
00311 *
00312 *   double dfreqafrq
00313 *     (Returned) Derivative of frequency with respect to angular frequency
00314 *     [/rad] (constant, = 1 / 2*pi), and ...
00315 *   double dafrqfreq
00316 *     (Returned) ... vice versa [rad] (constant, = 2*pi, always available).
00317 *
00318 *   double dfreqener
00319 *     (Returned) Derivative of frequency with respect to photon energy
00320 *     [/J/s] (constant, = 1/h), and ...
00321 *   double denerfreq
00322 *     (Returned) ... vice versa [Js] (constant, = h, Planck's constant,
00323 *     always available).
00324 *
00325 *   double dfreqwavn
00326 *     (Returned) Derivative of frequency with respect to wave number [m/s]
00327 *     (constant, = c, the speed of light in vacuuo), and ...
00328 *   double dwavnfreq
00329 *     (Returned) ... vice versa [s/m] (constant, = 1/c, always available).
00330 *
00331 *   double dfreqvrad
00332 *     (Returned) Derivative of frequency with respect to radio velocity [/m],
00333 *     and ...
00334 *   double dvradfreq
00335 *     (Returned) ... vice versa [m] (wavetype && velotype).
00336 *
00337 *   double dfreqwave
00338 *     (Returned) Derivative of frequency with respect to vacuum wavelength
00339 *     [/m/s], and ...
00340 *   double dwavefreq
00341 *     (Returned) ... vice versa [m s] (wavetype).
00342 *
00343 *   double dfreqawav
00344 *     (Returned) Derivative of frequency with respect to air wavelength,
00345 *     [/m/s], and ...
00346 *   double dawavfreq
00347 *     (Returned) ... vice versa [m s] (wavetype).
00348 *
00349 *   double dfreqvelo
00350 *     (Returned) Derivative of frequency with respect to relativistic
00351 *     velocity [/m], and ...
00352 *   double dvelofreq
00353 *     (Returned) ... vice versa [m] (wavetype && velotype).
00354 *
00355 *   double dwavevopt
00356 *     (Returned) Derivative of vacuum wavelength with respect to optical
00357 *     velocity [s], and ...
00358 *   double dvoptwave
00359 *     (Returned) ... vice versa [/s] (wavetype && velotype).
00360 *
00361 *   double dwavezopt
00362 *     (Returned) Derivative of vacuum wavelength with respect to redshift [m],
00363 *     and ...
00364 *   double dzoptwave
00365 *     (Returned) ... vice versa [/m] (wavetype && velotype).
00366 *
00367 *   double dwaveawav
00368 *     (Returned) Derivative of vacuum wavelength with respect to air
00369 *     wavelength [dimensionless], and ...
00370 *   double dawavwave
00371 *     (Returned) ... vice versa [dimensionless] (wavetype).
00372 *
00373 *   double dwavevelo
00374 *     (Returned) Derivative of vacuum wavelength with respect to relativistic
00375 *     velocity [s], and ...
00376 *   double dvelowave
00377 *     (Returned) ... vice versa [/s] (wavetype && velotype).
00378 *
00379 *   double dawavvelo
00380 *     (Returned) Derivative of air wavelength with respect to relativistic
00381 *     velocity [s], and ...
00382 *   double dveloawav
00383 *     (Returned) ... vice versa [/s] (wavetype && velotype).
00384 *
00385 *   double dvelobeta
00386 *     (Returned) Derivative of relativistic velocity with respect to
00387 *     relativistic beta [m/s] (constant, = c, the speed of light in vacuu0),
00388 *     and ...
00389 *   double dbetavelo
00390 *     (Returned) ... vice versa [s/m] (constant, = 1/c, always available).
00391 *
00392 *
00393 * Global variable: const char *spx_errmsg[] - Status return messages
00394 * ------------------------------------------------------------------
00395 * Error messages to match the status value returned from each function.
00396 *
00397 *===========================================================================*/
00398 
00399 #ifndef WCSLIB_SPEC
00400 #define WCSLIB_SPEC
00401 
00402 #ifdef __cplusplus
00403 extern "C" {
00404 #endif
00405 
00406 
00407 extern const char *spx_errmsg[];
00408 
00409 
00410 struct spxprm {
00411   double restfrq, restwav;      /* Rest frequency [Hz] and wavelength [m].  */
00412 
00413   int wavetype, velotype;       /* True if wave/velocity types have been    */
00414                                 /* computed; types are defined below.       */
00415 
00416   /* Spectral variables computed by specx().                                */
00417   /*------------------------------------------------------------------------*/
00418   double freq,                  /* wavetype: Frequency [Hz].                */
00419          afrq,                  /* wavetype: Angular frequency [rad/s].     */
00420          ener,                  /* wavetype: Photon energy [J].             */
00421          wavn,                  /* wavetype: Wave number [/m].              */
00422          vrad,                  /* velotype: Radio velocity [m/s].          */
00423          wave,                  /* wavetype: Vacuum wavelength [m].         */
00424          vopt,                  /* velotype: Optical velocity [m/s].        */
00425          zopt,                  /* velotype: Redshift.                      */
00426          awav,                  /* wavetype: Air wavelength [m].            */
00427          velo,                  /* velotype: Relativistic velocity [m/s].   */
00428          beta;                  /* velotype: Relativistic beta.             */
00429 
00430   /* Derivatives of spectral variables computed by specx().                 */
00431   /*------------------------------------------------------------------------*/
00432   double dfreqafrq, dafrqfreq,  /* Constant, always available.              */
00433          dfreqener, denerfreq,  /* Constant, always available.              */
00434          dfreqwavn, dwavnfreq,  /* Constant, always available.              */
00435          dfreqvrad, dvradfreq,  /* wavetype && velotype.                    */
00436          dfreqwave, dwavefreq,  /* wavetype.                                */
00437          dfreqawav, dawavfreq,  /* wavetype.                                */
00438          dfreqvelo, dvelofreq,  /* wavetype && velotype.                    */
00439          dwavevopt, dvoptwave,  /* wavetype && velotype.                    */
00440          dwavezopt, dzoptwave,  /* wavetype && velotype.                    */
00441          dwaveawav, dawavwave,  /* wavetype.                                */
00442          dwavevelo, dvelowave,  /* wavetype && velotype.                    */
00443          dawavvelo, dveloawav,  /* wavetype && velotype.                    */
00444          dvelobeta, dbetavelo;  /* Constant, always available.              */
00445 };
00446 
00447 /* Size of the spxprm struct in int units, used by the Fortran wrappers. */
00448 #define SPXLEN (sizeof(struct spxprm)/sizeof(int))
00449 
00450 
00451 int specx(const char *type, double spec, double restfrq, double restwav,
00452           struct spxprm *specs);
00453 
00454 
00455 /* For use in declaring function prototypes, e.g. in spcprm. */
00456 #define SPX_ARGS double param, int nspec, int instep, int outstep, \
00457                  const double inspec[], double outspec[], int stat[]
00458 
00459 int freqafrq(SPX_ARGS);
00460 int afrqfreq(SPX_ARGS);
00461 
00462 int freqener(SPX_ARGS);
00463 int enerfreq(SPX_ARGS);
00464 
00465 int freqwavn(SPX_ARGS);
00466 int wavnfreq(SPX_ARGS);
00467 
00468 int freqwave(SPX_ARGS);
00469 int wavefreq(SPX_ARGS);
00470 
00471 int freqawav(SPX_ARGS);
00472 int awavfreq(SPX_ARGS);
00473 
00474 int waveawav(SPX_ARGS);
00475 int awavwave(SPX_ARGS);
00476 
00477 int velobeta(SPX_ARGS);
00478 int betavelo(SPX_ARGS);
00479 
00480 
00481 int freqvelo(SPX_ARGS);
00482 int velofreq(SPX_ARGS);
00483 
00484 int freqvrad(SPX_ARGS);
00485 int vradfreq(SPX_ARGS);
00486 
00487 
00488 int wavevelo(SPX_ARGS);
00489 int velowave(SPX_ARGS);
00490 
00491 int awavvelo(SPX_ARGS);
00492 int veloawav(SPX_ARGS);
00493 
00494 int wavevopt(SPX_ARGS);
00495 int voptwave(SPX_ARGS);
00496 
00497 int wavezopt(SPX_ARGS);
00498 int zoptwave(SPX_ARGS);
00499 
00500 
00501 #ifdef __cplusplus
00502 }
00503 #endif
00504 
00505 #endif /* WCSLIB_SPEC */

Generated on Mon Sep 14 17:03:55 2009 for WCSLIB 4.4 by  doxygen 1.5.1