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. |
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.
self | Bivector with increasing X-entries | |
x_min | minimum X-entry | |
x_max | maximum X-entry |
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.
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 |
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.
x | x | |
sigma | sigma |
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.
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 |
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.
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 |
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.
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 |
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.
self | 2D-polynomial to hold fit | |
imgwave | Image map of wavelengths, any pixeltype | |
fitdeg | Degree of fit | |
presid | On success, points to fitting residual |
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.
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 |
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.
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 |
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.
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 |
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.
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 |
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.
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 |
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.
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 |
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().