Spectro functionality

Functions

int irplib_bivector_count_positive (const cpl_bivector *self, double x_min, double x_max)
 Count the positive Y-entries in a given X-range.
cpl_error_code irplib_polynomial_fit_2d_dispersion (cpl_polynomial *self, const cpl_image *imgwave, int fitdeg, double *presid)
 Fit a 2D-dispersion from an image of wavelengths.
cpl_error_code irplib_polynomial_find_1d_from_correlation (cpl_polynomial *self, int maxdeg, const cpl_vector *obs, irplib_base_spectrum_model *model, cpl_error_code(*filler)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int), double pixtol, double pixstep, int hsize, int maxite, double *pxc)
 Modify self by maximizing the cross-correlation.
cpl_error_code irplib_vector_fill_line_spectrum (cpl_vector *self, const cpl_polynomial *disp, irplib_base_spectrum_model *lsslamp, int hsize)
 Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_vector_fill_logline_spectrum (cpl_vector *self, const cpl_polynomial *disp, irplib_base_spectrum_model *lsslamp, int hsize)
 Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_vector_fill_line_spectrum_fast (cpl_vector *self, const cpl_polynomial *disp, irplib_base_spectrum_model *lsslamp, int hsize)
 Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_vector_fill_logline_spectrum_fast (cpl_vector *self, const cpl_polynomial *disp, irplib_base_spectrum_model *lsslamp, int hsize)
 Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_plot_spectrum_and_model (const cpl_vector *self, const cpl_polynomial *disp1d, irplib_base_spectrum_model *model, cpl_error_code(*filler)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int))
 Plot a 1D spectrum and one from a model.
cpl_error_code irplib_bivector_find_shift_from_correlation (cpl_bivector *self, const cpl_polynomial *disp, const cpl_vector *obs, irplib_base_spectrum_model *model, cpl_error_code(*filler)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int), int hsize, cpl_boolean doplot, double *pxc)
 Find shift(s) that maximizes (locally) the cross-correlation.
cpl_error_code irplib_polynomial_shift_1d_from_correlation (cpl_polynomial *self, const cpl_vector *obs, irplib_base_spectrum_model *model, cpl_error_code(*filler)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int), int hsize, cpl_boolean doplot, double *pxc)
 Shift self by the amount that maximizes the cross-correlation.
cpl_error_code irplib_vector_fill_line_spectrum_model (cpl_vector *self, cpl_vector *linepix, cpl_vector *erftmp, const cpl_polynomial *disp, const cpl_bivector *lines, double wslit, double wfwhm, double xtrunc, int hsize, cpl_boolean dofast, cpl_boolean dolog, unsigned *pulines)
 Generate a 1D spectrum from (arc) lines and a dispersion relation.
double irplib_erf_antideriv (double x, double sigma)
 The antiderivative of erx(x/sigma/sqrt(2)) with respect to x.
cpl_error_code irplib_polynomial_find_1d_from_correlation_all (cpl_polynomial *self, int maxdeg, const cpl_vector *obs, int nmaxima, int linelim, irplib_base_spectrum_model *model, cpl_error_code(*filler)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int), double pixtol, double pixstep, int hsize, int maxite, int maxfail, int maxcont, cpl_boolean doplot, double *pxc)
 Modify self by maximizing the cross-correlation across all maxima.

Function Documentation

int irplib_bivector_count_positive ( const cpl_bivector *  self,
double  x_min,
double  x_max 
)

Count the positive Y-entries in a given X-range.

Parameters:
self Bivector with increasing X-entries
x_min minimum X-entry
x_max maximum X-entry
Returns:
the number of matching entries, or negative on error

Definition at line 115 of file irplib_wavecal.c.

cpl_error_code irplib_bivector_find_shift_from_correlation ( cpl_bivector *  self,
const cpl_polynomial *  disp,
const cpl_vector *  obs,
irplib_base_spectrum_model *  model,
cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int)  filler,
int  hsize,
cpl_boolean  doplot,
double *  pxc 
)

Find shift(s) that maximizes (locally) the cross-correlation.

Parameters:
self list of shifts that maximizes the cross-correlation (locally)
disp 1D-Dispersion relation, at least of degree 1
obs The observed spectrum to correlate against
model Pointer to model parameters
filler The function to fill the model spectrum
hsize Half the search-distance, hsize > 0 [pixel]
doplot Plot the cross-correlation as a function of pixel shift
pxc Iff non-NULL, set *pxc to cross-correlation on success
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
Note:
On success, self will be resized to fit the number of shifts.

The shifts are listed in order of decreasing cross-correlation. If pxc is non-NULL, *pxc will be set to the cross-correlation at shift 0.

Definition at line 704 of file irplib_wavecal.c.

Referenced by irplib_polynomial_find_1d_from_correlation_all().

double irplib_erf_antideriv ( double  x,
double  sigma 
)

The antiderivative of erx(x/sigma/sqrt(2)) with respect to x.

Parameters:
x x
sigma sigma
Returns:
The antiderivative
Note:
This function is even.

Definition at line 1293 of file irplib_wavecal.c.

Referenced by irplib_vector_fill_line_spectrum_model().

cpl_error_code irplib_plot_spectrum_and_model ( const cpl_vector *  self,
const cpl_polynomial *  disp1d,
irplib_base_spectrum_model *  model,
cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int)  filler 
)

Plot a 1D spectrum and one from a model.

Parameters:
self Vector with observed spectrum
disp1d 1D-Dispersion relation, at least of degree 1
model Pointer to model parameters
filler The function to fill the model spectrum
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
See also:
irplib_vector_fill_line_spectrum()

Definition at line 618 of file irplib_wavecal.c.

Referenced by irplib_polynomial_find_1d_from_correlation_all().

cpl_error_code irplib_polynomial_find_1d_from_correlation ( cpl_polynomial *  self,
int  maxdeg,
const cpl_vector *  obs,
irplib_base_spectrum_model *  model,
cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int)  filler,
double  pixtol,
double  pixstep,
int  hsize,
int  maxite,
double *  pxc 
)

Modify self by maximizing the cross-correlation.

Parameters:
self 1D-Dispersion relation to modify, at least of degree 1
maxdeg Maximize the cross-correlation by modifying maxdeg degree
obs The observed spectrum to correlate against
model The model of the lines/OTF etc.
filler The function to fill the model spectrum
pixtol The (positive) dispersion tolerance, e.g. 1e-6
pixstep The step length used in the maximization, e.g. 0.5 [pixel]
hsize Half the search-distance to ensure a global-maximum, hsize >= 0
maxite Maximum number of iterations, e.g. 100 * maxdeg
pxc On sucess, *pxc is the cross-correlation
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
Note:
Fails with CPL_ERROR_UNSUPPORTED_MODE if compiled without GSL. self must be increasing in the interval from 1 to the length of obs.

Definition at line 232 of file irplib_wavecal.c.

Referenced by irplib_polynomial_find_1d_from_correlation_all().

cpl_error_code irplib_polynomial_find_1d_from_correlation_all ( cpl_polynomial *  self,
int  maxdeg,
const cpl_vector *  obs,
int  nmaxima,
int  linelim,
irplib_base_spectrum_model *  model,
cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int)  filler,
double  pixtol,
double  pixstep,
int  hsize,
int  maxite,
int  maxfail,
int  maxcont,
cpl_boolean  doplot,
double *  pxc 
)

Modify self by maximizing the cross-correlation across all maxima.

Parameters:
self 1D-Dispersion relation to modify, at least of degree 1
maxdeg Maximize the cross-correlation by modifying maxdeg degree
obs The observed spectrum to correlate against
nmaxima Number of local maxima to try (0 for all, 1 for global only)
linelim Maximum number of lines allowed in iterative refinement
model The model of the lines/OTF etc.
filler The function to fill the model spectrum
pixtol The (positive) dispersion tolerance, e.g. 1e-6
pixstep The step length used in the maximization, e.g. 0.5 [pixel]
hsize Half the search-distance to ensure a global-maximum, hsize >= 0
maxite Maximum number of iterations, e.g. 100 * maxdeg
maxfail Number of retries on failure
maxcont Number of retries on non-convergence
doplot Plot the cross-correlation as a function of pixel shift
pxc On sucess, *pxc is the cross-correlation
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
Note:
Fails with CPL_ERROR_UNSUPPORTED_MODE if compiled without GSL. self must be increasing in the interval from 1 to the length of obs.

Definition at line 1421 of file irplib_wavecal.c.

References irplib_bivector_find_shift_from_correlation(), irplib_errorstate_dump_debug(), irplib_plot_spectrum_and_model(), and irplib_polynomial_find_1d_from_correlation().

cpl_error_code irplib_polynomial_fit_2d_dispersion ( cpl_polynomial *  self,
const cpl_image *  imgwave,
int  fitdeg,
double *  presid 
)

Fit a 2D-dispersion from an image of wavelengths.

Parameters:
self 2D-polynomial to hold fit
imgwave Image map of wavelengths, any pixeltype
fitdeg Degree of fit
presid On success, points to fitting residual
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code

Definition at line 148 of file irplib_wavecal.c.

cpl_error_code irplib_polynomial_shift_1d_from_correlation ( cpl_polynomial *  self,
const cpl_vector *  obs,
irplib_base_spectrum_model *  model,
cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, int)  filler,
int  hsize,
cpl_boolean  doplot,
double *  pxc 
)

Shift self by the amount that maximizes the cross-correlation.

Parameters:
self 1D-Dispersion relation to shift, at least of degree 1
obs The observed spectrum to correlate against
model Pointer to model parameters
filler The function to fill the model spectrum
hsize Half the search-distance, hsize > 0 [pixel]
doplot Plot the cross-correlation as a function of pixel shift
pxc Iff non-NULL, set *pxc to cross-correlation on success
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code

Definition at line 870 of file irplib_wavecal.c.

cpl_error_code irplib_vector_fill_line_spectrum ( cpl_vector *  self,
const cpl_polynomial *  disp,
irplib_base_spectrum_model *  lsslamp,
int  hsize 
)

Generate a 1D spectrum from a model and a dispersion relation.

Parameters:
self Vector to fill with spectrum
disp 1D-Dispersion relation, at least of degree 1
lsslamp Pointer to irplib_line_spectrum_model struct
hsize The 1st intensity in self will be disp(1-hsize), hsize >= 0
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code

The model comprises these elements:

    double wslit;  // Slit Width
    double wfwhm;  // FWHM of transfer function
    double xtrunc; // Truncate transfer function beyond xtrunc, xtrunc > 0
    const cpl_bivector * lines;    // Catalogue of intensities, with
                                   //   increasing X-vector elements
    cpl_vector         * linepix;  // NULL, or temporary work-space of size
                                   // equal to the lines bivector
                                   // - should be uninitialized to zero
    unsigned             cost;     // Will be incremented for each call
    unsigned             xcost;    // Will be incremented for each OK call

The units of the X-values of the lines is assumed to be the same as that of disp, the units of wslit, wfwhm and xtrunc are assumed to be the same as the input unit of disp(), the units of self will be that of the Y-values of the lines.

Definition at line 433 of file irplib_wavecal.c.

References irplib_vector_fill_line_spectrum_model().

cpl_error_code irplib_vector_fill_line_spectrum_fast ( cpl_vector *  self,
const cpl_polynomial *  disp,
irplib_base_spectrum_model *  lsslamp,
int  hsize 
)

Generate a 1D spectrum from a model and a dispersion relation.

Parameters:
self Vector to fill with spectrum
disp 1D-Dispersion relation, at least of degree 1
lsslamp Pointer to irplib_line_spectrum_model struct
hsize The 1st intensity in self will be disp(1-hsize), hsize >= 0
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
See also:
irplib_vector_fill_line_spectrum()

Complexity reduced from O(nw) to O(n + w), where n is number of lines and truncation width [pixel] of the line.

Definition at line 528 of file irplib_wavecal.c.

References irplib_vector_fill_line_spectrum_model().

cpl_error_code irplib_vector_fill_line_spectrum_model ( cpl_vector *  self,
cpl_vector *  linepix,
cpl_vector *  erftmp,
const cpl_polynomial *  disp,
const cpl_bivector *  lines,
double  wslit,
double  wfwhm,
double  xtrunc,
int  hsize,
cpl_boolean  dofast,
cpl_boolean  dolog,
unsigned *  pulines 
)

Generate a 1D spectrum from (arc) lines and a dispersion relation.

Parameters:
self Vector to fill with spectrum
linepix Vector to update with best guess of line pixel position
disp 1D-Dispersion relation, at least of degree 1
lines Catalogue of lines, with increasing wavelengths
wslit Positive width of the slit
wfwhm Positive FWHM of the transfer function
xtrunc Truncate the line profile beyond distance xtrunc, xtrunc > 0
hsize The 1st intensity in self will be disp(1-hsize), hsize >= 0
dofast Iff true compose profile from pairs of two integer-placed
dolog Iff true log(1+I) is used for the (positive) intensities
pulines Iff non-NULL, number of lines used, on success
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
See also:
irplib_vector_fill_line_spectrum()
Note:
This function is supposed to be called via irplib_vector_fill_line_spectrum().

Definition at line 976 of file irplib_wavecal.c.

References irplib_erf_antideriv(), and irplib_errorstate_dump_debug().

Referenced by irplib_vector_fill_line_spectrum(), irplib_vector_fill_line_spectrum_fast(), irplib_vector_fill_logline_spectrum(), and irplib_vector_fill_logline_spectrum_fast().

cpl_error_code irplib_vector_fill_logline_spectrum ( cpl_vector *  self,
const cpl_polynomial *  disp,
irplib_base_spectrum_model *  lsslamp,
int  hsize 
)

Generate a 1D spectrum from a model and a dispersion relation.

Parameters:
self Vector to fill with spectrum
disp 1D-Dispersion relation, at least of degree 1
lsslamp Pointer to irplib_line_spectrum_model struct
hsize The 1st intensity in self will be disp(1-hsize), hsize >= 0
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
Note:
The logarithm is taken on the intensities
See also:
irplib_vector_fill_line_spectrum

log(1+I) is used for the (positive) intensities

Definition at line 480 of file irplib_wavecal.c.

References irplib_vector_fill_line_spectrum_model().

cpl_error_code irplib_vector_fill_logline_spectrum_fast ( cpl_vector *  self,
const cpl_polynomial *  disp,
irplib_base_spectrum_model *  lsslamp,
int  hsize 
)

Generate a 1D spectrum from a model and a dispersion relation.

Parameters:
self Vector to fill with spectrum
disp 1D-Dispersion relation, at least of degree 1
lsslamp Pointer to irplib_line_spectrum_model struct
hsize The 1st intensity in self will be disp(1-hsize), hsize >= 0
Returns:
CPL_ERROR_NONE on success, otherwise the relevant CPL error code
Note:
The logarithm is taken on the intensities
See also:
irplib_vector_fill_line_spectrum_fast()

log(1+I) is used for the (positive) intensities

Definition at line 575 of file irplib_wavecal.c.

References irplib_vector_fill_line_spectrum_model().


Generated on 7 Mar 2012 for DETMON Pipeline Reference Manual by  doxygen 1.6.1