UVES Pipeline Reference Manual  5.4.0
uves_extract_profile.h
1 /*
2  * This file is part of the ESO UVES Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2010-09-24 09:32:03 $
23  * $Revision: 1.5 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.3 2010/02/13 12:22:31 amodigli
27  * removed inlines (let's do work to compiler)
28  *
29  * Revision 1.2 2007/06/06 08:17:33 amodigli
30  * replace tab with 4 spaces
31  *
32  * Revision 1.1 2007/05/02 13:42:23 jmlarsen
33  * Added header
34  *
35  * Revision 1.28 2007/04/24 12:50:29 jmlarsen
36  * Replaced cpl_propertylist -> uves_propertylist which is much faster
37  *
38  * Revision 1.27 2006/11/15 14:04:08 jmlarsen
39  * Removed non-const version of parameterlist_get_first/last/next which is already
40  * in CPL, added const-safe wrapper, unwrapper and deallocator functions
41  *
42  * Revision 1.26 2006/09/19 07:15:35 jmlarsen
43  * Added chip to argument list of uves_extract()
44  *
45  * Revision 1.25 2006/08/17 13:56:53 jmlarsen
46  * Reduced max line length
47  *
48  * Revision 1.24 2006/05/16 12:13:07 amodigli
49  * added QC log
50  *
51  * Revision 1.23 2006/05/12 15:04:13 jmlarsen
52  * Changed gauss/moffat/virtual profile measuring methods to use
53  * global polynomials (rather than one polynomial per order)
54  *
55  * Revision 1.22 2006/04/24 09:21:18 jmlarsen
56  * Implemented virtual resampling algorithm
57  *
58  * Revision 1.21 2006/02/28 09:15:22 jmlarsen
59  * Minor update
60  *
61  * Revision 1.20 2005/12/19 16:17:56 jmlarsen
62  * Replaced bool -> int
63  *
64  */
65 #ifndef UVES_EXTRACT_PROFILE_H
66 #define UVES_EXTRACT_PROFILE_H
67 
68 #include <uves_extract_iterate.h>
69 
70 typedef struct _uves_extract_profile uves_extract_profile;
71 
72 uves_extract_profile *uves_extract_profile_new(
73  int (*f) (const double x[], const double a[], double *result),
74  int (*dfda)(const double x[], const double a[], double result[]),
75  int M,
76  double slit_length,
77  int sampling_factor);
78 
79 uves_extract_profile *
80 uves_extract_profile_new_constant(double slit_length);
81 
82 void uves_extract_profile_delete(uves_extract_profile **p);
83 
84 double
85 uves_extract_profile_evaluate(const uves_extract_profile *profile,
86  const uves_iterate_position *pos);
87 
88 void uves_extract_profile_set(const uves_extract_profile *p,
89  uves_iterate_position *pos,
90  int *warnings);
91 double
92 uves_extract_profile_get_y(uves_iterate_position *pos,
93  double bin,
94  int sampling_factor);
95 
96 double
97 uves_extract_profile_get_bin(const uves_iterate_position *pos,
98  int sampling_factor);
99 
100 int uves_extract_profile_get_nbins(double slit_length, int sampling_factor);
101 
102 
103 
104 
105 /* This should be defined to 0, and is used only for testing.
106  * If set to 1 the profile is measured order by order (like the MIDAS algorithm
107  * which is less robust)
108  */
109 #define ORDER_PER_ORDER 0
110 
111 /* The spatial profile @cond
112  fixme: avoid exporting this definition,
113  currently needed for uves_extract module
114 */
115 struct _uves_extract_profile
116 {
117  /* There are three types of profiles.
118  *
119  * If constant == true
120  * assume a constant spatial profile
121  * only the member current_area is used
122  * else if f != NULL (zero resampling)
123  * y0(x,m) and sigma(x,m) are the parameters
124  * of the assumed profile (gaussian/moffat)
125  * red_chisq(x,m) is the smoothed reduced
126  * chi^2 of the fits
127  *
128  * else if f == NULL (virtual resampling)
129  * dy is an array of polynomials.
130  * dy_i(x,m) is the profile of the i'th
131  * spatial bin.
132  */
133 
134  bool constant;
135 
136  int (*f) (const double x[], const double a[], double *result);
137  int (*dfda)(const double x[], const double a[], double result[]);
138  int M;
139 
140 #if ORDER_PER_ORDER
141  polynomial **y0; /* Polynomial for each order */
142  polynomial **sigma;
143  polynomial **red_chisq;
144 #else
145  polynomial *y0;
146  polynomial *sigma;
147  polynomial *red_chisq;
148 #endif
149 
150  double current_y0; /* This is for a "performance hack", */
151  double current_sigma; /* so that we don't have to evaluate the */
152  double current_area; /* polynomials too often. See also
153  uves_extract_profile_set(). */
154 
155  /* Virtual resampling */
156  int spatial_bins;
157  double slit_length;
158  int sampling_factor;
159 
160 
161  bool *is_zero_degree; /* For efficiency: use polynomials or simple doubles
162  as necessary */
163  polynomial **dy_poly; /* Polynomial for each position along slit */
164  double *dy_double;
165 
166  double *current_profile; /* Array with profile at current x */
167  double *current_ypos; /* Array with y-positions where profile is known,
168  at current x */
169  double *current_interpolated; /* Interpolated profile at current x */
170 
171 };
172 /* @endcond */
173 
174 #endif