CR2RE Pipeline Reference Manual 1.7.0
irplib_wavecal.h
1/* $Id: irplib_wavecal.h,v 1.18 2012-08-03 21:05:33 llundin Exp $
2 *
3 * This file is part of the IRPLIB Pipeline
4 * Copyright (C) 2002,2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: llundin $
23 * $Date: 2012-08-03 21:05:33 $
24 * $Revision: 1.18 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef IRPLIB_WAVECAL_H
29#define IRPLIB_WAVECAL_H
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36
37
38/*-----------------------------------------------------------------------------
39 Define
40 -----------------------------------------------------------------------------*/
41
42#define IRPLIB_WAVECAL_MODEL_COEFFS 4
43/* The number of columns is 5 + IRPLIB_WAVECAL_MODEL_COEFFS */
44#define IRPLIB_WAVECAL_MODEL_COLS 9
45
46#define IRPLIB_WAVECAL_LAB_MODE "SpecMode"
47#define IRPLIB_WAVECAL_LAB_RESID "Residual"
48#define IRPLIB_WAVECAL_LAB_ORDER "Fit_Order"
49#define IRPLIB_WAVECAL_LAB_XMIN "XMin"
50#define IRPLIB_WAVECAL_LAB_XMAX "XMax"
51#define IRPLIB_WAVECAL_LAB_C1 "C_1"
52#define IRPLIB_WAVECAL_LAB_C2 "C_2"
53#define IRPLIB_WAVECAL_LAB_C3 "C_3"
54#define IRPLIB_WAVECAL_LAB_C4 "C_4"
55
56#define IRPLIB_WAVECAL_LAB_WAVE "WAVELENGTH"
57#define IRPLIB_WAVECAL_LAB_INTENS "INTENSITY"
58
59
60/*-----------------------------------------------------------------------------
61 New Types
62 -----------------------------------------------------------------------------*/
63
64/* Any spectrum model must have these members first! */
65typedef struct
66{
67 cpl_size cost; /* May be incremented for cost counting */
68 cpl_size xcost; /* Ditto (can exclude failed fills) */
69 cpl_size ulines; /* May be set to number of lines used */
70
71} irplib_base_spectrum_model;
72
73typedef struct
74{
75 cpl_size cost; /* May be incremented for cost counting */
76 cpl_size xcost; /* Ditto (can exclude failed fills) */
77 cpl_size ulines; /* May be set to number of lines used */
78
79 double wslit; /* Slit Width */
80 double wfwhm; /* FWHM of transfer function */
81 double xtrunc; /* Truncate transfer function beyond xtrunc,
82 xtrunc > 0 */
83 const cpl_bivector *lines; /* Catalogue of intensities, with
84 increasing X-vector elements */
85 cpl_vector *linepix; /* Catalogue of line pixel positions
86 - zero for uninitialized */
87 cpl_vector *erftmp; /* Temporary storage for erf() values
88 - zero for uninitialized */
89} irplib_line_spectrum_model;
90
91/*-----------------------------------------------------------------------------
92 Function Prototypes
93 -----------------------------------------------------------------------------*/
94
96 cpl_polynomial *,
97 int,
98 const cpl_vector *,
99 int,
100 int,
101 irplib_base_spectrum_model *,
102 cpl_error_code (*)(cpl_vector *,
103 const cpl_polynomial *,
104 irplib_base_spectrum_model *),
105 double,
106 double,
107 int,
108 int,
109 int,
110 int,
111 cpl_boolean,
112 double *);
113
115 cpl_bivector *,
116 const cpl_polynomial *,
117 const cpl_vector *,
118 irplib_base_spectrum_model *,
119 cpl_error_code (*)(cpl_vector *,
120 const cpl_polynomial *,
121 irplib_base_spectrum_model *),
122 int,
123 cpl_boolean,
124 double *);
125
127 cpl_polynomial *,
128 const cpl_vector *,
129 irplib_base_spectrum_model *,
130 cpl_error_code (*)(cpl_vector *,
131 const cpl_polynomial *,
132 irplib_base_spectrum_model *),
133 int,
134 cpl_boolean,
135 double *);
136
138 cpl_polynomial *,
139 int,
140 const cpl_vector *,
141 irplib_base_spectrum_model *,
142 cpl_error_code (*)(cpl_vector *,
143 const cpl_polynomial *,
144 irplib_base_spectrum_model *),
145 double,
146 double,
147 int,
148 int,
149 double *);
150
151cpl_error_code irplib_vector_fill_line_spectrum(cpl_vector *,
152 const cpl_polynomial *,
153 irplib_base_spectrum_model *);
154
155cpl_error_code
157 const cpl_polynomial *,
158 irplib_base_spectrum_model *);
159
160cpl_error_code
162 const cpl_polynomial *,
163 irplib_base_spectrum_model *);
164
165cpl_error_code
167 const cpl_polynomial *,
168 irplib_base_spectrum_model *);
169
170cpl_error_code irplib_plot_spectrum_and_model(
171 const cpl_vector *,
172 const cpl_polynomial *,
173 irplib_base_spectrum_model *,
174 cpl_error_code (*)(cpl_vector *,
175 const cpl_polynomial *,
176 irplib_base_spectrum_model *));
177
178cpl_error_code irplib_polynomial_fit_2d_dispersion(cpl_polynomial *,
179 const cpl_image *,
180 int,
181 double *);
182
183int irplib_bivector_count_positive(const cpl_bivector *, double, double);
184
185#endif
int irplib_bivector_count_positive(const cpl_bivector *, double, double)
Count the positive Y-entries in a given X-range.
cpl_error_code irplib_vector_fill_line_spectrum(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *)
Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_bivector_find_shift_from_correlation(cpl_bivector *, const cpl_polynomial *, const cpl_vector *, irplib_base_spectrum_model *, cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *), int, cpl_boolean, double *)
Find shift(s) that maximizes (locally) the cross-correlation.
cpl_error_code irplib_polynomial_fit_2d_dispersion(cpl_polynomial *, const cpl_image *, int, double *)
Fit a 2D-dispersion from an image of wavelengths.
cpl_error_code irplib_vector_fill_line_spectrum_fast(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *)
Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_vector_fill_logline_spectrum_fast(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *)
Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_plot_spectrum_and_model(const cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *, cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *))
Plot a 1D spectrum and one from a model.
cpl_error_code irplib_polynomial_find_1d_from_correlation_all(cpl_polynomial *, int, const cpl_vector *, int, int, irplib_base_spectrum_model *, cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *), double, double, int, int, int, int, cpl_boolean, double *)
Modify self by maximizing the cross-correlation across all maxima.
cpl_error_code irplib_polynomial_find_1d_from_correlation(cpl_polynomial *, int, const cpl_vector *, irplib_base_spectrum_model *, cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *), double, double, int, int, double *)
Modify self by maximizing the cross-correlation.
cpl_error_code irplib_vector_fill_logline_spectrum(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *)
Generate a 1D spectrum from a model and a dispersion relation.
cpl_error_code irplib_polynomial_shift_1d_from_correlation(cpl_polynomial *, const cpl_vector *, irplib_base_spectrum_model *, cpl_error_code(*)(cpl_vector *, const cpl_polynomial *, irplib_base_spectrum_model *), int, cpl_boolean, double *)
Shift self by the amount that maximizes the cross-correlation.