Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

calib/source/wcalib.c File Reference

Main file for wcalib. More...

Go to the source code of this file.

Data Structures

struct  ArcLine
struct  ArcGroup

Defines

#define SWAP(a, b, tmp)   (tmp)=(a); (a)=(b); (b)=(tmp);
#define SIGINIT   2.
 Initial gaussian Sigma guess [AA].

#define CRITER_SIG_1   0.1
#define CRITER_SIG_2   0.2
#define CRITER_NREJ_1   0.2
#define CRITER_NREJ_2   0.5
#define CRITER_DIFF_1   3
#define CRITER_DIFF_2   2
 Quality criteria for calibration.


Typedefs

typedef ArcLine ArcLine
typedef ArcGroup ArcGroup

Functions

void addArcLine (ArcLine *list[], double lambda)
 Create a single-line list or expand a list of lines.

void delArcLines (ArcLine list[])
 Delete a list of lines.

ArcGroupnewArcGroup (ArcGroup *list[], double lambda)
 Create a single-line group or expand a list of groups.

void expandArcGroup (ArcGroup *group, double lambda)
 Add a line to expand a group.

void delArcGroups (ArcGroup list[])
 Delete a list of groups.

void boundArcGroup (ArcGroup *group, double halfwidth, double lstep)
 Compute the bounds of a set of lines.

ArcGroupfindArcGroups (int nlbda, double *lbda, double halfwidth, double lstep)
 Join the reference lines in independant groups of lines.

void setGslCheb (gsl_cheb_series *cheb, double *coef, long ncoef, double xmin, double xmax)
 Set a GSL Chebyshev series from elements.

int fillSpectrumArray (SPECTRUM *spectre, double linf, double lsup, gsl_cheb_series *continuum)
 Return the background-subtracted spectrum between bounds.

int nllsqfit_constrained (int npar, int npts, int nconst , double *par, double *bl, double *bu, void(*objfun)(), double *rnorm)
 Non-linear least-square fit with constraints (dqed wrapper).

void MultiGauss (double par[], double fj[], int *ldfj, int *igo, int iopt[], double ropt[])
 Multi-gaussian fitting function (dqed routine, unconstrained).

void fitLineSet (long NbPixel, double Wbound, double *refLbda, double *fitLbda, double *fitSig, double *fitInt, int *fitFlag, double sigmin, double sigmax)
 Fit gaussian profiles on a set of lines (unconstrained).

void MultiGauss_constrained (double par[], double fj[], int *ldfj, int *igo, int iopt[], double ropt[])
 Multi-gaussian fitting function (dqed routine, constrained).

void fitLineSet_constrained (long NbPixel, double Wbound, double *refLbda, double *fitLbda, double *fitSig, double *fitInt, int *fitFlag, double sigmin, double sigmax)
 Fit gaussian profiles on a set of lines (constrained).

void saveGauss (SPECTRUM *spectre, double *fitLbda, double *fitSig, double *fitInt, int ng, gsl_cheb_series *continuum)
 Save the gaussian fit in a spectrum.

void saveCalib (SPECTRUM *spectre, gsl_cheb_series *wcalib)
 Save the calibration polynome in a spectrum.

int main (int argc, char **argv)

Variables

int glnlines
double glLbdaStart
double glLbdaStep
double * glArray
int glncon


Detailed Description

Main file for wcalib.

Copyright:
(c) 2003 CRAL-Observatoire de Lyon
Date:
Wed Oct 26 23:58:45 2005

Date
2005/10/25 00:08:02
Author:
J-L Villecroze, R Bacon, E Emsellem, A Pecontal

Yannick Copin <y.copin@ipnl.in2p3.fr>

Author
ycopin
Version:
Adapted from wcalib_SAU v1.6

Revision
1.27
Id
wcalib.c,v 1.27 2005/10/25 00:08:02 ycopin Exp

Todo:
Discard calls to NAG.

Definition in file wcalib.c.


Define Documentation

#define SWAP a,
b,
tmp   )     (tmp)=(a); (a)=(b); (b)=(tmp);
 

Definition at line 28 of file wcalib.c.

Referenced by fitLineSet().

#define SIGINIT   2.
 

Initial gaussian Sigma guess [AA].

Definition at line 30 of file wcalib.c.

Referenced by fitLineSet(), and fitLineSet_constrained().

#define CRITER_SIG_1   0.1
 

Definition at line 32 of file wcalib.c.

Referenced by main().

#define CRITER_SIG_2   0.2
 

Definition at line 33 of file wcalib.c.

Referenced by main().

#define CRITER_NREJ_1   0.2
 

Definition at line 34 of file wcalib.c.

Referenced by main().

#define CRITER_NREJ_2   0.5
 

Definition at line 35 of file wcalib.c.

Referenced by main().

#define CRITER_DIFF_1   3
 

Definition at line 36 of file wcalib.c.

Referenced by main().

#define CRITER_DIFF_2   2
 

Quality criteria for calibration.

Definition at line 37 of file wcalib.c.

Referenced by main().


Typedef Documentation

typedef struct ArcLine ArcLine
 

Arc line structure

typedef struct ArcGroup ArcGroup
 

Arc line group structure


Function Documentation

void addArcLine ArcLine list[],
double  lambda
 

Create a single-line list or expand a list of lines.

Parameters:
list Pointer to the list of lines (or NULL for a new list)
lambda Wavelength of the new line [AA]

Definition at line 76 of file wcalib.c.

References ArcLine::next.

Referenced by expandArcGroup(), and newArcGroup().

void delArcLines ArcLine  list[]  ) 
 

Delete a list of lines.

Parameters:
list Pointer to the list of lines

Definition at line 106 of file wcalib.c.

References ArcLine::next.

Referenced by delArcGroups().

ArcGroup* newArcGroup ArcGroup list[],
double  lambda
 

Create a single-line group or expand a list of groups.

Parameters:
list Pointer to the list of groups (or NULL for a new list)
lambda Wavelength of the new line [AA]

Definition at line 122 of file wcalib.c.

References addArcLine(), and ArcGroup::next.

Referenced by findArcGroups().

Here is the call graph for this function:

void expandArcGroup ArcGroup group,
double  lambda
 

Add a line to expand a group.

Parameters:
group Pointer to a group
lambda Wavelength of the new line [AA]

Definition at line 159 of file wcalib.c.

References addArcLine(), ArcGroup::lines, and ArcGroup::nlines.

Referenced by findArcGroups().

Here is the call graph for this function:

void delArcGroups ArcGroup  list[]  ) 
 

Delete a list of groups.

Parameters:
list Pointer to the list of groups

Definition at line 173 of file wcalib.c.

References delArcLines(), ArcGroup::lines, and ArcGroup::next.

Here is the call graph for this function:

void boundArcGroup ArcGroup group,
double  halfwidth,
double  lstep
 

Compute the bounds of a set of lines.

Parameters:
group Groupe of line to calculate on
halfwidth Line half-width [lstep]
lstep Wavelength step

Definition at line 191 of file wcalib.c.

References ArcLine::lambda, ArcGroup::lbda_inf, ArcGroup::lbda_sup, ArcGroup::lines, and ArcLine::next.

Referenced by findArcGroups().

ArcGroup* findArcGroups int  nlbda,
double *  lbda,
double  halfwidth,
double  lstep
 

Join the reference lines in independant groups of lines.

Parameters:
nlbda Number of reference lines
lbda Reference lines array
halfwidth Line half-width [lstep]
lstep Wavelength step
Returns:
Pointer to first ArcGroup

Definition at line 217 of file wcalib.c.

References boundArcGroup(), expandArcGroup(), and newArcGroup().

Referenced by main().

Here is the call graph for this function:

void setGslCheb gsl_cheb_series *  cheb,
double *  coef,
long  ncoef,
double  xmin,
double  xmax
 

Set a GSL Chebyshev series from elements.

Parameters:
cheb Previously allocated series of order=ncoef-1
coef Polynome coefficients
ncoef Number of coefficients (=order+1)
xmin 
xmax Definition interval

Definition at line 263 of file wcalib.c.

Referenced by main().

int fillSpectrumArray SPECTRUM *  spectre,
double  linf,
double  lsup,
gsl_cheb_series *  continuum
 

Return the background-subtracted spectrum between bounds.

Parameters:
spectre Input spectrum
linf 
lsup Lower and upper wavelenght bounds
continuum Continuum polynome to be subtracted (Chebyshev series)
Returns:
Number of points stored in global variable glArray

Definition at line 284 of file wcalib.c.

References glArray, and glLbdaStart.

Referenced by main().

int nllsqfit_constrained int  npar,
int  npts,
int  nconst ,
double *  par,
double *  bl,
double *  bu,
void(*  objfun)(),
double *  rnorm
 

Non-linear least-square fit with constraints (dqed wrapper).

Parameters:
npar 
npts 
par 
bl 
bu 
objfun 
Returns:

Definition at line 341 of file wcalib.c.

Referenced by fitLineSet(), and fitLineSet_constrained().

void MultiGauss double  par[],
double  fj[],
int *  ldfj,
int *  igo,
int  iopt[],
double  ropt[]
 

Multi-gaussian fitting function (dqed routine, unconstrained).

Note:
This is needed by dqed -based functions (e.g. lsq_fit_with_bounds_nonag or nllsqfit_constrained). See dqed manual for parameters.

Definition at line 410 of file wcalib.c.

References glArray, glLbdaStart, glLbdaStep, and glnlines.

Referenced by fitLineSet().

void fitLineSet long  NbPixel,
double  Wbound,
double *  refLbda,
double *  fitLbda,
double *  fitSig,
double *  fitInt,
int *  fitFlag,
double  sigmin,
double  sigmax
 

Fit gaussian profiles on a set of lines (unconstrained).

Parameters:
NbPixel Number of pixel in the current set of lines
Wbound 
refLbda Reference wavelength array
fitLbda Adjusted wavelength array
fitSig Adjusted sigma array
fitInt Adjusted intensity array
fitFlag Adjustment flag array
sigmin 
sigmax Sigma bounds

Definition at line 447 of file wcalib.c.

References glArray, glLbdaStart, glLbdaStep, glnlines, MultiGauss(), nllsqfit_constrained(), SIGINIT, and SWAP.

Here is the call graph for this function:

void MultiGauss_constrained double  par[],
double  fj[],
int *  ldfj,
int *  igo,
int  iopt[],
double  ropt[]
 

Multi-gaussian fitting function (dqed routine, constrained).

Note:
This is needed by dqed -based functions (e.g. lsq_fit_with_bounds_nonag or nllsqfit_constrained). See dqed manual for parameters.

See fitLineSet_constrained for the constraint description.

Definition at line 524 of file wcalib.c.

References glArray, glLbdaStart, glLbdaStep, glncon, and glnlines.

Referenced by fitLineSet_constrained().

void fitLineSet_constrained long  NbPixel,
double  Wbound,
double *  refLbda,
double *  fitLbda,
double *  fitSig,
double *  fitInt,
int *  fitFlag,
double  sigmin,
double  sigmax
 

Fit gaussian profiles on a set of lines (constrained).

Parameters:
NbPixel Number of pixel in the current set of lines
Wbound 
refLbda Reference wavelength array
fitLbda Adjusted wavelength array
fitSig Adjusted sigma array
fitInt Adjusted intensity array
fitFlag Adjustment flag array
sigmin 
sigmax Sigma bounds
Note:
The linear constraint enforced during the fit is, for a group of more than one lines, that

\[d0.5\lambda_{i,ref}<d\lambda_i<1.5\lambda_{i,ref}\]

where $d\lambda_i = \lambda_{i+1} - \lambda_i$. This insures:

  • the proper ordering of the arc lines ($d\lambda_i>0$),
  • blended lines will not completely mix together.

Definition at line 592 of file wcalib.c.

References glArray, glLbdaStart, glLbdaStep, glncon, glnlines, MultiGauss_constrained(), nllsqfit_constrained(), and SIGINIT.

Referenced by main().

Here is the call graph for this function:

void saveGauss SPECTRUM *  spectre,
double *  fitLbda,
double *  fitSig,
double *  fitInt,
int  ng,
gsl_cheb_series *  continuum
 

Save the gaussian fit in a spectrum.

Parameters:
spectre Output spectrum
fitLbda Wavelength array
fitSig Sigma array
fitInt Intensity
ng Number of gaussian
continuum Continuum polynome (Chebyshev series)

Definition at line 675 of file wcalib.c.

Referenced by main().

void saveCalib SPECTRUM *  spectre,
gsl_cheb_series *  wcalib
 

Save the calibration polynome in a spectrum.

Parameters:
spectre Output spectrum
wcalib Wavelength calibration polynome

Definition at line 704 of file wcalib.c.

int main int  argc,
char **  argv
 

Definition at line 736 of file wcalib.c.

References CRITER_DIFF_1, CRITER_DIFF_2, CRITER_NREJ_1, CRITER_NREJ_2, CRITER_SIG_1, CRITER_SIG_2, fillSpectrumArray(), findArcGroups(), fitLineSet_constrained(), glLbdaStart, glLbdaStep, glnlines, init_snifs(), ArcGroup::lbda_inf, ArcGroup::lbda_sup, LRANGE4, ArcGroup::next, ArcGroup::nlines, read_lbdaref_table(), saveGauss(), and setGslCheb().

Here is the call graph for this function:


Variable Documentation

int glnlines
 

Definition at line 41 of file wcalib.c.

Referenced by fitLineSet(), fitLineSet_constrained(), main(), MultiGauss(), and MultiGauss_constrained().

double glLbdaStart
 

Definition at line 42 of file wcalib.c.

Referenced by fillSpectrumArray(), fitLineSet(), fitLineSet_constrained(), main(), MultiGauss(), and MultiGauss_constrained().

double glLbdaStep
 

Definition at line 42 of file wcalib.c.

Referenced by fitLineSet(), fitLineSet_constrained(), main(), MultiGauss(), and MultiGauss_constrained().

double* glArray
 

Definition at line 43 of file wcalib.c.

Referenced by fillSpectrumArray(), fitLineSet(), fitLineSet_constrained(), MultiGauss(), and MultiGauss_constrained().

int glncon
 

Definition at line 45 of file wcalib.c.

Referenced by fitLineSet_constrained(), and MultiGauss_constrained().


Generated on Wed Oct 26 23:59:45 2005 for Snifs by doxygen 1.3.5