GIRAFFE Pipeline Reference Manual

gimath_lm.h
1 /*
2  * This file is part of the GIRAFFE Pipeline
3  * Copyright (C) 2002-2019 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef GIMATH_LM_H
21 #define GIMATH_LM_H
22 
23 #include <cxtypes.h>
24 
25 #include <cpl_matrix.h>
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
33 #define LMRQ_DCHISQ 0.0001
34 #define LMRQ_ITERMAX 30
35 #define LMRQ_TESTMAX 7
36 #define LMRQ_NPARAMS 3
37 
38 #define DW_DEGREE 3
39 #define DW_LOG001 2.302585093 /* -log(0.1) */
40 
41 /* optical model inputs indices */
42 #define LMI_WLEN 0
43 #define LMI_XFIB 1
44 #define LMI_YFIB 2
45 
46 /* optical model parameters indices */
47 #define LMP_NX 0
48 #define LMP_NY 0
49 #define LMP_PXSIZ 1
50 #define LMP_FCOLL 2
51 #define LMP_CFACT 3
52 #define LMP_THETA 4
53 #define LMP_ORDER 5
54 #define LMP_SPACE 6
55 #define LMP_SOFFX 7
56 #define LMP_SOFFY 8
57 #define LMP_SPHI 9
58 
59 /* line model parameters indices */
60 #define LMP_AMPL 0
61 #define LMP_CENT 1
62 #define LMP_BACK 2
63 #define LMP_WID1 3
64 #define LMP_WID2 4
65 
66 /* locy model parameters indices */
67 #define LMP_TX 0
68 #define LMP_TY 1
69 #define LMP_CX 2
70 #define LMP_KY 3
71 #define LMP_TT 4
72 
73 /* locy model inputs indices */
74 #define LMI_XCCD 0
75 #define LMI_NX 1
76 #define LMI_STRX 2
77 #define LMI_NCOF 3
78 
85 typedef void (*fitted_func)(double[], double[], double[], double *, double[], int);
86 
92 struct lmrq_params {
93  cxint imax;
94  cxint tmax;
95  cxdouble dchsq;
96 };
97 
98 typedef struct lmrq_params lmrq_params;
99 
104 enum _lmrq_model_id_ {
105  LMRQ_GAUSSUM,
106  LMRQ_XOPTMOD,
107  LMRQ_XOPTMODGS,
108  LMRQ_XOPTMOD2,
109  LMRQ_PSFCOS,
110  LMRQ_PSFEXP,
111  LMRQ_YOPTMOD,
112  LMRQ_YOPTMOD2,
113  LMRQ_LOCYWARP,
114  LMRQ_PSFEXP2,
115  LMRQ_TEST,
116  LMRQ_UNDEFINED
117 };
118 
119 typedef enum _lmrq_model_id_ lmrq_model_id;
120 
125 enum lmrq_model_type {
126  LINE_MODEL,
127  XOPT_MODEL,
128  YOPT_MODEL,
129  LOCY_MODEL
130 };
131 
132 typedef enum lmrq_model_type lmrq_model_type;
133 
138 struct lmrq_model {
139  lmrq_model_id id;
140  fitted_func cfunc;
141  cxint nparams;
142  cxint ninputs;
143  cxchar name[256];
144  lmrq_model_type type;
145 };
146 
147 typedef struct lmrq_model lmrq_model; // aka FittedModel
148 
149 
150 cxint mrqnlfit(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
151  cxdouble[], cxint[], cxint, cpl_matrix *, cxdouble *,
152  lmrq_params, fitted_func);
153 
154 cxint mymrqmin(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
155  cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
156  cxdouble *, fitted_func, cxdouble *);
157 
158 cxint mymrqcof(cpl_matrix *, cpl_matrix *, cpl_matrix *, cxint, cpl_matrix *,
159  cxdouble[], cxint[], cxint, cpl_matrix *, cpl_matrix *,
160  cxdouble *, fitted_func);
161 
162 cxdouble r_squared(cxdouble, cpl_matrix *, cxint);
163 
164 
165 
166 void mrqgaussum(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
167  cxdouble[], cxint);
168 
169 void mrqxoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
170  cxdouble[], cxint);
171 
172 void mrqxoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
173  cxdouble[], cxint);
174 
175 void mrqyoptmod(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
176  cxdouble[], cxint);
177 
178 void mrqyoptmod2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
179  cxdouble[], cxint);
180 
181 void mrqpsfcos(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
182  cxdouble[], cxint);
183 
184 void mrqpsfexp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
185  cxdouble[], cxint);
186 
187 void mrqpsfexp2(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
188  cxdouble[], cxint);
189 
190 void mrqlocywarp(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
191  cxdouble[], cxint);
192 
193 void mrqxoptmodGS(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
194  cxdouble[], cxint);
195 
196 void mrqtest(cxdouble[], cxdouble[], cxdouble[], cxdouble *,
197  cxdouble[], cxint);
198 
199 extern lmrq_model lmrq_models[];
200 extern cxint nr_lmrq_models;
201 
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* GIMATH_LM_H */
struct definition to handle model functions
Definition: gimath_lm.h:138
lmrq_model_type type
Definition: gimath_lm.h:144
cxchar name[256]
Definition: gimath_lm.h:143
fitted_func cfunc
Definition: gimath_lm.h:140
cxint ninputs
Definition: gimath_lm.h:142
lmrq_model_id id
Definition: gimath_lm.h:139
cxint nparams
Definition: gimath_lm.h:141

This file is part of the GIRAFFE Pipeline Reference Manual 2.16.10.
Documentation copyright © 2002-2006 European Southern Observatory.
Generated on Thu Dec 15 2022 21:18:51 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2004