wavecal.h

00001 #ifndef WAVECAL_H
00002 #define WAVE_CAL_H
00003 /*******************************************************************************
00004 * E.S.O. - VLT project
00005 *
00006 * "@(#) $Id: wavecal.h,v 1.6 2005/04/19 11:29:53 amodigli Exp $"
00007 *
00008 * who       when      what
00009 * --------  --------  ----------------------------------------------
00010 * schreib  13/07/00  created
00011 */
00012 
00013 /************************************************************************
00014  * wavecal.h
00015  * routines needed for wavelength calibration
00016  *----------------------------------------------------------------------
00017  */
00018 
00019 /*
00020  * header files
00021  */
00022 
00023 /*
00024 #include <stdio.h>
00025 #include <inttypes.h> 
00026 #include <string.h>
00027 #include <math.h>
00028 #include "recipes.h"
00029 #include "eclipse.h"
00030 */
00031 #include <qfits.h>
00032 #include <cpl.h>
00033 #include "spectrum_ops.h"
00034 
00035 
00036 /*
00037  * function prototypes
00038  */
00039 
00040 /*----------------------------------------------------------------------------
00041    Function     :       waveMapSlit()
00042    In           :       acoefs: fit coefficient matrix: output of coeffsCrossSlitFit()
00043                         n_acoefs: number of acoefs, polynomial order + 1
00044                         n_rows: number of final image rows
00045                         n_columns: number of final image columns
00046    Out          :       wavemap calibration map image
00047  ---------------------------------------------------------------------------*/
00048 
00049 OneImage * waveMapSlit ( float ** acoefs,
00050                          int      n_acoefs,
00051                          int      n_rows,
00052                          int      n_columns ) ;
00053 
00054 /*----------------------------------------------------------------------------
00055    Function     :       waveCal()
00056    In           :       image:        merged image from a calibration emission lamp,
00057                         par:          fit parameters data structure storage
00058                         abuf:         buffer array for fit coefficients abuf[index][column]
00059                         row_clean: resulting list of the row indices but without the
00060                                    lines that are too close to each other for the fit
00061                                    output of findLines()
00062                         wavelength_clean: corrected wavelength list corresponding to
00063                                           the row_clean array
00064                                           output of findLines()
00065                         n_found_lines: output of findLines(): total number of found emission lines
00066                         dispersion:   dispersion of spectrum: micron per pixel
00067                         halfWidth:    half width of the box where the line must sit
00068                         minAmplitude: minimum amplitude of the Gaussian to do the fit
00069                         max_residual: maximum residual value, beyond that value
00070                                       the polynomial lambda-position fit is rejected.
00071                         fwhm:         first guess for the full width of half maximum
00072                                       of the gaussian line fit
00073                         n_a_fitcoefs: number of fit coefficients for the single
00074                                       column fits: lambda-position
00075                         n_b_fitcoefs: number of fit coefficients for the fits of
00076                                       the single a coefficients across the columns
00077                         sigmaFactor:  factor of the standard deviation of the determined
00078                                       polynomial coefficients of the columns beyond
00079                                       which these coefficients are not used to carry out
00080                                       the polynomial fit across the columns.
00081                         pixel_dist:   estimate of minimal pixel distance in spectral direction between slitlets
00082             pixel_tolerance: maximum tolerated difference between estimated
00083                      and fitted line positions.
00084    Out          :       wavelength map image.
00085                         abuf: array of smoothed coefficients of the polynomial fit along the columns:
00086                               abuf[index][column].
00087                         par: array of the resulting FitParams data structure
00088    Job          :       this routine takes an image from a calibration
00089                         emission lamp and delivers the smoothed fit coefficients of
00090                         a polynomial fit along the columns of the line positions as output.
00091                         This routine expects Nyquist sampled spectra
00092                         (either an interleaved image or an image convolved with an
00093                          appropriate function in spectral direction)
00094  ---------------------------------------------------------------------------*/
00095 /*<python>*/
00096 OneImage * waveCal( OneImage   * image,
00097                     FitParams ** par ,
00098                     float     ** abuf,
00099                     int          n_slitlets,
00100                     int       ** row_clean,
00101                     float     ** wavelength_clean,
00102                     int        * n_found_lines,
00103                     float        dispersion,
00104                     int          halfWidth,
00105                     float        minAmplitude,
00106                     float        max_residual,
00107                     float        fwhm,
00108                     int          n_a_fitcoefs,
00109                     int          n_b_fitcoefs,
00110                     float        sigmaFactor,
00111                     float        pixel_dist,
00112             float        pixel_tolerance ) ;
00113 /*</python>*/
00114 
00115 
00116  OneImage * spred_waveCal( OneImage   * image,
00117                      FitParams ** par ,
00118                      float     ** abuf,
00119                      int          n_slitlets,
00120                      int       ** row_clean,
00121                      float     ** wavelength_clean,
00122                      int        * n_found_lines,
00123                      float        dispersion,
00124                      int          halfWidth,
00125                      float        minAmplitude,
00126                      float        max_residual,
00127                      float        fwhm,
00128                      int          n_a_fitcoefs,
00129                      int          n_b_fitcoefs,
00130                      float        sigmaFactor,
00131                      float        pixel_dist,
00132                      float        pixel_tolerance,
00133                      float **slit_pos ) ;
00134 
00135 
00136 /*----------------------------------------------------------------------------
00137    Function     :       checkForFakeLines()
00138    In           :       par: array of the fit parameter data structure FitParams
00139                         dispersion: estimated dispersion
00140                         wavelength_clean: corrected wavelength list
00141                         row_clean: corrected row list corresponding to the wavelength list
00142                 n_found_lines: array of numbers of found lines of each column
00143             n_columns: total number of image columns
00144             pixel_tolerance: maximum tolerated difference between estimated
00145                      and fitted line positions.
00146    Out          :       par: corrected FitParams
00147                         0 in case of success
00148             -1 in case of error
00149    Job          :       this routine searches for successfully fitted fake lines like
00150                     bad pixels by comparing the found line positons with
00151             estimated template positions. This routine should be
00152             inserted in the wavelength calibration routine just after
00153             the fitLines() routine.
00154 ---------------------------------------------------------------------------*/
00155 
00156 /*<python>*/
00157 int checkForFakeLines ( FitParams ** par,
00158                     float        dispersion,
00159                         float     ** wavelength_clean,
00160             int       ** row_clean,
00161             int        * n_found_lines,
00162             int          n_columns,
00163             float        pixel_tolerance ) ;
00164 /*</python>*/
00165 
00166 /*----------------------------------------------------------------------------
00167    Function     :       createShiftedSlitWavemap()
00168    In           :       lineIm:       new shifted emission line frame
00169                         coeffs:       calculated polynomial coefficients,
00170                                       output of coeffsCrossSlitFit()
00171                         n_fitcoeffs:  number of polynomial coefficients, order + 1
00172                         wavelength:   wavelength list from line list
00173                         intensity:    corresponding line intensity from line list
00174                         n_lines:      number of lines in the list
00175                         magFactor:    magnification factor for help arrays
00176    Out          :       wavelength map
00177    Job          :       This routine cross-correlates a shifted emission line frames
00178                         and determines the shift to the old one which is given by
00179                         its polynomial coefficients.
00180                         Then the a0 coefficients is recalculated and afterwards
00181                         a new wavelength calibration map is generated using the
00182                         already calculated smoothed polynomial coefficients.
00183  ---------------------------------------------------------------------------*/
00184 
00185 /*<python>*/
00186 OneImage * createShiftedSlitWavemap ( OneImage * lineIm,
00187                                       float    ** coeffs,
00188                                       int      n_fitcoeffs,
00189                                       float  * wavelength,
00190                                       float  * intensity,
00191                                       int      n_lines,
00192                                       int      magFactor ) ;
00193 /*</python>*/
00194 
00195 
00196 /*----------------------------------------------------------------------------
00197    Function     :       createShiftedSlitWavemap2()
00198    In           :       lineIm:       new shifted emission line frame
00199                         coeffs:       calculated polynomial coefficients,
00200                                       output of coeffsCrossSlitFit()
00201                         n_fitcoeffs:  number of polynomial coefficients, order + 1
00202                         wavelength:   wavelength list from line list
00203                         intensity:    corresponding line intensity from line list
00204                         n_lines:      number of lines in the list
00205                         magFactor:    magnification factor for help arrays
00206                         dispersion:   estimate of the dispersion
00207                         pixel_dist:   estimate of minimal pixel distance in spectral direction between slitlets
00208    Out          :       wavelength map
00209    Job          :       This routine cross-correlates a shifted emission line frames
00210                         and determines the shift to the old one which is given by
00211                         its polynomial coefficients.
00212                         Then the a0 coefficients is recalculated and afterwards
00213                         a new wavelength calibration map is generated using the
00214                         already calculated smoothed polynomial coefficients.
00215  ---------------------------------------------------------------------------*/
00216 
00217 /*<python>*/
00218 OneImage * createShiftedSlitWavemap2 ( OneImage * lineIm,
00219                                       float    ** coeffs,
00220                                       int      n_fitcoeffs,
00221                                       float  * wavelength,
00222                                       float  * intensity,
00223                                       int      n_lines,
00224                                       int      magFactor,
00225                                       float    dispersion,
00226                                       float    pixel_dist ) ;
00227 /*</python>*/
00228 
00229 /*----------------------------------------------------------------------------
00230    Function     :       createShiftedSlitWavemap3()
00231    In           :       lineIm:       new shifted emission line frame
00232                         coeffs:       calculated polynomial coefficients,
00233                                       output of coeffsCrossSlitFit()
00234                         n_fitcoeffs:  number of polynomial coefficients, order + 1
00235                         wavelength:   wavelength list from line list
00236                         intensity:    corresponding line intensity from line list
00237                         n_lines:      number of lines in the list
00238                         magFactor:    magnification factor for help arrays
00239    Out          :       wavelength map
00240    Job          :       This routine cross-correlates a shifted emission line frames
00241                         and determines the shift to the old one which is given by
00242                         its polynomial coefficients.
00243                         Then the a0 coefficients is recalculated by using a clean mean
00244                         of the determined offset (shift) over the whole frame
00245                         and afterwards a new wavelength calibration map is generated using the
00246                         already calculated smoothed polynomial coefficients.
00247  ---------------------------------------------------------------------------*/
00248 
00249 /*<python>*/
00250 OneImage * createShiftedSlitWavemap3 ( OneImage * lineIm,
00251                                       float    ** coeffs,
00252                                       int      n_fitcoeffs,
00253                                       float  * wavelength,
00254                                       float  * intensity,
00255                                       int      n_lines,
00256                                       int      magFactor ) ;
00257 /*</python>*/
00258 
00259 /*----------------------------------------------------------------------------
00260    Function     :       checkLinePositions()
00261    In           :       lineIm:       new shifted emission line frame
00262                         coeffs:       calculated polynomial coefficients,
00263                                       output of coeffsCrossSlitFit()
00264                         n_fitcoeffs:  number of polynomial coefficients, order + 1
00265                         par:          fit parameters
00266    Out          :       clean averaged position error (shift) of the brightest lines in the
00267 emission
00268                         line image with respect to the expected positions from the wavelengt
00269 h
00270                         calibration (error in the wavelength regime (microns)).
00271    Job          :       This routine determines the clean averaged error (shift) of the brig
00272 htest
00273                         lines in the emission line image with respect to the expected positi
00274 ons
00275                         from the wavelength calibration. The error is given in the wavelengt
00276 h
00277                         regime (microns).
00278                         It should give the user an impression for the quality
00279                         of the wavelength calibration.
00280  ---------------------------------------------------------------------------*/
00281 
00282 /*<python>*/
00283 float checkLinePositions ( OneImage     * lineIm,
00284                            float       ** coeffs,
00285                            int            n_fitcoeffs,
00286                            FitParams   ** par ) ;
00287 /*</python>*/
00288 
00289 /*----------------------------------------------------------------------------
00290    Function     :       checkCorrelatedLinePositions()
00291    In           :       lineIm:       new shifted emission line frame
00292                         coeffs:       calculated polynomial coefficients,
00293                                       output of coeffsCrossSlitFit()
00294                         n_fitcoeffs:  number of polynomial coefficients, order + 1
00295                         wavelength:   wavelength list from line list
00296                         intensity:    corresponding line intensity from line list
00297                         n_lines:      number of lines in list
00298                         fwhm:         guess value for full width of half maximum of gaussian
00299                         width:        half width of the box where the line must sit
00300                         min_amplitude: minimum line amplitude with respect to the background
00301                                        to do the fit
00302                         par:          fit parameters
00303    Out          :       clean averaged position error (shift) of the brightest lines in the
00304 emissio
00305 n
00306                         line image with respect to the expected positions from the wavelengt
00307 h
00308                         calibration (error in the wavelength regime (microns)).
00309    Job          :       This routine determines the clean averaged error (shift) of the brig
00310 htest
00311                         lines in the emission line image with respect to the expected positi
00312 ons
00313                         from the wavelength calibration. The error is given in the wavelengt
00314 h
00315                         regime (microns).
00316                         It should give the user an impression of the quality
00317                         of the wavelength calibration.
00318  ---------------------------------------------------------------------------*/
00319 
00320 /*<python>*/
00321 float checkCorrelatedLinePositions ( OneImage     * lineIm,
00322                                      float       ** coeffs,
00323                                      int            n_fitcoeffs,
00324                                      float        * wavelength,
00325                                      float        * intensity,
00326                                      int            n_lines,
00327                                      float          fwhm,
00328                                      float          width,
00329                                      float          min_amplitude,
00330                                      float          dispersion,
00331                                      FitParams   ** par ) ;
00332 /*</python>*/
00333 
00334 
00335 #endif 

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