SINFONI Pipeline Reference Manual  2.6.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! */
65 typedef struct {
66  cpl_size cost; /* May be incremented for cost counting */
67  cpl_size xcost; /* Ditto (can exclude failed fills) */
68  cpl_size ulines; /* May be set to number of lines used */
69 
70 } irplib_base_spectrum_model;
71 
72 typedef struct {
73  cpl_size cost; /* May be incremented for cost counting */
74  cpl_size xcost; /* Ditto (can exclude failed fills) */
75  cpl_size ulines; /* May be set to number of lines used */
76 
77  double wslit; /* Slit Width */
78  double wfwhm; /* FWHM of transfer function */
79  double xtrunc; /* Truncate transfer function beyond xtrunc,
80  xtrunc > 0 */
81  const cpl_bivector * lines; /* Catalogue of intensities, with
82  increasing X-vector elements */
83  cpl_vector * linepix; /* Catalogue of line pixel positions
84  - zero for uninitialized */
85  cpl_vector * erftmp; /* Temporary storage for erf() values
86  - zero for uninitialized */
87 } irplib_line_spectrum_model;
88 
89 /*-----------------------------------------------------------------------------
90  Function Prototypes
91  -----------------------------------------------------------------------------*/
92 
93 cpl_error_code
95  int,
96  const cpl_vector *,
97  int, int,
98  irplib_base_spectrum_model *,
99  cpl_error_code (*)
100  (cpl_vector *,
101  const cpl_polynomial *,
102  irplib_base_spectrum_model *),
103  double,
104  double,
105  int,
106  int,
107  int,
108  int,
109  cpl_boolean,
110  double *);
111 
112 cpl_error_code
114  const cpl_polynomial *,
115  const cpl_vector *,
116  irplib_base_spectrum_model *,
117  cpl_error_code (*)
118  (cpl_vector *,
119  const cpl_polynomial *,
120  irplib_base_spectrum_model *),
121  int,
122  cpl_boolean,
123  double *);
124 
125 cpl_error_code
127  const cpl_vector *,
128  irplib_base_spectrum_model *,
129  cpl_error_code (*)
130  (cpl_vector *,
131  const cpl_polynomial *,
132  irplib_base_spectrum_model *),
133  int, cpl_boolean, double *);
134 
135 cpl_error_code
136 irplib_polynomial_find_1d_from_correlation(cpl_polynomial *, int,
137  const cpl_vector *,
138  irplib_base_spectrum_model *,
139  cpl_error_code (*)
140  (cpl_vector *,
141  const cpl_polynomial *,
142  irplib_base_spectrum_model *),
143  double, double,
144  int, int, double *);
145 
146 cpl_error_code irplib_vector_fill_line_spectrum(cpl_vector *,
147  const cpl_polynomial *,
148  irplib_base_spectrum_model *);
149 
150 cpl_error_code irplib_vector_fill_logline_spectrum(cpl_vector *,
151  const cpl_polynomial *,
152  irplib_base_spectrum_model *);
153 
154 cpl_error_code
156  const cpl_polynomial *,
157  irplib_base_spectrum_model *);
158 
159 cpl_error_code
161  const cpl_polynomial *,
162  irplib_base_spectrum_model *);
163 
164 cpl_error_code irplib_plot_spectrum_and_model(const cpl_vector *,
165  const cpl_polynomial *,
166  irplib_base_spectrum_model *,
167  cpl_error_code (*)
168  (cpl_vector *,
169  const cpl_polynomial *,
170  irplib_base_spectrum_model *));
171 
172 cpl_error_code irplib_polynomial_fit_2d_dispersion(cpl_polynomial *,
173  const cpl_image *,
174  int, double *);
175 
176 int irplib_bivector_count_positive(const cpl_bivector *, double, double);
177 
178 #endif
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_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_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.
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_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_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.
int irplib_bivector_count_positive(const cpl_bivector *, double, double)
Count the positive Y-entries in a given X-range.