spectrum_ops.h

00001 #ifndef SPECTRUM_OPS_H
00002 #define SPECTRUM_OPS_H
00003 
00004 /*******************************************************************************
00005 * E.S.O. - VLT project
00006 *
00007 * "@(#) $Id: spectrum_ops.h,v 1.10 2005/06/07 12:51:09 amodigli Exp $"
00008 *
00009 * who       when      what
00010 * --------  --------  ----------------------------------------------
00011 * schreib  25/05/00  created
00012 */
00013 
00014 /************************************************************************
00015  * spectrum_ops.h
00016  * spectral vector routines
00017  *----------------------------------------------------------------------
00018  */
00019 
00020 #define  SPEED_OF_LIGHT 2.99792458e8
00021 #define  PLANCK         6.62606876e-34
00022 #define  BOLTZMANN      1.3806503e-23
00023 
00024 /*
00025  * header files
00026  */
00027 
00028 /*
00029 #include <stdio.h>
00030 #include <math.h>
00031 #include "spiffi_types.h"
00032 #include "eclipse.h"
00033 #include "recipes.h"
00034 */
00035 #include <qfits.h>
00036 #include <cpl.h>
00037 #include "focus.h"
00038 /*----------------------------------------------------------------------------
00039  *                      Function ANSI C prototypes
00040  *--------------------------------------------------------------------------*/
00041 
00042 
00043 /*----------------------------------------------------------------------------
00044     Function     :       divImageBySpectrum()
00045     In           :       image: resampled image
00046                          spectrum: resampled spectrum in image format
00047     Out          :       resulting image
00048     Job          :       divides a resampled image with a resampled spectrum
00049                          in the same spectral range
00050                          that means all image columns are multiplied with the same spectrum
00051   ---------------------------------------------------------------------------*/
00052 
00053 /*<python>*/
00054 OneImage * divImageBySpectrum( OneImage * image, OneImage * spectrum ) ;
00055 /*</python>*/
00056 
00057 
00058 
00059 /*----------------------------------------------------------------------------
00060    Function     :       newVector()
00061    In           :       number of vector elements
00062    Out          :       vector
00063    Job          :       allocates memory for a new vector
00064  ---------------------------------------------------------------------------*/
00065 
00066 /*<python>*/
00067 Vector * newVector( ulong32 n_elements ) ;
00068 /*</python>*/
00069 
00070 
00071 /*----------------------------------------------------------------------------
00072    Function     :       destroyVector()
00073    In           :       vector to destroy
00074    Out          :       nothing
00075    Job          :       frees memory of a vector
00076  ---------------------------------------------------------------------------*/
00077 
00078 /*<python>*/
00079 void destroyVector( Vector *vector ) ;
00080 /*</python>*/
00081 
00082 /*----------------------------------------------------------------------------
00083    Function     :       vectorToImage()
00084    In           :       spectral vector that should be converted to a fits image
00085    Out          :       image with lx = 1 and ly = length of vector
00086    Job          :       converts a spectral vector to a fits image
00087                         remark: vector object spectrum is destroyed
00088  ---------------------------------------------------------------------------*/
00089 
00090 /*<python>*/
00091 OneImage * vectorToImage( Vector * spectrum ) ;
00092 /*</python>*/
00093 
00094 /*----------------------------------------------------------------------------
00095    Function     :       imageToVector()
00096    In           :       1-D Fits image that should be converted to a spectral vector
00097    Out          :       spectral vector with length ly
00098    Job          :       converts a fits image to a spectral vector
00099                         remark: input image is destroyed
00100  ---------------------------------------------------------------------------*/
00101 
00102 /*<python>*/
00103 Vector * imageToVector( OneImage * spectrum ) ;
00104 /*</python>*/
00105 
00106 
00107 /*----------------------------------------------------------------------------
00108    Function     :       extractSpectrumFromResampledFlat()
00109    In           :       resflat: resampled halogen lamp frame, bad pixel corrected
00110                         loreject, hireject: percentage of extreme low and high intensity values
00111                                             to be rejected from averaging
00112    Out          :       fits image that contains the final halogen lamp spectrum
00113    Job          :       builds one spectrum in a fits image out of a resampled
00114                         flatfield frame by taking a clean mean along the spatial pixels
00115  ---------------------------------------------------------------------------*/
00116 
00117 /*<python>*/
00118 OneImage * extractSpectrumFromResampledFlat( OneImage * resflat,
00119                                              float      loreject,
00120                                              float      hireject ) ;
00121 /*</python>*/
00122 
00123 /*----------------------------------------------------------------------------
00124    Function     :       multiplyImageWithSpectrum()
00125    In           :       image: resampled image
00126                         spectrum: resampled spectrum in image format
00127    Out          :       resulting image
00128    Job          :       multiplys a resampled image with a resampled spectrum
00129                         (calibrated halogen lamp spectrum) in the same spectral range
00130                         that means all image columns are multiplied with the same spectrum
00131  ---------------------------------------------------------------------------*/
00132 
00133 /*<python>*/
00134 OneImage * multiplyImageWithSpectrum( OneImage * image, OneImage * spectrum ) ;
00135 /*</python>*/
00136 
00137 /*----------------------------------------------------------------------------
00138    Function     :       optimalExtractionFromCube()
00139    In           :       cube: input data cube
00140                         llx, lly: lower left edge point of 2d Gaussian fitting box.
00141                         halfbox_x, halfbox_y: half width of a box inside which
00142                                               a 2D-Gaussian fit is carried out
00143                         fwhm_factor: factor applied to the found fwhms of a 2D-Gaussian
00144                                      fit, defines the radius of the aperture inside which the
00145                                      spectral extraction is carried out (default: 0.6).
00146                         backvariance: (readnoise^2 + dark current variance) needed to determine
00147                                       the noise variance of the background. Must be given
00148                                       in counts/sec.
00149                         sky:         estimated sky variance in counts/sec
00150                         gain:        conversion factor electrons/count
00151                         exptime:     total exposure time
00152    Out          :       resulting spectrum stored in a 1D-image
00153    Job          :       does the optimal extraction of a standard star spectrum
00154                         according to the equation:
00155                         S = sum { (P^2 / V) * (I - B) / P } / sum{ P^2 / V }
00156                         S: spectral flux at a particular wavelength
00157                         P: normalized PSF (determined by a 2D-Gaussian fit)
00158                         I: pixel value
00159                         B: background pixel value determined by the background parameter of the 2D-Gaussian fit
00160                         V: estimated variance of a pixel: V = [R^2 + D + sky + I,c/exptime]/gain
00161                            where R is the read noise, and D the dark current variance.
00162                            backvariance is R^2 + D in counts/sec. I,c is the source intensity in counts
00163                         Remember: sigma,e[e-] = gain[e/count] * sigma,c [counts] = sqrt(I,e) = sqrt(gain*I,c)
00164                         => V,c = sigma,c^2 = sigma,e^2/gain^2
00165                         => sigma,c = sqrt(I,c/gain) => V,c = I,c/gain
00166  ---------------------------------------------------------------------------*/
00167 
00168 /*<python>*/
00169 OneImage * optimalExtractionFromCube( OneCube * cube,
00170                                       int llx,
00171                                       int lly,
00172                                       int halfbox_x,
00173                                       int halfbox_y,
00174                                       float fwhm_factor,
00175                                       float backvariance,
00176                                       float sky,
00177                                       float gain,
00178                                       float exptime,
00179                                       const char* name,
00180                                       cpl_table** spectrum,
00181                                       int qc_info,
00182                                       int* check2) ;
00183 /*</python>*/
00184 
00185 /*----------------------------------------------------------------------------
00186    Function     :       extractSkyFromCube()
00187    In           :       cube: reduced cube from sky spider observation
00188                         loReject, hiReject: fraction (percentage) of the extreme high and low
00189                                             sky spectrum values that are rejected before
00190                                             averaging the found sky spectra.
00191                         position: end pixel positions of the straight line in the image
00192                                   dividing the sky from the object pixels.
00193                         tolerance: pixel tolerance which are not considered and subtracted from
00194                                    the diagonal line to be sure to get a clean sky, default: 2
00195                         posindicator: indicates in which edge of the field of view the sky is projected. 
00196                                       output of spiffi_get_spiderposindex() in fitshead.c
00197    Out          :       resulting averaged sky spectrum
00198    Job          :       extracts a sky spectrum from a reduced sky spider observation, that
00199                         means from a data cube. Therefore, the position of the sky within the
00200                         field of view must be first read from the fits header. A pixel tolerance is
00201                         subtracted.
00202                         The found sky spectra are averaged by rejecting the extreme high and low values.
00203  ---------------------------------------------------------------------------*/
00204 
00205 /*<python>*/
00206 Vector * extractSkyFromCube( OneCube * cube,
00207                              float     loReject,
00208                              float     hiReject,
00209                              int     * position,
00210                              int       tolerance,
00211                              int       posindicator ) ;
00212 /*</python>*/
00213 
00214 /*---------------------------------------------------------------------------
00215    Function     :       sumRectangleOfCubeSpectra()
00216    In           :       cube: 1 allocated cube,
00217                         llx, lly, urx, ury: lower left and upper right
00218                                             position of rectangle in x-y plane ,
00219                                             image coordinates 0...
00220    Out          :       result spectrum vector
00221    Job          :       averaging routine for a reduced data to get a better spectral S/N
00222                         only for a rectangular aperture.
00223  ---------------------------------------------------------------------------*/
00224 
00225 /*<python>*/
00226 Vector * sumRectangleOfCubeSpectra( OneCube * cube,
00227                                      int llx,
00228                                      int lly,
00229                                      int urx,
00230                                      int ury ) ;
00231 /*</python>*/
00232 
00233 /*---------------------------------------------------------------------------
00234    Function     :       sumCircleOfCubeSpectra()
00235    In           :       cube: 1 allocated cube,
00236                         centerx, centery: center pixel of circular aperture
00237                                           in image coordinates
00238                         radius: integer radius of circular aperture
00239    Out          :       result spectrum vector
00240    Job          :       averaging routine for a reduced data to get a better spectral S/N
00241                         only for a circular aperture.
00242  ---------------------------------------------------------------------------*/
00243 
00244 /*<python>*/
00245 Vector * sumCircleOfCubeSpectra( OneCube * cube,
00246                                   int       centerx,
00247                                   int       centery,
00248                                   int       radius ) ;
00249 /*</python>*/
00250 
00251 
00252 /*---------------------------------------------------------------------------
00253    Function     :       meanRectangleOfCubeSpectra()
00254    In           :       cube: 1 allocated cube,
00255                         llx, lly, urx, ury: lower left and upper right
00256                                             position of rectangle in x-y plane ,
00257                                             image coordinates 0...
00258    Out          :       result spectrum vector
00259    Job          :       averaging routine for a reduced data to get a better spectral S/N
00260                         only for a rectangular aperture.
00261  ---------------------------------------------------------------------------*/
00262 
00263 /*<python>*/
00264 Vector * meanRectangleOfCubeSpectra( OneCube * cube,
00265                                      int llx,
00266                                      int lly,
00267                                      int urx,
00268                                      int ury ) ;
00269 /*</python>*/
00270 
00271 /*---------------------------------------------------------------------------
00272    Function     :       meanCircleOfCubeSpectra()
00273    In           :       cube: 1 allocated cube,
00274                         centerx, centery: center pixel of circular aperture
00275                                           in image coordinates
00276                         radius: integer radius of circular aperture
00277    Out          :       result spectrum vector
00278    Job          :       averaging routine for a reduced data to get a better spectral S/N
00279                         only for a circular aperture.
00280  ---------------------------------------------------------------------------*/
00281 
00282 /*<python>*/
00283 Vector * meanCircleOfCubeSpectra( OneCube * cube,
00284                                   int       centerx,
00285                                   int       centery,
00286                                   int       radius ) ;
00287 /*</python>*/
00288 
00289 /*---------------------------------------------------------------------------
00290    Function     :       blackbodySpectrum()
00291    In           :       templateSpec: spectrum of a standard star
00292                         (1-d image with fits header)
00293                         temp: blackbody temperature in Kelvin (standard Star temp),
00294    Out          :       resulting spectrum vector
00295    Job          :       computes a blackbody spectral intensity distribution
00296                         (W/(m^2 lambda ster))
00297  ---------------------------------------------------------------------------*/
00298 
00299 /*<python>*/
00300 Vector * blackbodySpectrum( char * templateSpec, double temp ) ;
00301 /*</python>*/
00302 
00303 /*---------------------------------------------------------------------------
00304    Function     :       medianRectangleOfCubeSpectra()
00305    In           :       cube: 1 allocated cube,
00306                         llx, lly, urx, ury: lower left and upper right
00307                                             position of rectangle in x-y plane ,
00308                                             image coordinates 0...
00309    Out          :       result spectrum vector
00310    Job          :       averaging routine for a reduced data to get a better spectral S/N
00311                         only for a rectangular aperture.
00312  ---------------------------------------------------------------------------*/
00313 
00314 /*<python>*/
00315 Vector * medianRectangleOfCubeSpectra( OneCube * cube,
00316                                              int llx,
00317                                              int lly,
00318                                              int urx,
00319                                              int ury ) ;
00320 /*</python>*/
00321 
00322 /*---------------------------------------------------------------------------
00323    Function     :       medianCircleOfCubeSpectra()
00324    In           :       cube: 1 allocated cube,
00325                         centerx, centery: center pixel of circular aperture
00326                                           in image coordinates
00327                         radius: integer radius of circular aperture
00328    Out          :       result spectrum vector
00329    Job          :       averaging routine for a reduced data to get a better spectral S/N
00330                         only for a circular aperture.
00331  ---------------------------------------------------------------------------*/
00332 
00333 /*<python>*/
00334 Vector * medianCircleOfCubeSpectra( OneCube * cube,
00335                                   int       centerx,
00336                                   int       centery,
00337                                   int       radius ) ;
00338 /*</python>*/
00339 
00340 
00341 /*---------------------------------------------------------------------------
00342    Function     :       cleanmeanRectangleOfCubeSpectra()
00343    In           :       cube: 1 allocated cube,
00344                         llx, lly, urx, ury: lower left and upper right
00345                                             position of rectangle in x-y plane ,
00346                                             image coordinates 0...
00347    Out          :       result spectrum vector
00348    Job          :       averaging routine for a reduced data to get a better spectral S/N
00349                         only for a rectangular aperture.
00350  ---------------------------------------------------------------------------*/
00351 
00352 /*<python>*/
00353 Vector * cleanmeanRectangleOfCubeSpectra( OneCube * cube,
00354                                              int llx,
00355                                              int lly,
00356                                              int urx,
00357                                              int ury,
00358                                              float lo_reject,
00359                                              float hi_reject ) ;
00360 /*</python>*/
00361 
00362 /*---------------------------------------------------------------------------
00363    Function     :       cleanmeanCircleOfCubeSpectra()
00364    In           :       cube: 1 allocated cube,
00365                         centerx, centery: center pixel of circular aperture
00366                                           in image coordinates
00367                         radius: integer radius of circular aperture
00368    Out          :       result spectrum vector
00369    Job          :       averaging routine for a reduced data to get a better spectral S/N
00370                         only for a circular aperture.
00371  ---------------------------------------------------------------------------*/
00372 
00373 /*<python>*/
00374 Vector * cleanmeanCircleOfCubeSpectra( OneCube * cube,
00375                                   int       centerx,
00376                                   int       centery,
00377                                   int       radius,
00378                                   float     lo_reject,
00379                                   float     hi_reject ) ;
00380 /*</python>*/
00381 
00382 /*---------------------------------------------------------------------------
00383    Function     :       shiftArray()
00384    In           :       input: input array,
00385                         n_elements: number of elements in input array
00386                         shift: sub-pixel shift value (must be < 1.)
00387                         ker:    interpolation kernel
00388    Out          :       resulting float array
00389    Job          :       shifts an array by a sub-pixel shift value using a tanh
00390                         interpolation kernel
00391  ---------------------------------------------------------------------------*/
00392 
00393 /*<python>*/
00394 float * shiftArray ( float * input, int n_elements, float shift, double * ker ) ;
00395 /*</python>*/
00396 
00397 
00398 
00399 #endif 
00401 /*--------------------------------------------------------------------------*/

Generated on Wed Oct 26 13:08:55 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001