X-shooter Pipeline Reference Manual 3.8.15
xsh_model_io.c
Go to the documentation of this file.
1/* $Id: xsh_model_io.c,v 1.41 2011-12-02 14:15:28 amodigli Exp $
2 *
3 * This file is part of the CRIRES 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: amodigli $
23 * $Date: 2011-12-02 14:15:28 $
24 * $Revision: 1.41 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35
36#include <cpl.h>
37#include <xsh_msg.h>
38#include <xsh_utils_table.h>
39#include "xsh_model_io.h"
40#include "xsh_dfs.h"
41#include "xsh_error.h"
44
45/*-----------------------------------------------------------------------------
46 Functions prototypes
47 -----------------------------------------------------------------------------*/
48
49static int xsh_table_check_column(const cpl_table *, const char *) ;
50
51/*----------------------------------------------------------------------------*/
55/*----------------------------------------------------------------------------*/
56
59void
61 int i=0;
62
63 xsh_msg("temper=%g",p_xs_3->temper);
64 xsh_msg("arm=%d", p_xs_3->arm);
65 xsh_msg("t_ir_p2=%g", p_xs_3->t_ir_p2);
66 xsh_msg("t_ir_p3=%g", p_xs_3->t_ir_p3);
67 xsh_msg("es_x=%g", p_xs_3->es_x);
68 xsh_msg("es_y=%g", p_xs_3->es_y);
69 xsh_msg("mues=%g", p_xs_3->mues);
70 xsh_msg("nues=%g", p_xs_3->nues);
71 xsh_msg("taues=%g",p_xs_3->taues);
72 xsh_msg("slit_scale=%g",p_xs_3->slit_scale);
73 xsh_msg("es_s=%g",p_xs_3->es_s);
74 xsh_msg("es_w=%g",p_xs_3->es_w);
75 xsh_msg("fcol=%g",p_xs_3->fcol);
76 xsh_msg("cmup1=%g",p_xs_3->cmup1);
77 xsh_msg("mup1=%g", p_xs_3->mup1);
78 xsh_msg("nup1=%g", p_xs_3->nup1);
79 xsh_msg("taup1=%g",p_xs_3->taup1);
80 xsh_msg("mup2=%g", p_xs_3->mup2);
81 xsh_msg("nup2=%g", p_xs_3->nup2);
82 xsh_msg("taup2=%g", p_xs_3->taup2);
83 xsh_msg("mup3=%g", p_xs_3->mup3);
84 xsh_msg("nup3=%g", p_xs_3->nup3);
85 xsh_msg("taup3=%g",p_xs_3->taup3);
86 xsh_msg("mup4=%g", p_xs_3->mup4);
87 xsh_msg("nup4=%g", p_xs_3->nup4);
88 xsh_msg("taup4=%g", p_xs_3->taup4);
89 xsh_msg("mup5=%g",p_xs_3->mup5);
90 xsh_msg("nup5=%g", p_xs_3->nup5);
91 xsh_msg("taup5=%g", p_xs_3->taup5);
92 xsh_msg("mup6=%g", p_xs_3->mup6);
93 xsh_msg("nup6=%g", p_xs_3->nup6);
94 xsh_msg("taup6=%g",p_xs_3->taup6);
95 xsh_msg("mug=%g",p_xs_3->mug);
96 xsh_msg("nug=%g",p_xs_3->nug);
97 xsh_msg("taug=%g", p_xs_3->taug);
98 xsh_msg("sg=%g", p_xs_3->sg);
99 xsh_msg("fdet=%g", p_xs_3->fdet);
100 xsh_msg("mud=%g", p_xs_3->mud);
101 xsh_msg("nud=%g", p_xs_3->nud);
102 xsh_msg("taud=%g",p_xs_3->taud);
103 xsh_msg("pix=%g", p_xs_3->pix);
104 xsh_msg("chipx=%g",p_xs_3->chipx);
105 xsh_msg("chipy=%g",p_xs_3->chipy);
106 xsh_msg("chiprot=%g", p_xs_3->chiprot);
107 xsh_msg("pc_x_xx=%g", p_xs_3->pc_x_xx);
108 xsh_msg("pc_x_x1=%g", p_xs_3->pc_x_x1);
109 xsh_msg("pc_x_yy=%g", p_xs_3->pc_x_yy);
110 xsh_msg("pc_x_y1=%g", p_xs_3->pc_x_y1);
111 xsh_msg("pc_x_xy=%g", p_xs_3->pc_x_xy);
112 xsh_msg("pc_x_x3=%g", p_xs_3->pc_x_x3);
113 xsh_msg("pc_x_x2y=%g", p_xs_3->pc_x_x2y);
114 xsh_msg("pc_x_y2x=%g", p_xs_3->pc_x_y2x);
115 xsh_msg("pc_x_y3=%g", p_xs_3->pc_x_y3);
116 xsh_msg("pc_y_xx=%g", p_xs_3->pc_y_xx);
117 xsh_msg("pc_y_x1=%g", p_xs_3->pc_y_x1);
118 xsh_msg("pc_y_yy=%g", p_xs_3->pc_y_yy);
119 xsh_msg("pc_y_y1=%g", p_xs_3->pc_y_y1);
120 xsh_msg("pc_y_xy=%g", p_xs_3->pc_y_xy);
121 xsh_msg("pc_y_x3=%g", p_xs_3->pc_y_x3);
122 xsh_msg("pc_y_x2y=%g", p_xs_3->pc_y_x2y);
123 xsh_msg("pc_y_y2x=%g", p_xs_3->pc_y_y2x);
124 xsh_msg("pc_y_y3=%g", p_xs_3->pc_y_y3);
125 xsh_msg("pc4_x_xy3=%g", p_xs_3->pc4_x_xy3);
126 xsh_msg("pc4_x_x3y=%g",p_xs_3->pc4_x_x3y);
127 xsh_msg("pc4_x_x2y2=%g",p_xs_3->pc4_x_x2y2);
128 xsh_msg("pc4_x_x4=%g", p_xs_3->pc4_x_x4);
129 xsh_msg("pc4_x_y4=%g", p_xs_3->pc4_x_y4);
130 xsh_msg("pc4_y_xy3=%g",p_xs_3->pc4_y_xy3);
131 xsh_msg("pc4_y_x3y=%g", p_xs_3->pc4_y_x3y);
132 xsh_msg("pc4_y_x2y2=%g", p_xs_3->pc4_y_x2y2);
133 xsh_msg("pc4_y_x4=%g", p_xs_3->pc4_y_x4);
134 xsh_msg("pc4_y_y4=%g", p_xs_3->pc4_y_y4);
135 xsh_msg("ca_x0=%g", p_xs_3->ca_x0);
136 xsh_msg("ca_x=%g1", p_xs_3->ca_x1);
137 xsh_msg("ca_y0=%g", p_xs_3->ca_y0);
138 xsh_msg("ca_y1=%g", p_xs_3->ca_y1);
139 xsh_msg("d2_x1=%g", p_xs_3->d2_x1);
140 xsh_msg("d2_x=%g2", p_xs_3->d2_x2);
141 xsh_msg("d2_x3=%g", p_xs_3->d2_x3);
142 xsh_msg("d2_y1x0=%g", p_xs_3->d2_y1x0);
143 xsh_msg("d2_y1x1=%g", p_xs_3->d2_y1x1);
144 xsh_msg("d2_y1x2=%g", p_xs_3->d2_y1x2);
145 xsh_msg("d2_y1x3=%g", p_xs_3->d2_y1x3);
146 xsh_msg("d2_y2x0=%g", p_xs_3->d2_y2x0);
147 xsh_msg("d2_y2x1=%g", p_xs_3->d2_y2x1);
148 xsh_msg("d2_y2x2=%g", p_xs_3->d2_y2x2);
149 xsh_msg("d2_y2x3=%g", p_xs_3->d2_y2x3);
150 xsh_msg("d2_y3x0=%g", p_xs_3->d2_y3x0);
151 xsh_msg("d2_y3x1=%g", p_xs_3->d2_y3x1);
152 xsh_msg("d2_y3x2=%g", p_xs_3->d2_y3x2);
153 xsh_msg("d2_y3x3=%g", p_xs_3->d2_y3x3);
154 xsh_msg("offx=%g", p_xs_3->offx);
155 xsh_msg("offy=%g", p_xs_3->offy);
156 xsh_msg("flipx=%g", p_xs_3->flipx);
157 xsh_msg("flipy=%g", p_xs_3->flipy);
158 for(i=0;i<9;i++){
159 xsh_msg("slit=%g", p_xs_3->slit[i]);
160 }
161
162 return;
163
164}
165/*----------------------------------------------------------------------------*/
172/*----------------------------------------------------------------------------*/
173cpl_error_code
175 cpl_frame * config_frame,
176 xsh_xs_3 * p_xs_3)
177{
178 cpl_table * tab = NULL;
179 int nlines ;
180 char * name ;
181 int i;
182 const char * config=NULL;
183 const char * tag=NULL;
184 XSH_INSTRCONFIG* instr_config=NULL;
185
186 xsh_instrument* instr = NULL;
187
188 instr = xsh_instrument_new();
189
190 XSH_ASSURE_NOT_NULL( config_frame);
191 XSH_ASSURE_NOT_NULL( p_xs_3);
192 check( config=cpl_frame_get_filename(config_frame));
193 check( tag=cpl_frame_get_tag(config_frame));
194 xsh_msg_dbg_high("file %s tag=%s",config,tag);
195 /* Load the table */
196 check( tab = xsh_load_table_check(config,tag));
198 check( nlines = cpl_table_get_nrow(tab));
199
200 p_xs_3->config_mjd=0.0;
201
202 /*default values for the two non-zero dist coeff.s
203 (missing from older config files, if present in new files they will be overwritten) */
204 p_xs_3->pc_x_x1=1.0;
205 p_xs_3->pc_y_y1=1.0;
206 p_xs_3->pc_x_xx=0.0;
207 p_xs_3->pc_x_xy=0.0;
208 p_xs_3->pc_x_x3=0.0;
209 p_xs_3->pc_x_y1=0.0;
210 p_xs_3->pc_x_yy=0.0;
211 p_xs_3->pc_x_y3=0.0;
212 p_xs_3->pc_x_x2y=0.0;
213 p_xs_3->pc_x_y2x=0.0;
214 p_xs_3->pc_y_xx=0.0;
215 p_xs_3->pc_y_xy=0.0;
216 p_xs_3->pc_y_x3=0.0;
217 p_xs_3->pc_y_x1=0.0;
218 p_xs_3->pc_y_yy=0.0;
219 p_xs_3->pc_y_y3=0.0;
220 p_xs_3->pc_y_x2y=0.0;
221 p_xs_3->pc_y_y2x=0.0;
222
223 p_xs_3->d2_x1=0.0;
224 p_xs_3->d2_x2=0.0;
225 p_xs_3->d2_x3=0.0;
226 p_xs_3->d2_y1x0=0.0;
227 p_xs_3->d2_y1x1=0.0;
228 p_xs_3->d2_y1x2=0.0;
229 p_xs_3->d2_y1x3=0.0;
230 p_xs_3->d2_y2x0=0.0;
231 p_xs_3->d2_y2x1=0.0;
232 p_xs_3->d2_y2x2=0.0;
233 p_xs_3->d2_y2x3=0.0;
234 p_xs_3->d2_y3x0=0.0;
235 p_xs_3->d2_y3x1=0.0;
236 p_xs_3->d2_y3x2=0.0;
237 p_xs_3->d2_y3x3=0.0;
238 p_xs_3->pc4_x_x3y=0.0;
239 p_xs_3->pc4_x_xy3=0.0;
240 p_xs_3->pc4_x_x2y2=0.0;
241 p_xs_3->pc4_x_x4=0.0;
242 p_xs_3->pc4_x_y4=0.0;
243 p_xs_3->pc4_y_xy3=0.0;
244 p_xs_3->pc4_y_x3y=0.0;
245 p_xs_3->pc4_y_x2y2=0.0;
246 p_xs_3->pc4_y_x4=0.0;
247 p_xs_3->pc4_y_y4=0.0;
248 p_xs_3->ca_x0=0.0;
249 p_xs_3->ca_x1=0.0;
250 p_xs_3->ca_y0=0.0;
251 p_xs_3->ca_y1=0.0;
252 p_xs_3->offx=0.0;
253 p_xs_3->offy=0.0;
254
255 if (strncmp(tag,XSH_MOD_CFG_NIR,16)==0 ||
256 strncmp(tag,XSH_MOD_CFG_TAB_NIR,20)==0) {
257 p_xs_3->pc4_x_x3y=0.0;
258 p_xs_3->pc4_x_xy3=0.0;
259 p_xs_3->pc4_x_x2y2=0.0;
260 p_xs_3->pc4_x_x4=0.0;
261 p_xs_3->pc4_x_y4=0.0;
262 p_xs_3->pc4_y_xy3=0.0;
263 p_xs_3->pc4_y_x3y=0.0;
264 p_xs_3->pc4_y_x2y2=0.0;
265 p_xs_3->pc4_y_x4=0.0;
266 p_xs_3->pc4_y_y4=0.0;
267 p_xs_3->ca_x0=0.0;
268 p_xs_3->ca_x1=0.0;
269 p_xs_3->ca_y0=0.0;
270 p_xs_3->ca_y1=0.0;
271 p_xs_3->offx=0.0;
272 p_xs_3->offy=0.0;
273 }
274 else if (strncmp(tag,XSH_MOD_CFG_VIS,16)==0 ||
275 strncmp(tag,XSH_MOD_CFG_TAB_VIS,20)==0) {
276 p_xs_3->d2_x1=0.00287311525385538;
277 p_xs_3->d2_x2=1.55125984130817E-05;
278 p_xs_3->d2_x3=-4.00980399239143E-05;
279 }
280 else if (strncmp(tag,XSH_MOD_CFG_UVB,16)==0 ||
281 strncmp(tag,XSH_MOD_CFG_TAB_UVB,20)==0) {
282 p_xs_3->d2_x1=0.0;
283 p_xs_3->d2_x2=0.0;
284 p_xs_3->d2_x3=0.0;
285 }
286
287
288 /* Loop on lines */
289 for (i=0 ; i<nlines ; i++) {
290 name = (char*) cpl_table_get_string(tab, XSH_COL_MODEL_CONF_NAME, i);
291 // printf("param %s : %g\n", name, cpl_table_get_double(tab,
292 // XSH_COL_MODEL_CONF_BEST, i, NULL)) ;
293 if (!strcmp("temper", name)) p_xs_3->temper =
294 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
295 else if (!strcmp("arm", name)) p_xs_3->arm =
296 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
297 else if (!strcmp("config_mjd", name)) p_xs_3->config_mjd =
298 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
299 else if (!strcmp("t_ir_p2", name)) p_xs_3->t_ir_p2 =
300 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
301 else if (!strcmp("t_ir_p3", name)) p_xs_3->t_ir_p3 =
302 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
303 else if (!strcmp("es_x", name)) p_xs_3->es_x =
304 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
305 else if (!strcmp("es_y", name)) p_xs_3->es_y =
306 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
307 else if (!strcmp("mues", name)) p_xs_3->mues =
308 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
309 else if (!strcmp("nues", name)) p_xs_3->nues =
310 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
311 else if (!strcmp("taues", name)) p_xs_3->taues =
312 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
313 else if (!strcmp("slit_scale", name)) p_xs_3->slit_scale =
314 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
315 else if (!strcmp("es_s", name)) p_xs_3->es_s =
316 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
317 else if (!strcmp("es_w", name)) p_xs_3->es_w =
318 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
319 else if (!strcmp("fcol", name)) p_xs_3->fcol =
320 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
321 else if (!strcmp("cmup1", name)) p_xs_3->cmup1 =
322 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
323 else if (!strcmp("mup1", name)) p_xs_3->mup1 =
324 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
325 else if (!strcmp("nup1", name)) p_xs_3->nup1 =
326 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
327 else if (!strcmp("taup1", name)) p_xs_3->taup1 =
328 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
329 else if (!strcmp("mup2", name)) p_xs_3->mup2 =
330 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
331 else if (!strcmp("nup2", name)) p_xs_3->nup2 =
332 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
333 else if (!strcmp("taup2", name)) p_xs_3->taup2 =
334 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
335 else if (!strcmp("mup3", name)) p_xs_3->mup3 =
336 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
337 else if (!strcmp("nup3", name)) p_xs_3->nup3 =
338 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
339 else if (!strcmp("taup3", name)) p_xs_3->taup3 =
340 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
341 else if (!strcmp("mup4", name)) p_xs_3->mup4 =
342 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
343 else if (!strcmp("nup4", name)) p_xs_3->nup4 =
344 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
345 else if (!strcmp("taup4", name)) p_xs_3->taup4 =
346 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
347 else if (!strcmp("mup5", name)) p_xs_3->mup5 =
348 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
349 else if (!strcmp("nup5", name)) p_xs_3->nup5 =
350 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
351 else if (!strcmp("taup5", name)) p_xs_3->taup5 =
352 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
353 else if (!strcmp("mup6", name)) p_xs_3->mup6 =
354 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
355 else if (!strcmp("nup6", name)) p_xs_3->nup6 =
356 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
357 else if (!strcmp("taup6", name)) p_xs_3->taup6 =
358 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
359 else if (!strcmp("mug", name)) p_xs_3->mug =
360 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
361 else if (!strcmp("nug", name)) p_xs_3->nug =
362 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
363 else if (!strcmp("taug", name)) p_xs_3->taug =
364 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
365 else if (!strcmp("sg", name)) p_xs_3->sg =
366 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
367 else if (!strcmp("fdet", name)) p_xs_3->fdet =
368 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
369 else if (!strcmp("mud", name)) p_xs_3->mud =
370 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
371 else if (!strcmp("nud", name)) p_xs_3->nud =
372 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
373 else if (!strcmp("taud", name)) p_xs_3->taud =
374 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
375 else if (!strcmp("pix", name)) p_xs_3->pix =
376 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
377 else if (!strcmp("chipx", name)) p_xs_3->chipx=
378 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
379 else if (!strcmp("chipy", name)) p_xs_3->chipy=
380 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
381 else if (!strcmp("chiprot", name)) p_xs_3->chiprot =
382 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
383 else if (!strcmp("pc_x_xx", name)) p_xs_3->pc_x_xx=
384 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
385 else if (!strcmp("pc_x_x1", name)) p_xs_3->pc_x_x1=
386 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
387 else if (!strcmp("pc_x_yy", name)) p_xs_3->pc_x_yy=
388 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
389 else if (!strcmp("pc_x_y1", name)) p_xs_3->pc_x_y1=
390 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
391 else if (!strcmp("pc_x_xy", name)) p_xs_3->pc_x_xy=
392 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
393 else if (!strcmp("pc_x_x3", name)) p_xs_3->pc_x_x3=
394 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
395 else if (!strcmp("pc_x_x2y", name)) p_xs_3->pc_x_x2y=
396 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
397 else if (!strcmp("pc_x_y2x", name)) p_xs_3->pc_x_y2x=
398 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
399 else if (!strcmp("pc_x_y3", name)) p_xs_3->pc_x_y3=
400 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
401 else if (!strcmp("pc_y_xx", name)) p_xs_3->pc_y_xx=
402 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
403 else if (!strcmp("pc_y_x1", name)) p_xs_3->pc_y_x1=
404 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
405 else if (!strcmp("pc_y_yy", name)) p_xs_3->pc_y_yy=
406 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
407 else if (!strcmp("pc_y_y1", name)) p_xs_3->pc_y_y1=
408 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
409 else if (!strcmp("pc_y_xy", name)) p_xs_3->pc_y_xy=
410 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
411 else if (!strcmp("pc_y_x3", name)) p_xs_3->pc_y_x3=
412 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
413 else if (!strcmp("pc_y_x2y", name)) p_xs_3->pc_y_x2y=
414 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
415 else if (!strcmp("pc_y_y2x", name)) p_xs_3->pc_y_y2x=
416 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
417 else if (!strcmp("pc_y_y3", name)) p_xs_3->pc_y_y3=
418 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
419 else if (!strcmp("pc4_x_xy3", name)) p_xs_3->pc4_x_xy3=
420 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
421 else if (!strcmp("pc4_x_x3y", name)) p_xs_3->pc4_x_x3y=
422 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
423 else if (!strcmp("pc4_x_x2y2", name)) p_xs_3->pc4_x_x2y2=
424 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
425 else if (!strcmp("pc4_x_x4", name)) p_xs_3->pc4_x_x4=
426 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
427 else if (!strcmp("pc4_x_y4", name)) p_xs_3->pc4_x_y4=
428 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
429 else if (!strcmp("pc4_y_xy3", name)) p_xs_3->pc4_y_xy3=
430 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
431 else if (!strcmp("pc4_y_x3y", name)) p_xs_3->pc4_y_x3y=
432 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
433 else if (!strcmp("pc4_y_x2y2", name)) p_xs_3->pc4_y_x2y2=
434 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
435 else if (!strcmp("pc4_y_x4", name)) p_xs_3->pc4_y_x4=
436 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
437 else if (!strcmp("pc4_y_y4", name)) p_xs_3->pc4_y_y4=
438 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
439 else if (!strcmp("ca_x0", name)) p_xs_3->ca_x0=
440 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
441 else if (!strcmp("ca_x1", name)) p_xs_3->ca_x1=
442 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
443 else if (!strcmp("ca_y0", name)) p_xs_3->ca_y0=
444 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
445 else if (!strcmp("ca_y1", name)) p_xs_3->ca_y1=
446 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
447 else if (!strcmp("d2_x1", name)) p_xs_3->d2_x1=
448 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
449 else if (!strcmp("d2_x2", name)) p_xs_3->d2_x2=
450 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
451 else if (!strcmp("d2_x3", name)) p_xs_3->d2_x3=
452 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
453 else if (!strcmp("d2_y1x0", name)) p_xs_3->d2_y1x0=
454 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
455 else if (!strcmp("d2_y1x1", name)) p_xs_3->d2_y1x1=
456 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
457 else if (!strcmp("d2_y1x2", name)) p_xs_3->d2_y1x2=
458 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
459 else if (!strcmp("d2_y1x3", name)) p_xs_3->d2_y1x3=
460 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
461 else if (!strcmp("d2_y2x0", name)) p_xs_3->d2_y2x0=
462 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
463 else if (!strcmp("d2_y2x1", name)) p_xs_3->d2_y2x1=
464 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
465 else if (!strcmp("d2_y2x2", name)) p_xs_3->d2_y2x2=
466 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
467 else if (!strcmp("d2_y2x3", name)) p_xs_3->d2_y2x3=
468 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
469 else if (!strcmp("d2_y3x0", name)) p_xs_3->d2_y3x0=
470 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
471 else if (!strcmp("d2_y3x1", name)) p_xs_3->d2_y3x1=
472 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
473 else if (!strcmp("d2_y3x2", name)) p_xs_3->d2_y3x2=
474 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
475 else if (!strcmp("d2_y3x3", name)) p_xs_3->d2_y3x3=
476 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
477 else if (!strcmp("offx", name)) p_xs_3->offx =
478 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
479 else if (!strcmp("offy", name)) p_xs_3->offy =
480 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
481 else if (!strcmp("flipx", name)) p_xs_3->flipx =
482 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
483 else if (!strcmp("flipy", name)) p_xs_3->flipy =
484 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
485 else if (!strncmp("slit", name,4)){
486 int islit;
487 for(islit=0; islit <9; islit++){
488 char temp[10];
489
490 sprintf(temp,"slit[%d]",islit);
491 if (!strcmp(name, temp)){
492 p_xs_3->slit[islit]=
493 cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST, i, NULL) ;
494 }
495 }
496 }
497 }
498 p_xs_3->pix_X=p_xs_3->pix_Y=p_xs_3->pix;
499 if (p_xs_3->arm==0) {
500 p_xs_3->morder=UVB_morder;
501 p_xs_3->blaze_pad=UVB_blaze_pad;
505 }
506 else if (p_xs_3->arm==1) {
507 p_xs_3->morder=VIS_morder;
508 p_xs_3->blaze_pad=VIS_blaze_pad;
512 }
513 else if (p_xs_3->arm==2) {
514 p_xs_3->morder=NIR_morder;
515 p_xs_3->blaze_pad=NIR_blaze_pad;
519 }
520 else {
521 return CPL_ERROR_UNSUPPORTED_MODE;
522 }
523 instr_config=xsh_instrument_get_config(instr);
524 p_xs_3->BSIZE=instr_config->ny;
525 p_xs_3->ASIZE=instr_config->nx;
526 p_xs_3->SIZE=p_xs_3->BSIZE;
527 p_xs_3->chipypix=(float)(p_xs_3->BSIZE);
528 p_xs_3->chipxpix=(float)(p_xs_3->ASIZE);
529 p_xs_3->morder_min=instr_config->order_min;
530 p_xs_3->morder_max=instr_config->order_max;
531
532 /* Conversion from DEG to RAD */
533 p_xs_3->mues *= DEG2RAD ;
534 p_xs_3->nues *= DEG2RAD ;
535 p_xs_3->taues *= DEG2RAD ;
536 p_xs_3->cmup1 *= DEG2RAD ;
537 p_xs_3->mup1 *= DEG2RAD ;
538 p_xs_3->nup1 *= DEG2RAD ;
539 p_xs_3->taup1 *= DEG2RAD ;
540 p_xs_3->mup2 *= DEG2RAD ;
541 p_xs_3->nup2 *= DEG2RAD ;
542 p_xs_3->taup2 *= DEG2RAD ;
543 p_xs_3->mup3 *= DEG2RAD ;
544 p_xs_3->nup3 *= DEG2RAD ;
545 p_xs_3->taup3 *= DEG2RAD ;
546 p_xs_3->mup4 *= DEG2RAD ;
547 p_xs_3->nup4 *= DEG2RAD ;
548 p_xs_3->taup4 *= DEG2RAD ;
549 p_xs_3->mup5 *= DEG2RAD ;
550 p_xs_3->nup5 *= DEG2RAD ;
551 p_xs_3->taup5 *= DEG2RAD ;
552 p_xs_3->mup6 *= DEG2RAD ;
553 p_xs_3->nup6 *= DEG2RAD ;
554 p_xs_3->taup6 *= DEG2RAD ;
555 p_xs_3->mug *= DEG2RAD ;
556 p_xs_3->nug *= DEG2RAD ;
557 p_xs_3->taug *= DEG2RAD ;
558 p_xs_3->mud *= DEG2RAD ;
559 p_xs_3->nud *= DEG2RAD ;
560 p_xs_3->taud *= DEG2RAD ;
561 p_xs_3->chiprot *= DEG2RAD ;
562
563 cleanup:
564 XSH_TABLE_FREE( tab) ;
565 xsh_instrument_free(&instr);
566 return cpl_error_get_code();
567
568}
569
570int xsh_model_readfits(double * abest,double * amin,
571 double * amax, int * aname,
572 const char * xs_config_file,
573 const char* xs_config_tag,
574 struct xs_3 *p_xs_3,
575 ann_all_par *p_all_par)
576{
577 int ii,jj,kk,compa, par_found, indlen;
578 char tempstr[10];
579 double d2r;
580
581 cpl_table * tab ;
582 int nlines ;
583 XSH_INSTRCONFIG* instr_config=NULL;
584 xsh_instrument* instr = NULL;
585
586 instr = xsh_instrument_new();
587 p_xs_3->config_mjd=0.0;
588 /*default distortion coefficients in case they are not present */
589 p_xs_3->pc_x_x1=1.0;
590 p_xs_3->pc_y_y1=1.0;
591 p_xs_3->pc_x_xx=0.0;
592 p_xs_3->pc_x_xy=0.0;
593 p_xs_3->pc_x_x3=0.0;
594 p_xs_3->pc_x_y1=0.0;
595 p_xs_3->pc_x_yy=0.0;
596 p_xs_3->pc_x_y3=0.0;
597 p_xs_3->pc_x_x2y=0.0;
598 p_xs_3->pc_x_y2x=0.0;
599 p_xs_3->pc_y_xx=0.0;
600 p_xs_3->pc_y_xy=0.0;
601 p_xs_3->pc_y_x3=0.0;
602 p_xs_3->pc_y_x1=0.0;
603 p_xs_3->pc_y_yy=0.0;
604 p_xs_3->pc_y_y3=0.0;
605 p_xs_3->pc_y_x2y=0.0;
606 p_xs_3->pc_y_y2x=0.0;
607 p_xs_3->pc4_x_x3y=0.0;
608 p_xs_3->pc4_x_xy3=0.0;
609 p_xs_3->pc4_x_x2y2=0.0;
610 p_xs_3->pc4_x_x4=0.0;
611 p_xs_3->pc4_x_y4=0.0;
612 p_xs_3->pc4_y_xy3=0.0;
613 p_xs_3->pc4_y_x3y=0.0;
614 p_xs_3->pc4_y_x2y2=0.0;
615 p_xs_3->pc4_y_x4=0.0;
616 p_xs_3->pc4_y_y4=0.0;
617 p_xs_3->ca_x0=0.0;
618 p_xs_3->ca_x1=0.0;
619 p_xs_3->ca_y0=0.0;
620 p_xs_3->ca_y1=0.0;
621 p_xs_3->d2_x1=0.0;
622 p_xs_3->d2_x2=0.0;
623 p_xs_3->d2_x3=0.0;
624 p_xs_3->d2_y1x0=0.0;
625 p_xs_3->d2_y1x1=0.0;
626 p_xs_3->d2_y1x2=0.0;
627 p_xs_3->d2_y1x3=0.0;
628 p_xs_3->d2_y2x0=0.0;
629 p_xs_3->d2_y2x1=0.0;
630 p_xs_3->d2_y2x2=0.0;
631 p_xs_3->d2_y2x3=0.0;
632 p_xs_3->d2_y3x0=0.0;
633 p_xs_3->d2_y3x1=0.0;
634 p_xs_3->d2_y3x2=0.0;
635 p_xs_3->d2_y3x3=0.0;
636 p_xs_3->offx=0.0;
637 p_xs_3->offy=0.0;
638
639 if (strncmp(xs_config_tag,XSH_MOD_CFG_NIR,16)==0 ||
640 strncmp(xs_config_tag,XSH_MOD_CFG_TAB_NIR,20)==0) {
641 p_xs_3->pc4_x_x3y=0.0;
642 p_xs_3->pc4_x_xy3=0.0;
643 p_xs_3->pc4_x_x2y2=0.0;
644 p_xs_3->pc4_x_x4=0.0;
645 p_xs_3->pc4_x_y4=0.0;
646 p_xs_3->pc4_y_xy3=0.0;
647 p_xs_3->pc4_y_x3y=0.0;
648 p_xs_3->pc4_y_x2y2=0.0;
649 p_xs_3->pc4_y_x4=0.0;
650 p_xs_3->pc4_y_y4=0.0;
651 p_xs_3->ca_x0=0.0;
652 p_xs_3->ca_x1=0.0;
653 p_xs_3->ca_y0=0.0;
654 p_xs_3->ca_y1=0.0;
655 p_xs_3->offx=0.0;
656 p_xs_3->offy=0.0;
657 }
658 else if (strncmp(xs_config_tag,XSH_MOD_CFG_VIS,16)==0 ||
659 strncmp(xs_config_tag,XSH_MOD_CFG_TAB_VIS,20)==0) {
660 p_xs_3->d2_x1=0.00287311525385538;
661 p_xs_3->d2_x2=1.55125984130817E-05;
662 p_xs_3->d2_x3=-4.00980399239143E-05;
663 }
664 else if (strncmp(xs_config_tag,XSH_MOD_CFG_UVB,16)==0 ||
665 strncmp(xs_config_tag,XSH_MOD_CFG_TAB_UVB,20)==0) {
666 p_xs_3->d2_x1=0.0;
667 p_xs_3->d2_x2=0.0;
668 p_xs_3->d2_x3=0.0;
669 }
670
671
672
673 xsh_msg("tag=%s",xs_config_tag);
674
675 /* Load the table */
676 if ((tab = xsh_load_table_check(xs_config_file,xs_config_tag)) == NULL) {
677 cpl_msg_error(__func__, "Cannot load the config table") ;
678 return -1 ;
679 }
680 nlines = cpl_table_get_nrow(tab) ;
681
682 for (ii=0 ; ii<nlines ; ii++) {
683 (p_all_par+ii)->best=cpl_table_get_double(tab, XSH_COL_MODEL_CONF_BEST,
684 ii, NULL) ;
685 (p_all_par+ii)->min = cpl_table_get_double(tab, XSH_COL_MODEL_CONF_LOW,
686 ii, NULL) ;
687 (p_all_par+ii)->max = cpl_table_get_double(tab,XSH_COL_MODEL_CONF_HIGH,
688 ii, NULL) ;
689 (p_all_par+ii)->flag = cpl_table_get_int(tab, XSH_COL_MODEL_CONF_FLAG,
690 ii, NULL) ;
691 sprintf((p_all_par+ii)->name, (char*)cpl_table_get_string(tab,
693 if ((p_all_par+ii)->flag==1) {
694 if ((p_all_par+ii)->best<(p_all_par+ii)->min ||
695 (p_all_par+ii)->best>(p_all_par+ii)->max) {
696 printf("limits wrong in config file for parameter: %s \n",
697 (p_all_par+ii)->name);
698 abort();
699 }
700 }
701 }
702 xsh_free_table(&tab);
703 jj=0;
704 for (ii=0 ; ii<nlines ; ii++) {
705 d2r=1.0;
706 par_found=0;
707/*below the number of char in the variable name MUST be given to strncmp*/
708 compa=strncmp((p_all_par+ii)->name,"arm",3);
709 if (compa==0) {
710 p_xs_3->arm=(p_all_par+ii)->best;
711 par_found=1;
712 }
713 compa=strncmp((p_all_par+ii)->name,"temper",6);
714 if (compa==0) {
715 p_xs_3->temper=(p_all_par+ii)->best;
716 par_found=1;
717 }
718 compa=strncmp((p_all_par+ii)->name,"arm",3);
719 if (compa==0) {
720 p_xs_3->arm=(p_all_par+ii)->best;
721 par_found=1;
722 }
723 compa=strncmp((p_all_par+ii)->name,"config_mjd",10);
724 if (compa==0) {
725 p_xs_3->config_mjd=(p_all_par+ii)->best;
726 par_found=1;
727 }
728 compa=strncmp((p_all_par+ii)->name,"t_ir_p2",7);
729 if (compa==0) {
730 p_xs_3->t_ir_p2=(p_all_par+ii)->best;
731 par_found=1;
732 }
733 compa=strncmp((p_all_par+ii)->name,"t_ir_p3",7);
734 if (compa==0) {
735 p_xs_3->t_ir_p3=(p_all_par+ii)->best;
736 par_found=1;
737 }
738 compa=strncmp((p_all_par+ii)->name,"es_x",4);
739 if (compa==0) {
740 p_xs_3->es_x=(p_all_par+ii)->best;
741 par_found=1;
742 }
743 compa=strncmp((p_all_par+ii)->name,"es_y",4);
744 if (compa==0) {
745 p_xs_3->es_y=(p_all_par+ii)->best;
746 par_found=1;
747 }
748 compa=strncmp((p_all_par+ii)->name,"mues",4);
749 if (compa==0) {
750 d2r=DEG2RAD;
751 p_xs_3->mues=(p_all_par+ii)->best*d2r;
752 par_found=1;
753 }
754 compa=strncmp((p_all_par+ii)->name,"nues",4);
755 if (compa==0) {
756 d2r=DEG2RAD;
757 p_xs_3->nues=(p_all_par+ii)->best*d2r;
758 par_found=1;
759 }
760 compa=strncmp((p_all_par+ii)->name,"taues",5);
761 if (compa==0) {
762 d2r=DEG2RAD;
763 p_xs_3->taues=(p_all_par+ii)->best*d2r;
764 par_found=1;
765 }
766 compa=strncmp((p_all_par+ii)->name,"slit_scale",10);
767 if (compa==0) {
768 d2r=DEG2RAD;
769 p_xs_3->slit_scale=(p_all_par+ii)->best;
770 par_found=1;
771 }
772 compa=strncmp((p_all_par+ii)->name,"es_s",4);
773 if (compa==0) {
774 p_xs_3->es_s=(p_all_par+ii)->best;
775 par_found=1;
776 }
777 compa=strncmp((p_all_par+ii)->name,"es_w",4);
778 if (compa==0) {
779 p_xs_3->es_w=(p_all_par+ii)->best;
780 par_found=1;
781 }
782 compa=strncmp((p_all_par+ii)->name,"fcol",4);
783 if (compa==0) {
784 p_xs_3->fcol=(p_all_par+ii)->best;
785 par_found=1;
786 }
787 compa=strncmp((p_all_par+ii)->name,"cmup1",5);
788 if (compa==0) {
789 d2r=DEG2RAD;
790 p_xs_3->cmup1=(p_all_par+ii)->best*d2r;
791 par_found=1;
792 }
793 compa=strncmp((p_all_par+ii)->name,"mup1",4);
794 if (compa==0) {
795 d2r=DEG2RAD;
796 p_xs_3->mup1=(p_all_par+ii)->best*d2r;
797 par_found=1;
798 }
799 compa=strncmp((p_all_par+ii)->name,"nup1",4);
800 if (compa==0) {
801 d2r=DEG2RAD;
802 p_xs_3->nup1=(p_all_par+ii)->best*d2r;
803 par_found=1;
804 }
805 compa=strncmp((p_all_par+ii)->name,"taup1",5);
806 if (compa==0) {
807 d2r=DEG2RAD;
808 p_xs_3->taup1=(p_all_par+ii)->best*d2r;
809 par_found=1;
810 }
811 compa=strncmp((p_all_par+ii)->name,"mup2",4);
812 if (compa==0) {
813 d2r=DEG2RAD;
814 p_xs_3->mup2=(p_all_par+ii)->best*d2r;
815 par_found=1;
816 }
817 compa=strncmp((p_all_par+ii)->name,"nup2",4);
818 if (compa==0) {
819 d2r=DEG2RAD;
820 p_xs_3->nup2=(p_all_par+ii)->best*d2r;
821 par_found=1;
822 }
823 compa=strncmp((p_all_par+ii)->name,"taup2",5);
824 if (compa==0) {
825 d2r=DEG2RAD;
826 p_xs_3->taup2=(p_all_par+ii)->best*d2r;
827 par_found=1;
828 }
829 compa=strncmp((p_all_par+ii)->name,"mup3",4);
830 if (compa==0) {
831 d2r=DEG2RAD;
832 p_xs_3->mup3=(p_all_par+ii)->best*d2r;
833 par_found=1;
834 }
835 compa=strncmp((p_all_par+ii)->name,"nup3",4);
836 if (compa==0) {
837 d2r=DEG2RAD;
838 p_xs_3->nup3=(p_all_par+ii)->best*d2r;
839 par_found=1;
840 }
841 compa=strncmp((p_all_par+ii)->name,"taup3",5);
842 if (compa==0) {
843 d2r=DEG2RAD;
844 p_xs_3->taup3=(p_all_par+ii)->best*d2r;
845 par_found=1;
846 }
847 compa=strncmp((p_all_par+ii)->name,"mup4",4);
848 if (compa==0) {
849 d2r=DEG2RAD;
850 p_xs_3->mup4=(p_all_par+ii)->best*d2r;
851 par_found=1;
852 }
853 compa=strncmp((p_all_par+ii)->name,"nup4",4);
854 if (compa==0) {
855 d2r=DEG2RAD;
856 p_xs_3->nup4=(p_all_par+ii)->best*d2r;
857 par_found=1;
858 }
859 compa=strncmp((p_all_par+ii)->name,"taup4",5);
860 if (compa==0) {
861 d2r=DEG2RAD;
862 p_xs_3->taup4=(p_all_par+ii)->best*d2r;
863 par_found=1;
864 }
865 compa=strncmp((p_all_par+ii)->name,"mup5",4);
866 if (compa==0) {
867 d2r=DEG2RAD;
868 p_xs_3->mup5=(p_all_par+ii)->best*d2r;
869 par_found=1;
870 }
871 compa=strncmp((p_all_par+ii)->name,"nup5",4);
872 if (compa==0) {
873 d2r=DEG2RAD;
874 p_xs_3->nup5=(p_all_par+ii)->best*d2r;
875 par_found=1;
876 }
877 compa=strncmp((p_all_par+ii)->name,"taup5",5);
878 if (compa==0) {
879 d2r=DEG2RAD;
880 p_xs_3->taup5=(p_all_par+ii)->best*d2r;
881 par_found=1;
882 }
883 compa=strncmp((p_all_par+ii)->name,"mup6",4);
884 if (compa==0) {
885 d2r=DEG2RAD;
886 p_xs_3->mup6=(p_all_par+ii)->best*d2r;
887 par_found=1;
888 }
889 compa=strncmp((p_all_par+ii)->name,"nup6",4);
890 if (compa==0) {
891 d2r=DEG2RAD;
892 p_xs_3->nup6=(p_all_par+ii)->best*d2r;
893 par_found=1;
894 }
895 compa=strncmp((p_all_par+ii)->name,"taup6",5);
896 if (compa==0) {
897 d2r=DEG2RAD;
898 p_xs_3->taup6=(p_all_par+ii)->best*d2r;
899 par_found=1;
900 }
901 compa=strncmp((p_all_par+ii)->name,"mug",3);
902 if (compa==0) {
903 d2r=DEG2RAD;
904 p_xs_3->mug=(p_all_par+ii)->best*d2r;
905 par_found=1;
906 }
907 compa=strncmp((p_all_par+ii)->name,"nug",3);
908 if (compa==0) {
909 d2r=DEG2RAD;
910 p_xs_3->nug=(p_all_par+ii)->best*d2r;
911 par_found=1;
912 }
913 compa=strncmp((p_all_par+ii)->name,"taug",4);
914 if (compa==0) {
915 d2r=DEG2RAD;
916 p_xs_3->taug=(p_all_par+ii)->best*d2r;
917 par_found=1;
918 }
919 compa=strncmp((p_all_par+ii)->name,"sg",2);
920 if (compa==0) {
921 p_xs_3->sg=(p_all_par+ii)->best;
922 par_found=1;
923 }
924 compa=strncmp((p_all_par+ii)->name,"fdet",4);
925 if (compa==0) {
926 p_xs_3->fdet=(p_all_par+ii)->best;
927 par_found=1;
928 }
929 compa=strncmp((p_all_par+ii)->name,"mud",3);
930 if (compa==0) {
931 d2r=DEG2RAD;
932 p_xs_3->mud=(p_all_par+ii)->best*d2r;
933 par_found=1;
934 }
935 compa=strncmp((p_all_par+ii)->name,"nud",3);
936 if (compa==0) {
937 d2r=DEG2RAD;
938 p_xs_3->nud=(p_all_par+ii)->best*d2r;
939 par_found=1;
940 }
941 compa=strncmp((p_all_par+ii)->name,"taud",4);
942 if (compa==0) {
943 d2r=DEG2RAD;
944 p_xs_3->taud=(p_all_par+ii)->best*d2r;
945 par_found=1;
946 }
947 compa=strncmp((p_all_par+ii)->name,"pix",3);
948 if (compa==0) {
949 p_xs_3->pix=(p_all_par+ii)->best;
950 par_found=1;
951 }
952 compa=strncmp((p_all_par+ii)->name,"chipx",5);
953 if (compa==0) {
954 p_xs_3->chipx=(p_all_par+ii)->best;
955 par_found=1;
956 }
957 compa=strncmp((p_all_par+ii)->name,"chipy",5);
958 if (compa==0) {
959 p_xs_3->chipy=(p_all_par+ii)->best;
960 par_found=1;
961 }
962 compa=strncmp((p_all_par+ii)->name,"chiprot",7);
963 if (compa==0) {
964 d2r=DEG2RAD;
965 p_xs_3->chiprot=(p_all_par+ii)->best*d2r;
966 par_found=1;
967 }
968 compa=strncmp((p_all_par+ii)->name,"pc_x_xx",7);
969 if (compa==0) {
970 p_xs_3->pc_x_xx=(p_all_par+ii)->best;
971 par_found=1;
972 }
973 compa=strncmp((p_all_par+ii)->name,"pc_x_x1",7);
974 if (compa==0) {
975 p_xs_3->pc_x_x1=(p_all_par+ii)->best;
976 par_found=1;
977 }
978 compa=strncmp((p_all_par+ii)->name,"pc_x_yy",7);
979 if (compa==0) {
980 p_xs_3->pc_x_yy=(p_all_par+ii)->best;
981 par_found=1;
982 }
983 compa=strncmp((p_all_par+ii)->name,"pc_x_y1",7);
984 if (compa==0) {
985 p_xs_3->pc_x_y1=(p_all_par+ii)->best;
986 par_found=1;
987 }
988 compa=strncmp((p_all_par+ii)->name,"pc_x_xy",7);
989 if (compa==0) {
990 p_xs_3->pc_x_xy=(p_all_par+ii)->best;
991 par_found=1;
992 }
993 compa=strncmp((p_all_par+ii)->name,"pc_x_x3",7);
994 if (compa==0) {
995 p_xs_3->pc_x_x3=(p_all_par+ii)->best;
996 par_found=1;
997 }
998 compa=strncmp((p_all_par+ii)->name,"pc_x_x2y",8);
999 if (compa==0) {
1000 p_xs_3->pc_x_x2y=(p_all_par+ii)->best;
1001 par_found=1;
1002 }
1003 compa=strncmp((p_all_par+ii)->name,"pc_x_y2x",8);
1004 if (compa==0) {
1005 p_xs_3->pc_x_y2x=(p_all_par+ii)->best;
1006 par_found=1;
1007 }
1008 compa=strncmp((p_all_par+ii)->name,"pc_x_y3",7);
1009 if (compa==0) {
1010 p_xs_3->pc_x_y3=(p_all_par+ii)->best;
1011 par_found=1;
1012 }
1013 compa=strncmp((p_all_par+ii)->name,"pc_y_xx",7);
1014 if (compa==0) {
1015 p_xs_3->pc_y_xx=(p_all_par+ii)->best;
1016 par_found=1;
1017 }
1018 compa=strncmp((p_all_par+ii)->name,"pc_y_x1",7);
1019 if (compa==0) {
1020 p_xs_3->pc_y_x1=(p_all_par+ii)->best;
1021 par_found=1;
1022 }
1023 compa=strncmp((p_all_par+ii)->name,"pc_y_yy",7);
1024 if (compa==0) {
1025 p_xs_3->pc_y_yy=(p_all_par+ii)->best;
1026 par_found=1;
1027 }
1028 compa=strncmp((p_all_par+ii)->name,"pc_y_y1",7);
1029 if (compa==0) {
1030 p_xs_3->pc_y_y1=(p_all_par+ii)->best;
1031 par_found=1;
1032 }
1033 compa=strncmp((p_all_par+ii)->name,"pc_y_xy",7);
1034 if (compa==0) {
1035 p_xs_3->pc_y_xy=(p_all_par+ii)->best;
1036 par_found=1;
1037 }
1038 compa=strncmp((p_all_par+ii)->name,"pc_y_x3",7);
1039 if (compa==0) {
1040 p_xs_3->pc_y_x3=(p_all_par+ii)->best;
1041 par_found=1;
1042 }
1043 compa=strncmp((p_all_par+ii)->name,"pc_y_x2y",8);
1044 if (compa==0) {
1045 p_xs_3->pc_y_x2y=(p_all_par+ii)->best;
1046 par_found=1;
1047 }
1048 compa=strncmp((p_all_par+ii)->name,"pc_y_y2x",8);
1049 if (compa==0) {
1050 p_xs_3->pc_y_y2x=(p_all_par+ii)->best;
1051 par_found=1;
1052 }
1053 compa=strncmp((p_all_par+ii)->name,"pc_y_y3",7);
1054 if (compa==0) {
1055 p_xs_3->pc_y_y3=(p_all_par+ii)->best;
1056 par_found=1;
1057 }
1058 compa=strncmp((p_all_par+ii)->name,"pc4_x_xy3",9);
1059 if (compa==0) {
1060 p_xs_3->pc4_x_xy3=(p_all_par+ii)->best;
1061 par_found=1;
1062 }
1063 compa=strncmp((p_all_par+ii)->name,"pc4_x_x3y",9);
1064 if (compa==0) {
1065 p_xs_3->pc4_x_x3y=(p_all_par+ii)->best;
1066 par_found=1;
1067 }
1068 compa=strncmp((p_all_par+ii)->name,"pc4_x_x2y2",10);
1069 if (compa==0) {
1070 p_xs_3->pc4_x_x2y2=(p_all_par+ii)->best;
1071 par_found=1;
1072 }
1073 compa=strncmp((p_all_par+ii)->name,"pc4_x_x4",8);
1074 if (compa==0) {
1075 p_xs_3->pc4_x_x4=(p_all_par+ii)->best;
1076 par_found=1;
1077 }
1078 compa=strncmp((p_all_par+ii)->name,"pc4_x_y4",8);
1079 if (compa==0) {
1080 p_xs_3->pc4_x_y4=(p_all_par+ii)->best;
1081 par_found=1;
1082 }
1083 compa=strncmp((p_all_par+ii)->name,"pc4_y_xy3",9);
1084 if (compa==0) {
1085 p_xs_3->pc4_y_xy3=(p_all_par+ii)->best;
1086 par_found=1;
1087 }
1088 compa=strncmp((p_all_par+ii)->name,"pc4_y_x3y",9);
1089 if (compa==0) {
1090 p_xs_3->pc4_y_x3y=(p_all_par+ii)->best;
1091 par_found=1;
1092 }
1093 compa=strncmp((p_all_par+ii)->name,"pc4_y_x2y2",10);
1094 if (compa==0) {
1095 p_xs_3->pc4_y_x2y2=(p_all_par+ii)->best;
1096 par_found=1;
1097 }
1098 compa=strncmp((p_all_par+ii)->name,"pc4_y_x4",8);
1099 if (compa==0) {
1100 p_xs_3->pc4_y_x4=(p_all_par+ii)->best;
1101 par_found=1;
1102 }
1103 compa=strncmp((p_all_par+ii)->name,"pc4_y_y4",8);
1104 if (compa==0) {
1105 p_xs_3->pc4_y_y4=(p_all_par+ii)->best;
1106 par_found=1;
1107 }
1108 compa=strncmp((p_all_par+ii)->name,"ca_x0",5);
1109 if (compa==0) {
1110 p_xs_3->ca_x0=(p_all_par+ii)->best;
1111 par_found=1;
1112 }
1113 compa=strncmp((p_all_par+ii)->name,"ca_x1",5);
1114 if (compa==0) {
1115 p_xs_3->ca_x1=(p_all_par+ii)->best;
1116 par_found=1;
1117 }
1118 compa=strncmp((p_all_par+ii)->name,"ca_y0",5);
1119 if (compa==0) {
1120 p_xs_3->ca_y0=(p_all_par+ii)->best;
1121 par_found=1;
1122 }
1123 compa=strncmp((p_all_par+ii)->name,"ca_y1",5);
1124 if (compa==0) {
1125 p_xs_3->ca_y1=(p_all_par+ii)->best;
1126 par_found=1;
1127 }
1128 compa=strncmp((p_all_par+ii)->name,"d2_x1",5);
1129 if (compa==0) {
1130 p_xs_3->d2_x1=(p_all_par+ii)->best;
1131 par_found=1;
1132 }
1133 compa=strncmp((p_all_par+ii)->name,"d2_x2",5);
1134 if (compa==0) {
1135 p_xs_3->d2_x2=(p_all_par+ii)->best;
1136 par_found=1;
1137 }
1138 compa=strncmp((p_all_par+ii)->name,"d2_x3",5);
1139 if (compa==0) {
1140 p_xs_3->d2_x3=(p_all_par+ii)->best;
1141 par_found=1;
1142 }
1143 compa=strncmp((p_all_par+ii)->name,"d2_y1x0",7);
1144 if (compa==0) {
1145 p_xs_3->d2_y1x0=(p_all_par+ii)->best;
1146 par_found=1;
1147 }
1148 compa=strncmp((p_all_par+ii)->name,"d2_y1x1",7);
1149 if (compa==0) {
1150 p_xs_3->d2_y1x1=(p_all_par+ii)->best;
1151 par_found=1;
1152 }
1153 compa=strncmp((p_all_par+ii)->name,"d2_y1x2",7);
1154 if (compa==0) {
1155 p_xs_3->d2_y1x2=(p_all_par+ii)->best;
1156 par_found=1;
1157 }
1158 compa=strncmp((p_all_par+ii)->name,"d2_y1x3",7);
1159 if (compa==0) {
1160 p_xs_3->d2_y1x3=(p_all_par+ii)->best;
1161 par_found=1;
1162 }
1163 compa=strncmp((p_all_par+ii)->name,"d2_y2x0",7);
1164 if (compa==0) {
1165 p_xs_3->d2_y2x0=(p_all_par+ii)->best;
1166 par_found=1;
1167 }
1168 compa=strncmp((p_all_par+ii)->name,"d2_y2x1",7);
1169 if (compa==0) {
1170 p_xs_3->d2_y2x1=(p_all_par+ii)->best;
1171 par_found=1;
1172 }
1173 compa=strncmp((p_all_par+ii)->name,"d2_y2x2",7);
1174 if (compa==0) {
1175 p_xs_3->d2_y2x2=(p_all_par+ii)->best;
1176 par_found=1;
1177 }
1178 compa=strncmp((p_all_par+ii)->name,"d2_y2x3",7);
1179 if (compa==0) {
1180 p_xs_3->d2_y2x3=(p_all_par+ii)->best;
1181 par_found=1;
1182 }
1183 compa=strncmp((p_all_par+ii)->name,"d2_y3x0",7);
1184 if (compa==0) {
1185 p_xs_3->d2_y3x0=(p_all_par+ii)->best;
1186 par_found=1;
1187 }
1188 compa=strncmp((p_all_par+ii)->name,"d2_y3x1",7);
1189 if (compa==0) {
1190 p_xs_3->d2_y3x1=(p_all_par+ii)->best;
1191 par_found=1;
1192 }
1193 compa=strncmp((p_all_par+ii)->name,"d2_y3x2",7);
1194 if (compa==0) {
1195 p_xs_3->d2_y3x2=(p_all_par+ii)->best;
1196 par_found=1;
1197 }
1198 compa=strncmp((p_all_par+ii)->name,"d2_y3x3",7);
1199 if (compa==0) {
1200 p_xs_3->d2_y3x3=(p_all_par+ii)->best;
1201 par_found=1;
1202 }
1203 compa=strncmp((p_all_par+ii)->name,"offx",4);
1204 if (compa==0) {
1205 p_xs_3->offx=(p_all_par+ii)->best;
1206 par_found=1;
1207 }
1208 compa=strncmp((p_all_par+ii)->name,"offy",4);
1209 if (compa==0) {
1210 p_xs_3->offy=(p_all_par+ii)->best;
1211 par_found=1;
1212 }
1213 compa=strncmp((p_all_par+ii)->name,"flipx",5);
1214 if (compa==0) {
1215 p_xs_3->flipx=(p_all_par+ii)->best;
1216 par_found=1;
1217 }
1218 compa=strncmp((p_all_par+ii)->name,"flipy",5);
1219 if (compa==0) {
1220 p_xs_3->flipy=(p_all_par+ii)->best;
1221 par_found=1;
1222 }
1223 for (kk=0;kk<9;kk++) {
1224 sprintf(tempstr,"slit[%d]",kk);
1225 indlen=strlen(tempstr);
1226 compa=strncmp((p_all_par+ii)->name,tempstr,indlen);
1227 if (compa==0) {
1228 p_xs_3->slit[kk]=(p_all_par+ii)->best;
1229 par_found=1;
1230 }
1231 }
1232 if (par_found==1) {
1233 if ((p_all_par+ii)->flag!=0) {
1234 abest[jj]=(p_all_par+ii)->best;
1235 amin[jj]=(p_all_par+ii)->min;
1236 amax[jj]=(p_all_par+ii)->max;
1237 aname[jj]=ii;
1238 printf("%d %s %d \n", ii, (p_all_par+ii)->name, jj);
1239 jj++;
1240 }
1241 }
1242 }
1243 if (p_xs_3->arm==0) {
1244 p_xs_3->morder=UVB_morder;
1245 p_xs_3->blaze_pad=UVB_blaze_pad;
1247 p_xs_3->xsize_corr=UVB_xsize_corr;
1248 p_xs_3->ysize_corr=UVB_ysize_corr;
1249 }
1250 else if (p_xs_3->arm==1) {
1251 p_xs_3->morder=VIS_morder;
1252 p_xs_3->blaze_pad=VIS_blaze_pad;
1254 p_xs_3->xsize_corr=VIS_xsize_corr;
1255 p_xs_3->ysize_corr=VIS_ysize_corr;
1256 }
1257 else if (p_xs_3->arm==2) {
1258 p_xs_3->morder=NIR_morder;
1259 p_xs_3->blaze_pad=NIR_blaze_pad;
1261 p_xs_3->xsize_corr=NIR_xsize_corr;
1262 p_xs_3->ysize_corr=NIR_ysize_corr;
1263 }
1264 else {
1265 return -1;
1266 }
1267 instr_config=xsh_instrument_get_config(instr);
1268 p_xs_3->BSIZE=instr_config->ny;
1269 p_xs_3->ASIZE=instr_config->nx;
1270 p_xs_3->SIZE=p_xs_3->BSIZE;
1271 p_xs_3->chipypix=(float)(p_xs_3->BSIZE);
1272 p_xs_3->chipxpix=(float)(p_xs_3->ASIZE);
1273 p_xs_3->morder_min=instr_config->order_min;
1274 p_xs_3->morder_max=instr_config->order_max;
1275
1276 p_xs_3->pix_X=p_xs_3->pix_Y=p_xs_3->pix;
1277
1278 xsh_instrument_free(&instr);
1279
1280 return jj;
1281}
1282
1283#define xsh_model_config_enter(name, val, index, units) \
1284 cpl_table_set_string(tab, XSH_COL_MODEL_CONF_NAME, index, name) ; \
1285 cpl_table_set_double(tab, XSH_COL_MODEL_CONF_BEST, index, val) ; \
1286 cpl_table_set_double(tab, XSH_COL_MODEL_CONF_LOW, index, val) ; \
1287 cpl_table_set_double(tab, XSH_COL_MODEL_CONF_HIGH, index, val) ; \
1288 cpl_table_set_int(tab, XSH_COL_MODEL_CONF_FLAG, index, 0) ; \
1289 cpl_table_set_string(tab, XSH_COL_MODEL_CONF_UNITS, index, units) ;
1290
1291cpl_table * xsh_model_io_output_cfg(struct xs_3 *p_xs_3)
1292{
1293 cpl_table * tab ;
1294 char tempstr[10];
1295 int nb_parameters ;
1296 int i, j ;
1297
1298 /* Initialise */
1299 nb_parameters = 91 ;
1300
1301 /* Create the table */
1302 tab = cpl_table_new(nb_parameters) ;
1303 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_BEST, CPL_TYPE_DOUBLE) ;
1304 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_LOW, CPL_TYPE_DOUBLE) ;
1305 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_HIGH, CPL_TYPE_DOUBLE) ;
1306 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_FLAG, CPL_TYPE_INT) ;
1307 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_NAME, CPL_TYPE_STRING) ;
1308 cpl_table_new_column(tab, XSH_COL_MODEL_CONF_UNITS, CPL_TYPE_STRING) ;
1309
1310 i = 0 ;
1311 xsh_model_config_enter("arm", p_xs_3->arm, i, NULL) ; i++ ;
1312 xsh_model_config_enter("temper", p_xs_3->temper, i,"K") ; i++ ;
1313 xsh_model_config_enter("t_ir_p2", p_xs_3->t_ir_p2, i,"K") ; i++ ;
1314 xsh_model_config_enter("t_ir_p3", p_xs_3->t_ir_p3, i,"K") ; i++ ;
1315 xsh_model_config_enter("es_x", p_xs_3->es_x, i,"mm") ; i++ ;
1316 xsh_model_config_enter("es_y", p_xs_3->es_y, i,"mm") ; i++ ;
1317 xsh_model_config_enter("mues", p_xs_3->mues/DEG2RAD, i,"deg") ; i++ ;
1318 xsh_model_config_enter("nues", p_xs_3->nues/DEG2RAD, i,"deg") ; i++ ;
1319 xsh_model_config_enter("taues", p_xs_3->taues/DEG2RAD,i,"deg") ; i++ ;
1320 xsh_model_config_enter("slit_scale", p_xs_3->slit_scale,i,"mm/\"") ; i++ ;
1321 xsh_model_config_enter("es_s", p_xs_3->es_s, i,"mm") ; i++ ;
1322 xsh_model_config_enter("es_w", p_xs_3->es_w, i,"mm") ; i++ ;
1323 xsh_model_config_enter("fcol", p_xs_3->fcol, i,"mm") ; i++ ;
1324 xsh_model_config_enter("cmup1", p_xs_3->cmup1/DEG2RAD, i,"deg") ; i++ ;
1325 xsh_model_config_enter("mup1", p_xs_3->mup1/DEG2RAD, i,"deg") ; i++ ;
1326 xsh_model_config_enter("nup1", p_xs_3->nup1/DEG2RAD, i,"deg") ; i++ ;
1327 xsh_model_config_enter("taup1", p_xs_3->taup1/DEG2RAD, i,"deg") ; i++ ;
1328 xsh_model_config_enter("mup2", p_xs_3->mup2/DEG2RAD, i,"deg") ; i++ ;
1329 xsh_model_config_enter("nup2", p_xs_3->nup2/DEG2RAD, i,"deg") ; i++ ;
1330 xsh_model_config_enter("taup2", p_xs_3->taup2/DEG2RAD, i,"deg") ; i++ ;
1331 xsh_model_config_enter("mup3", p_xs_3->mup3/DEG2RAD, i,"deg") ; i++ ;
1332 xsh_model_config_enter("nup3", p_xs_3->nup3/DEG2RAD, i,"deg") ; i++ ;
1333 xsh_model_config_enter("taup3", p_xs_3->taup3/DEG2RAD, i,"deg") ; i++ ;
1334 xsh_model_config_enter("mup4", p_xs_3->mup4/DEG2RAD, i,"deg") ; i++ ;
1335 xsh_model_config_enter("nup4", p_xs_3->nup4/DEG2RAD, i,"deg") ; i++ ;
1336 xsh_model_config_enter("taup4", p_xs_3->taup4/DEG2RAD, i,"deg") ; i++ ;
1337 xsh_model_config_enter("mup5", p_xs_3->mup5/DEG2RAD, i,"deg") ; i++ ;
1338 xsh_model_config_enter("nup5", p_xs_3->nup5/DEG2RAD, i,"deg") ; i++ ;
1339 xsh_model_config_enter("taup5", p_xs_3->taup5/DEG2RAD, i,"deg") ; i++ ;
1340 xsh_model_config_enter("mup6", p_xs_3->mup6/DEG2RAD, i,"deg") ; i++ ;
1341 xsh_model_config_enter("nup6", p_xs_3->nup6/DEG2RAD, i,"deg") ; i++ ;
1342 xsh_model_config_enter("taup6", p_xs_3->taup6/DEG2RAD, i,"deg") ; i++ ;
1343 xsh_model_config_enter("mug", p_xs_3->mug/DEG2RAD, i,"deg") ; i++ ;
1344 xsh_model_config_enter("nug", p_xs_3->nug/DEG2RAD, i,"deg") ; i++ ;
1345 xsh_model_config_enter("taug", p_xs_3->taug/DEG2RAD, i,"deg") ; i++ ;
1346 xsh_model_config_enter("sg", p_xs_3->sg, i,"mm-1") ; i++ ;
1347 xsh_model_config_enter("fdet", p_xs_3->fdet, i,"mm") ; i++ ;
1348 xsh_model_config_enter("mud", p_xs_3->mud/DEG2RAD, i,"deg") ; i++ ;
1349 xsh_model_config_enter("nud", p_xs_3->nud/DEG2RAD, i,"deg") ; i++ ;
1350 xsh_model_config_enter("taud", p_xs_3->taud/DEG2RAD, i,"deg") ; i++ ;
1351 xsh_model_config_enter("pix", p_xs_3->pix, i,"mm") ; i++ ;
1352 xsh_model_config_enter("chipx", p_xs_3->chipx, i,"mm") ; i++ ;
1353 xsh_model_config_enter("chipy", p_xs_3->chipy, i,"mm") ; i++ ;
1354 xsh_model_config_enter("chiprot", p_xs_3->chiprot/DEG2RAD,i,"deg");i++;
1355 xsh_model_config_enter("pc_x_xx", p_xs_3->pc_x_xx, i,NULL) ; i++ ;
1356 xsh_model_config_enter("pc_x_x1", p_xs_3->pc_x_x1, i,NULL) ; i++ ;
1357 xsh_model_config_enter("pc_x_yy", p_xs_3->pc_x_yy, i,NULL) ; i++ ;
1358 xsh_model_config_enter("pc_x_y1", p_xs_3->pc_x_y1, i,NULL) ; i++ ;
1359 xsh_model_config_enter("pc_x_xy", p_xs_3->pc_x_xy, i,NULL) ; i++ ;
1360 xsh_model_config_enter("pc_x_x3", p_xs_3->pc_x_x3, i,NULL) ; i++ ;
1361 xsh_model_config_enter("pc_x_x2y", p_xs_3->pc_x_x2y, i,NULL) ; i++ ;
1362 xsh_model_config_enter("pc_x_y2x", p_xs_3->pc_x_y2x, i,NULL) ; i++ ;
1363 xsh_model_config_enter("pc_x_y3", p_xs_3->pc_x_y3, i,NULL) ; i++ ;
1364 xsh_model_config_enter("pc_y_xx", p_xs_3->pc_y_xx, i,NULL) ; i++ ;
1365 xsh_model_config_enter("pc_y_x1", p_xs_3->pc_y_x1, i,NULL) ; i++ ;
1366 xsh_model_config_enter("pc_y_yy", p_xs_3->pc_y_yy, i,NULL) ; i++ ;
1367 xsh_model_config_enter("pc_y_y1", p_xs_3->pc_y_y1, i,NULL) ; i++ ;
1368 xsh_model_config_enter("pc_y_xy", p_xs_3->pc_y_xy, i,NULL) ; i++ ;
1369 xsh_model_config_enter("pc_y_x3", p_xs_3->pc_y_x3, i,NULL) ; i++ ;
1370 xsh_model_config_enter("pc_y_x2y", p_xs_3->pc_y_x2y, i,NULL) ; i++ ;
1371 xsh_model_config_enter("pc_y_y2x", p_xs_3->pc_y_y2x, i,NULL) ; i++ ;
1372 xsh_model_config_enter("pc_y_y3", p_xs_3->pc_y_y3, i,NULL) ; i++ ;
1373 if (p_xs_3->arm==2 && p_xs_3->d2_y1x0==0.0) {
1374 xsh_model_config_enter("pc4_x_xy3", p_xs_3->pc4_x_xy3, i,NULL) ; i++ ;
1375 xsh_model_config_enter("pc4_x_x3y", p_xs_3->pc4_x_x3y, i,NULL) ; i++ ;
1376 xsh_model_config_enter("pc4_x_x2y2", p_xs_3->pc4_x_x2y2, i,NULL) ; i++ ;
1377 xsh_model_config_enter("pc4_x_x4", p_xs_3->pc4_x_x4, i,NULL) ; i++ ;
1378 xsh_model_config_enter("pc4_x_y4", p_xs_3->pc4_x_y4, i,NULL) ; i++ ;
1379 xsh_model_config_enter("pc4_y_xy3", p_xs_3->pc4_y_xy3, i,NULL) ; i++ ;
1380 xsh_model_config_enter("pc4_y_x3y", p_xs_3->pc4_y_x3y, i,NULL) ; i++ ;
1381 xsh_model_config_enter("pc4_y_x2y2", p_xs_3->pc4_y_x2y2, i,NULL) ; i++ ;
1382 xsh_model_config_enter("pc4_y_x4", p_xs_3->pc4_y_x4, i,NULL) ; i++ ;
1383 xsh_model_config_enter("pc4_y_y4", p_xs_3->pc4_y_y4, i,NULL) ; i++ ;
1384 xsh_model_config_enter("ca_x0", p_xs_3->ca_x0, i,NULL) ; i++ ;
1385 xsh_model_config_enter("ca_x1", p_xs_3->ca_x1, i,NULL) ; i++ ;
1386 xsh_model_config_enter("ca_y0", p_xs_3->ca_y0, i,NULL) ; i++ ;
1387 xsh_model_config_enter("ca_y1", p_xs_3->ca_y1, i,NULL) ; i++ ;
1388 }
1389 else {
1390 xsh_model_config_enter("d2_y1x0", p_xs_3->d2_y1x0, i,NULL) ; i++ ;
1391 xsh_model_config_enter("d2_y1x1", p_xs_3->d2_y1x1, i,NULL) ; i++ ;
1392 xsh_model_config_enter("d2_y1x2", p_xs_3->d2_y1x2, i,NULL) ; i++ ;
1393 xsh_model_config_enter("d2_y1x3", p_xs_3->d2_y1x3, i,NULL) ; i++ ;
1394 xsh_model_config_enter("d2_y2x0", p_xs_3->d2_y2x0, i,NULL) ; i++ ;
1395 xsh_model_config_enter("d2_y2x1", p_xs_3->d2_y2x1, i,NULL) ; i++ ;
1396 xsh_model_config_enter("d2_y2x2", p_xs_3->d2_y2x2, i,NULL) ; i++ ;
1397 xsh_model_config_enter("d2_y2x3", p_xs_3->d2_y2x3, i,NULL) ; i++ ;
1398 xsh_model_config_enter("d2_y3x0", p_xs_3->d2_y3x0, i,NULL) ; i++ ;
1399 xsh_model_config_enter("d2_y3x1", p_xs_3->d2_y3x1, i,NULL) ; i++ ;
1400 xsh_model_config_enter("d2_y3x2", p_xs_3->d2_y3x2, i,NULL) ; i++ ;
1401 xsh_model_config_enter("d2_y3x3", p_xs_3->d2_y3x3, i,NULL) ; i++ ;
1402 xsh_model_config_enter("offx", p_xs_3->offx, i,"pix") ; i++ ;
1403 xsh_model_config_enter("offy", p_xs_3->offy, i,"pix") ; i++ ;
1404 }
1405 xsh_model_config_enter("d2_x1", p_xs_3->d2_x1, i,NULL) ; i++ ;
1406 xsh_model_config_enter("d2_x2", p_xs_3->d2_x2, i,NULL) ; i++ ;
1407 xsh_model_config_enter("d2_x3", p_xs_3->d2_x3, i,NULL) ; i++ ;
1408
1409 xsh_model_config_enter("flipx", p_xs_3->flipx, i,NULL) ; i++ ;
1410 xsh_model_config_enter("flipy", p_xs_3->flipy, i,NULL) ; i++ ;
1411 for (j=0 ; j<9 ; j++) {
1412 sprintf(tempstr, "slit[%d]", j) ;
1413 xsh_model_config_enter(tempstr, p_xs_3->slit[j], i,"\"") ; i++ ;
1414 }
1415 xsh_model_config_enter("config_mjd", p_xs_3->config_mjd, i,"days") ; i++ ;
1416
1417 return tab ;
1418}
1419
1420
1421
1422
1426 const char * in,
1427 const char * procatg)
1428{
1429 cpl_table * out ;
1430 int nok ;
1431
1432 /* Check entries */
1433 if (in == NULL) return NULL ;
1434 if (procatg == NULL) return NULL ;
1435
1436
1437 /* Load the table */
1438 if ((out = cpl_table_load(in, 1, 0)) == NULL) {
1439 cpl_msg_error(__func__, "Cannot load %s as a table", in) ;
1440 return NULL ;
1441 }
1442
1443 /* Check that the columns are there */
1444 nok = 0 ;
1445 // XSH_MOD_CFG_UVB
1446 /* REG : add new PRO CATG there */
1447 if (
1448 !strcmp(procatg, XSH_MOD_CFG_TAB_UVB) ||
1449 !strcmp(procatg, XSH_MOD_CFG_TAB_VIS) ||
1450 !strcmp(procatg, XSH_MOD_CFG_TAB_NIR) ||
1451 !strcmp(procatg, XSH_MOD_CFG_OPT_AFC_UVB) ||
1452 !strcmp(procatg, XSH_MOD_CFG_OPT_AFC_VIS) ||
1453 !strcmp(procatg, XSH_MOD_CFG_OPT_AFC_NIR) ||
1454
1455 !strcmp(procatg, XSH_MOD_CFG_OPT_REC_UVB) ||
1456 !strcmp(procatg, XSH_MOD_CFG_OPT_REC_VIS) ||
1457 !strcmp(procatg, XSH_MOD_CFG_OPT_REC_NIR) ||
1458
1459
1460 !strcmp(procatg, XSH_MOD_CFG_OPT_FMT_UVB) ||
1461 !strcmp(procatg, XSH_MOD_CFG_OPT_FMT_VIS) ||
1462 !strcmp(procatg, XSH_MOD_CFG_OPT_FMT_NIR) ||
1463
1464
1465 !strcmp(procatg, XSH_MOD_CFG_OPT_2D_UVB) ||
1466 !strcmp(procatg, XSH_MOD_CFG_OPT_2D_VIS) ||
1467 !strcmp(procatg, XSH_MOD_CFG_OPT_2D_NIR) ||
1468
1469 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_SLIT_UVB) ||
1470 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_SLIT_VIS) ||
1471 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_SLIT_NIR) ||
1472
1473 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_IFU_UVB) ||
1474 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_IFU_VIS) ||
1475 !strcmp(procatg, XSH_MOD_CFG_OPT_WAV_IFU_NIR) ||
1476/* For now the following 3 checks are duplicates of the first 3
1477 * since XSH_MOD_CFG_*** == XSH_MOD_CFG_TAB_*** */
1478 /* !strcmp(procatg, XSH_MOD_CFG_UVB) ||
1479 !strcmp(procatg, XSH_MOD_CFG_VIS) ||
1480 !strcmp(procatg, XSH_MOD_CFG_NIR) || */
1481 !strcmp(procatg, XSH_MOD_CFG_FAN_UVB) ||
1482 !strcmp(procatg, XSH_MOD_CFG_FAN_VIS) ||
1483 !strcmp(procatg, XSH_MOD_CFG_FAN_NIR) ||
1484 !strcmp(procatg, XSH_MOD_CFG_OPEN_UVB) ||
1485 !strcmp(procatg, XSH_MOD_CFG_OPEN_VIS) ||
1486 !strcmp(procatg, XSH_MOD_CFG_OPEN_NIR)) {
1487
1493 } else {
1494 cpl_msg_error(__func__, "Unsupported PRO.CATG: %s", procatg) ;
1495 cpl_table_delete(out) ;
1496 return NULL ;
1497 }
1498
1499 /* Check if ok */
1500 if (nok > 0) {
1501 xsh_msg_error("%d",cpl_error_get_code());
1502 xsh_msg_error("%s",cpl_error_get_where());
1503 cpl_table_delete(out) ;
1504 return NULL ;
1505 }
1506
1507 return out ;
1508}
1509
1510
1512 const cpl_table * tab,
1513 const char * col)
1514{
1515 int ret ;
1516 if (!cpl_table_has_column(tab, col)) {
1517 cpl_msg_error(__func__, "Column %s is missing", col) ;
1518 ret = 1 ;
1519 } else ret = 0 ;
1520 return ret ;
1521}
1522
1524{
1525 FILE * tempcfg;
1526 char tempstr[10];
1527 int jj;
1528
1529 /* Initialise */
1530 tempcfg=fopen("xsh_temp.cfg","w");
1531
1532 fprintf(tempcfg,"%lf %lf %lf %d temper\n", p_xs_3->temper,p_xs_3->temper,p_xs_3->temper,0);
1533 fprintf(tempcfg,"%lf %lf %lf %d t_ir_p2\n", p_xs_3->t_ir_p2,p_xs_3->t_ir_p2,p_xs_3->t_ir_p2,0);
1534 fprintf(tempcfg,"%lf %lf %lf %d t_ir_p3\n", p_xs_3->t_ir_p3,p_xs_3->t_ir_p3,p_xs_3->t_ir_p3,0);
1535 fprintf(tempcfg,"%lf %lf %lf %d es_x\n", p_xs_3->es_x,p_xs_3->es_x,p_xs_3->es_x,0);
1536 fprintf(tempcfg,"%lf %lf %lf %d es_y\n", p_xs_3->es_y,p_xs_3->es_y,p_xs_3->es_y,0);
1537 fprintf(tempcfg,"%lf es_y_tot\n", p_xs_3->es_y_tot);
1538 fprintf(tempcfg,"%lf %lf %lf %d mues\n", p_xs_3->mues/DEG2RAD,p_xs_3->mues/DEG2RAD,p_xs_3->mues/DEG2RAD,0);
1539 fprintf(tempcfg,"%lf %lf %lf %d nues\n", p_xs_3->nues/DEG2RAD,p_xs_3->nues/DEG2RAD,p_xs_3->nues/DEG2RAD,0);
1540 fprintf(tempcfg,"%lf %lf %lf %d taues\n", p_xs_3->taues/DEG2RAD,p_xs_3->taues/DEG2RAD,p_xs_3->taues/DEG2RAD,0);
1541 fprintf(tempcfg,"%lf %lf %lf %d slit_scale\n", p_xs_3->slit_scale,p_xs_3->slit_scale,p_xs_3->slit_scale,0);
1542 fprintf(tempcfg,"%lf %lf %lf %d es_s\n", p_xs_3->es_s,p_xs_3->es_s,p_xs_3->es_s,0);
1543 fprintf(tempcfg,"%lf %lf %lf %d es_w\n", p_xs_3->es_w,p_xs_3->es_w,p_xs_3->es_w,0);
1544 fprintf(tempcfg,"%lf %lf %lf %d fcol\n", p_xs_3->fcol,p_xs_3->fcol,p_xs_3->fcol,0);
1545 fprintf(tempcfg,"%lf %lf %lf %d cmup1\n", p_xs_3->cmup1/DEG2RAD,p_xs_3->cmup1/DEG2RAD,p_xs_3->cmup1/DEG2RAD,0);
1546 fprintf(tempcfg,"%lf %lf %lf %d mup1\n", p_xs_3->mup1/DEG2RAD,p_xs_3->mup1/DEG2RAD,p_xs_3->mup1/DEG2RAD,0);
1547 fprintf(tempcfg,"%lf %lf %lf %d nup1\n", p_xs_3->nup1/DEG2RAD,p_xs_3->nup1/DEG2RAD,p_xs_3->nup1/DEG2RAD,0);
1548 fprintf(tempcfg,"%lf %lf %lf %d taup1\n", p_xs_3->taup1/DEG2RAD,p_xs_3->taup1/DEG2RAD,p_xs_3->taup1/DEG2RAD,0);
1549 fprintf(tempcfg,"%lf %lf %lf %d mup2\n", p_xs_3->mup2/DEG2RAD,p_xs_3->mup2/DEG2RAD,p_xs_3->mup2/DEG2RAD,0);
1550 fprintf(tempcfg,"%lf %lf %lf %d nup2\n", p_xs_3->nup2/DEG2RAD,p_xs_3->nup2/DEG2RAD,p_xs_3->nup2/DEG2RAD,0);
1551 fprintf(tempcfg,"%lf %lf %lf %d taup2\n", p_xs_3->taup2/DEG2RAD,p_xs_3->taup2/DEG2RAD,p_xs_3->taup2/DEG2RAD,0);
1552 fprintf(tempcfg,"%lf %lf %lf %d mup3\n", p_xs_3->mup3/DEG2RAD,p_xs_3->mup3/DEG2RAD,p_xs_3->mup3/DEG2RAD,0);
1553 fprintf(tempcfg,"%lf %lf %lf %d nup3\n", p_xs_3->nup3/DEG2RAD,p_xs_3->nup3/DEG2RAD,p_xs_3->nup3/DEG2RAD,0);
1554 fprintf(tempcfg,"%lf %lf %lf %d taup3\n", p_xs_3->taup3/DEG2RAD,p_xs_3->taup3/DEG2RAD,p_xs_3->taup3/DEG2RAD,0);
1555 fprintf(tempcfg,"%lf %lf %lf %d mup4\n", p_xs_3->mup4/DEG2RAD,p_xs_3->mup4/DEG2RAD,p_xs_3->mup4/DEG2RAD,0);
1556 fprintf(tempcfg,"%lf %lf %lf %d nup4\n", p_xs_3->nup4/DEG2RAD,p_xs_3->nup4/DEG2RAD,p_xs_3->nup4/DEG2RAD,0);
1557 fprintf(tempcfg,"%lf %lf %lf %d taup4\n", p_xs_3->taup4/DEG2RAD,p_xs_3->taup4/DEG2RAD,p_xs_3->taup4/DEG2RAD,0);
1558 fprintf(tempcfg,"%lf %lf %lf %d mup5\n", p_xs_3->mup5/DEG2RAD,p_xs_3->mup5/DEG2RAD,p_xs_3->mup5/DEG2RAD,0);
1559 fprintf(tempcfg,"%lf %lf %lf %d nup5\n", p_xs_3->nup5/DEG2RAD,p_xs_3->nup5/DEG2RAD,p_xs_3->nup5/DEG2RAD,0);
1560 fprintf(tempcfg,"%lf %lf %lf %d taup5\n", p_xs_3->taup5/DEG2RAD,p_xs_3->taup5/DEG2RAD,p_xs_3->taup5/DEG2RAD,0);
1561 fprintf(tempcfg,"%lf %lf %lf %d mup6\n", p_xs_3->mup6/DEG2RAD,p_xs_3->mup6/DEG2RAD,p_xs_3->mup6/DEG2RAD,0);
1562 fprintf(tempcfg,"%lf %lf %lf %d nup6\n", p_xs_3->nup6/DEG2RAD,p_xs_3->nup6/DEG2RAD,p_xs_3->nup6/DEG2RAD,0);
1563 fprintf(tempcfg,"%lf %lf %lf %d taup6\n", p_xs_3->taup6/DEG2RAD,p_xs_3->taup6/DEG2RAD,p_xs_3->taup6/DEG2RAD,0);
1564 fprintf(tempcfg,"%lf %lf %lf %d mug\n", p_xs_3->mug/DEG2RAD,p_xs_3->mug/DEG2RAD,p_xs_3->mug/DEG2RAD,0);
1565 fprintf(tempcfg,"%lf %lf %lf %d nug\n", p_xs_3->nug/DEG2RAD,p_xs_3->nug/DEG2RAD,p_xs_3->nug/DEG2RAD,0);
1566 fprintf(tempcfg,"%lf %lf %lf %d taug\n", p_xs_3->taug/DEG2RAD,p_xs_3->taug/DEG2RAD,p_xs_3->taug/DEG2RAD,0);
1567 fprintf(tempcfg,"%lf %lf %lf %d sg\n", p_xs_3->sg,p_xs_3->sg,p_xs_3->sg,0);
1568 fprintf(tempcfg,"%lf %lf %lf %d fdet\n", p_xs_3->fdet,p_xs_3->fdet,p_xs_3->fdet,0);
1569 fprintf(tempcfg,"%lf %lf %lf %d mud\n", p_xs_3->mud/DEG2RAD,p_xs_3->mud/DEG2RAD,p_xs_3->mud/DEG2RAD,0);
1570 fprintf(tempcfg,"%lf %lf %lf %d nud\n", p_xs_3->nud/DEG2RAD,p_xs_3->nud/DEG2RAD,p_xs_3->nud/DEG2RAD,0);
1571 fprintf(tempcfg,"%lf %lf %lf %d taud\n", p_xs_3->taud/DEG2RAD,p_xs_3->taud/DEG2RAD,p_xs_3->taud/DEG2RAD,0);
1572 fprintf(tempcfg,"%lf %lf %lf %d pix\n", p_xs_3->pix,p_xs_3->pix,p_xs_3->pix,0);
1573 fprintf(tempcfg,"%lf %lf %lf %d chipx\n", p_xs_3->chipx,p_xs_3->chipx,p_xs_3->chipx,0);
1574 fprintf(tempcfg,"%lf %lf %lf %d chipy\n", p_xs_3->chipy,p_xs_3->chipy,p_xs_3->chipy,0);
1575 fprintf(tempcfg,"%lf %lf %lf %d chiprot\n", p_xs_3->chiprot/DEG2RAD,p_xs_3->chiprot/DEG2RAD,p_xs_3->chiprot/DEG2RAD,0);
1576 fprintf(tempcfg,"%lf %lf %lf %d pc_x_xx\n", p_xs_3->pc_x_xx,p_xs_3->pc_x_xx,p_xs_3->pc_x_xx,0);
1577 fprintf(tempcfg,"%lf %lf %lf %d pc_x_x1\n", p_xs_3->pc_x_x1,p_xs_3->pc_x_x1,p_xs_3->pc_x_x1,0);
1578 fprintf(tempcfg,"%lf %lf %lf %d pc_x_yy\n", p_xs_3->pc_x_yy,p_xs_3->pc_x_yy,p_xs_3->pc_x_yy,0);
1579 fprintf(tempcfg,"%lf %lf %lf %d pc_x_y1\n", p_xs_3->pc_x_y1,p_xs_3->pc_x_y1,p_xs_3->pc_x_y1,0);
1580 fprintf(tempcfg,"%lf %lf %lf %d pc_x_xy\n", p_xs_3->pc_x_xy,p_xs_3->pc_x_xy,p_xs_3->pc_x_xy,0);
1581 fprintf(tempcfg,"%lf %lf %lf %d pc_x_x3\n", p_xs_3->pc_x_x3,p_xs_3->pc_x_x3,p_xs_3->pc_x_x3,0);
1582 fprintf(tempcfg,"%lf %lf %lf %d pc_x_x2y\n", p_xs_3->pc_x_x2y,p_xs_3->pc_x_x2y,p_xs_3->pc_x_x2y,0);
1583 fprintf(tempcfg,"%lf %lf %lf %d pc_x_y2x\n", p_xs_3->pc_x_y2x,p_xs_3->pc_x_y2x,p_xs_3->pc_x_y2x,0);
1584 fprintf(tempcfg,"%lf %lf %lf %d pc_x_y3\n", p_xs_3->pc_x_y3,p_xs_3->pc_x_y3,p_xs_3->pc_x_y3,0);
1585 fprintf(tempcfg,"%lf %lf %lf %d pc_y_xx\n", p_xs_3->pc_y_xx,p_xs_3->pc_y_xx,p_xs_3->pc_y_xx,0);
1586 fprintf(tempcfg,"%lf %lf %lf %d pc_y_x1\n", p_xs_3->pc_y_x1,p_xs_3->pc_y_x1,p_xs_3->pc_y_x1,0);
1587 fprintf(tempcfg,"%lf %lf %lf %d pc_y_yy\n", p_xs_3->pc_y_yy,p_xs_3->pc_y_yy,p_xs_3->pc_y_yy,0);
1588 fprintf(tempcfg,"%lf %lf %lf %d pc_y_y1\n", p_xs_3->pc_y_y1,p_xs_3->pc_y_y1,p_xs_3->pc_y_y1,0);
1589 fprintf(tempcfg,"%lf %lf %lf %d pc_y_xy\n", p_xs_3->pc_y_xy,p_xs_3->pc_y_xy,p_xs_3->pc_y_xy,0);
1590 fprintf(tempcfg,"%lf %lf %lf %d pc_y_x3\n", p_xs_3->pc_y_x3,p_xs_3->pc_y_x3,p_xs_3->pc_y_x3,0);
1591 fprintf(tempcfg,"%lf %lf %lf %d pc_y_x2y\n", p_xs_3->pc_y_x2y,p_xs_3->pc_y_x2y,p_xs_3->pc_y_x2y,0);
1592 fprintf(tempcfg,"%lf %lf %lf %d pc_y_y2x\n", p_xs_3->pc_y_y2x,p_xs_3->pc_y_y2x,p_xs_3->pc_y_y2x,0);
1593 fprintf(tempcfg,"%lf %lf %lf %d pc_y_y3\n", p_xs_3->pc_y_y3,p_xs_3->pc_y_y3,p_xs_3->pc_y_y3,0);
1594 fprintf(tempcfg,"%lf %lf %lf %d pc4_x_xy3\n", p_xs_3->pc4_x_xy3,p_xs_3->pc4_x_xy3,p_xs_3->pc4_x_xy3,0);
1595 fprintf(tempcfg,"%lf %lf %lf %d pc4_x_x3y\n", p_xs_3->pc4_x_x3y,p_xs_3->pc4_x_x3y,p_xs_3->pc4_x_x3y,0);
1596 fprintf(tempcfg,"%lf %lf %lf %d pc4_x_x2y2\n", p_xs_3->pc4_x_x2y2,p_xs_3->pc4_x_x2y2,p_xs_3->pc4_x_x2y2,0);
1597 fprintf(tempcfg,"%lf %lf %lf %d pc4_x_x4\n", p_xs_3->pc4_x_x4,p_xs_3->pc4_x_x4,p_xs_3->pc4_x_x4,0);
1598 fprintf(tempcfg,"%lf %lf %lf %d pc4_x_y4\n", p_xs_3->pc4_x_y4,p_xs_3->pc4_x_y4,p_xs_3->pc4_x_x4,0);
1599 fprintf(tempcfg,"%lf %lf %lf %d pc4_y_xy3\n", p_xs_3->pc4_y_xy3,p_xs_3->pc4_y_xy3,p_xs_3->pc4_y_xy3,0);
1600 fprintf(tempcfg,"%lf %lf %lf %d pc4_y_x3y\n", p_xs_3->pc4_y_x3y,p_xs_3->pc4_y_x3y,p_xs_3->pc4_y_x3y,0);
1601 fprintf(tempcfg,"%lf %lf %lf %d pc4_y_x2y2\n", p_xs_3->pc4_y_x2y2,p_xs_3->pc4_y_x2y2,p_xs_3->pc4_y_x2y2,0);
1602 fprintf(tempcfg,"%lf %lf %lf %d pc4_y_x4\n", p_xs_3->pc4_y_x4,p_xs_3->pc4_y_x4,p_xs_3->pc4_y_x4,0);
1603 fprintf(tempcfg,"%lf %lf %lf %d pc4_y_y4\n", p_xs_3->pc4_y_y4,p_xs_3->pc4_y_y4,p_xs_3->pc4_y_x4,0);
1604 fprintf(tempcfg,"%lf %lf %lf %d ca_x0\n", p_xs_3->ca_x0,p_xs_3->ca_x0,p_xs_3->ca_x0,0);
1605 fprintf(tempcfg,"%lf %lf %lf %d ca_x1\n", p_xs_3->ca_x1,p_xs_3->ca_x1,p_xs_3->ca_x1,0);
1606 fprintf(tempcfg,"%lf %lf %lf %d ca_y0\n", p_xs_3->ca_y0,p_xs_3->ca_y0,p_xs_3->ca_y0,0);
1607 fprintf(tempcfg,"%lf %lf %lf %d ca_y1\n", p_xs_3->ca_y1,p_xs_3->ca_y1,p_xs_3->ca_y1,0);
1608 fprintf(tempcfg,"%lf %lf %lf %d d2_x1\n", p_xs_3->d2_x1,p_xs_3->d2_x1,p_xs_3->d2_x1,0);
1609 fprintf(tempcfg,"%lf %lf %lf %d d2_x2\n", p_xs_3->d2_x2,p_xs_3->d2_x2,p_xs_3->d2_x2,0);
1610 fprintf(tempcfg,"%lf %lf %lf %d d2_x3\n", p_xs_3->d2_x3,p_xs_3->d2_x3,p_xs_3->d2_x3,0);
1611 fprintf(tempcfg,"%lf %lf %lf %d d2_y1x0\n", p_xs_3->d2_y1x0,p_xs_3->d2_y1x0,p_xs_3->d2_y1x0,0);
1612 fprintf(tempcfg,"%lf %lf %lf %d d2_y1x1\n", p_xs_3->d2_y1x1,p_xs_3->d2_y1x1,p_xs_3->d2_y1x1,0);
1613 fprintf(tempcfg,"%lf %lf %lf %d d2_y1x2\n", p_xs_3->d2_y1x2,p_xs_3->d2_y1x2,p_xs_3->d2_y1x2,0);
1614 fprintf(tempcfg,"%lf %lf %lf %d d2_y1x3\n", p_xs_3->d2_y1x3,p_xs_3->d2_y1x3,p_xs_3->d2_y1x3,0);
1615 fprintf(tempcfg,"%lf %lf %lf %d d2_y2x0\n", p_xs_3->d2_y2x0,p_xs_3->d2_y2x0,p_xs_3->d2_y2x0,0);
1616 fprintf(tempcfg,"%lf %lf %lf %d d2_y2x1\n", p_xs_3->d2_y2x1,p_xs_3->d2_y2x1,p_xs_3->d2_y2x1,0);
1617 fprintf(tempcfg,"%lf %lf %lf %d d2_y2x2\n", p_xs_3->d2_y2x2,p_xs_3->d2_y2x2,p_xs_3->d2_y2x2,0);
1618 fprintf(tempcfg,"%lf %lf %lf %d d2_y2x3\n", p_xs_3->d2_y2x3,p_xs_3->d2_y2x3,p_xs_3->d2_y2x3,0);
1619 fprintf(tempcfg,"%lf %lf %lf %d d2_y3x0\n", p_xs_3->d2_y3x0,p_xs_3->d2_y3x0,p_xs_3->d2_y3x0,0);
1620 fprintf(tempcfg,"%lf %lf %lf %d d2_y3x1\n", p_xs_3->d2_y3x1,p_xs_3->d2_y3x1,p_xs_3->d2_y3x1,0);
1621 fprintf(tempcfg,"%lf %lf %lf %d d2_y3x2\n", p_xs_3->d2_y3x2,p_xs_3->d2_y3x2,p_xs_3->d2_y3x2,0);
1622 fprintf(tempcfg,"%lf %lf %lf %d d2_y3x3\n", p_xs_3->d2_y3x3,p_xs_3->d2_y3x3,p_xs_3->d2_y3x3,0);
1623 fprintf(tempcfg,"%lf %lf %lf %d offx\n", p_xs_3->offx,p_xs_3->offx,p_xs_3->offx,0);
1624 fprintf(tempcfg,"%lf %lf %lf %d offy\n", p_xs_3->offy,p_xs_3->offy,p_xs_3->offy,0);
1625 fprintf(tempcfg,"%lf %lf %lf %d flipx\n", p_xs_3->flipx,p_xs_3->flipx,p_xs_3->flipx,0);
1626 fprintf(tempcfg,"%lf %lf %lf %d flipy\n", p_xs_3->flipy,p_xs_3->flipy,p_xs_3->flipy,0);
1627 for (jj=0 ; jj<9 ; jj++) {
1628 sprintf(tempstr, "slit[%d]", jj) ;
1629 fprintf(tempcfg,"%lf %lf %lf %d %s \n",p_xs_3->slit[jj],p_xs_3->slit[jj],p_xs_3->slit[jj],0,tempstr);
1630 }
1631 fclose(tempcfg);
1632 return;
1633}
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
XSH_INSTRCONFIG * xsh_instrument_get_config(xsh_instrument *i)
Get the instrument default set of keywords.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
int xsh_model_readfits(double *abest, double *amin, double *amax, int *aname, const char *xs_config_file, const char *xs_config_tag, struct xs_3 *p_xs_3, ann_all_par *p_all_par)
Definition: xsh_model_io.c:570
cpl_error_code xsh_model_config_load_best(cpl_frame *config_frame, xsh_xs_3 *p_xs_3)
Load the config model table and fill the struct.
Definition: xsh_model_io.c:174
void xsh_model_io_dump(xsh_xs_3 *p_xs_3)
Definition: xsh_model_io.c:60
#define xsh_model_config_enter(name, val, index, units)
cpl_table * xsh_model_io_output_cfg(struct xs_3 *p_xs_3)
#define xsh_msg_error(...)
Print an error message.
Definition: xsh_msg.h:62
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_high(...)
Definition: xsh_msg.h:40
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
Definition: xsh_utils.c:2133
DOUBLE mup2
DOUBLE taup1
double ca_x0
DOUBLE fcol
DOUBLE es_x
double d2_y1x0
double d2_y2x0
double d2_y1x3
double pc4_y_x3y
double config_mjd
DOUBLE nup4
DOUBLE pix
DOUBLE mup1
double pc4_y_y4
DOUBLE mup5
DOUBLE mud
double pc_x_y3
double d2_y1x2
DOUBLE pix_Y
double pc4_y_xy3
DOUBLE es_w
double chipx
DOUBLE nup3
DOUBLE blaze_pad
DOUBLE taug
double pc_x_x3
double pc_x_x2y
double pc4_y_x4
double pc4_y_x2y2
double d2_y3x0
double pc_y_y1
double d2_y2x2
double d2_x1
double d2_y3x2
DOUBLE nud
int morder_max
double pc4_x_xy3
DOUBLE t_ir_p3
DOUBLE pix_X
double pc_x_xy
double pc_x_y1
double ca_x1
DOUBLE taud
double chipypix
DOUBLE fdet
DOUBLE nup1
DOUBLE taup5
double d2_y2x3
double xsize_corr
DOUBLE taup4
double d2_y1x1
DOUBLE nup2
double pc_y_x1
DOUBLE t_ir_p2
double d2_y2x1
DOUBLE cmup1
double pc4_x_x3y
DOUBLE slit[10]
DOUBLE flipy
double pc_x_y2x
double chipy
DOUBLE slit_scale
double pc_y_y3
DOUBLE mues
DOUBLE taup6
DOUBLE flipx
DOUBLE offx
DOUBLE nues
double ca_y1
double pc_x_x1
DOUBLE mup3
DOUBLE es_y
double ca_y0
double pc_x_xx
DOUBLE mup4
DOUBLE temper
double pc4_x_x2y2
double d2_x2
int morder_min
double pc4_x_y4
double ysize_corr
DOUBLE nup6
DOUBLE offy
DOUBLE es_y_tot
double d2_x3
double pc4_x_x4
double d2_y3x1
DOUBLE nug
double chiprot
double pc_y_x3
double d2_y3x3
double pc_y_y2x
double pc_y_x2y
DOUBLE sg
DOUBLE nup5
DOUBLE taup3
DOUBLE mup6
double pc_y_xx
double pc_x_yy
double pc_y_xy
DOUBLE es_s
int morder
DOUBLE taup2
double pc_y_yy
double chipxpix
DOUBLE mug
DOUBLE taues
@ XSH_ARM_UVB
@ XSH_ARM_NIR
@ XSH_ARM_VIS
#define XSH_MOD_CFG_OPT_REC_VIS
Definition: xsh_dfs.h:1224
#define XSH_MOD_CFG_OPT_AFC_NIR
Definition: xsh_dfs.h:1259
#define XSH_MOD_CFG_FAN_UVB
Definition: xsh_dfs.h:1277
#define XSH_MOD_CFG_OPT_REC_UVB
Definition: xsh_dfs.h:1223
#define XSH_COL_MODEL_CONF_HIGH
Definition: xsh_dfs.h:1296
#define XSH_MOD_CFG_OPT_WAV_SLIT_VIS
Definition: xsh_dfs.h:1241
#define XSH_MOD_CFG_OPT_FMT_NIR
Definition: xsh_dfs.h:1230
#define XSH_MOD_CFG_VIS
Definition: xsh_dfs.h:1263
#define XSH_MOD_CFG_OPT_2D_VIS
Definition: xsh_dfs.h:1235
#define XSH_MOD_CFG_TAB_NIR
Definition: xsh_dfs.h:1254
#define XSH_MOD_CFG_UVB
Definition: xsh_dfs.h:1262
#define XSH_COL_MODEL_CONF_BEST
Definition: xsh_dfs.h:1294
#define XSH_MOD_CFG_OPEN_NIR
Definition: xsh_dfs.h:1269
#define XSH_MOD_CFG_OPT_WAV_IFU_VIS
Definition: xsh_dfs.h:1247
#define XSH_MOD_CFG_TAB_UVB
Definition: xsh_dfs.h:1252
#define XSH_COL_MODEL_CONF_LOW
Definition: xsh_dfs.h:1295
#define XSH_MOD_CFG_OPEN_UVB
Definition: xsh_dfs.h:1267
#define XSH_MOD_CFG_OPT_FMT_UVB
Definition: xsh_dfs.h:1228
#define XSH_MOD_CFG_FAN_VIS
Definition: xsh_dfs.h:1278
#define XSH_COL_MODEL_CONF_NAME
Definition: xsh_dfs.h:1292
#define XSH_MOD_CFG_OPT_2D_UVB
Definition: xsh_dfs.h:1234
#define XSH_MOD_CFG_NIR
Definition: xsh_dfs.h:1264
#define XSH_MOD_CFG_OPT_WAV_IFU_UVB
Definition: xsh_dfs.h:1246
#define XSH_MOD_CFG_OPT_WAV_IFU_NIR
Definition: xsh_dfs.h:1248
#define XSH_MOD_CFG_OPT_FMT_VIS
Definition: xsh_dfs.h:1229
#define XSH_MOD_CFG_TAB_VIS
Definition: xsh_dfs.h:1253
#define XSH_MOD_CFG_OPT_WAV_SLIT_UVB
Definition: xsh_dfs.h:1240
#define XSH_COL_MODEL_CONF_FLAG
Definition: xsh_dfs.h:1297
#define XSH_MOD_CFG_OPT_WAV_SLIT_NIR
Definition: xsh_dfs.h:1242
#define XSH_MOD_CFG_OPEN_VIS
Definition: xsh_dfs.h:1268
#define XSH_MOD_CFG_FAN_NIR
Definition: xsh_dfs.h:1279
#define XSH_MOD_CFG_OPT_AFC_UVB
Definition: xsh_dfs.h:1257
#define XSH_COL_MODEL_CONF_UNITS
Definition: xsh_dfs.h:1293
#define XSH_MOD_CFG_OPT_2D_NIR
Definition: xsh_dfs.h:1236
#define XSH_MOD_CFG_OPT_AFC_VIS
Definition: xsh_dfs.h:1258
#define XSH_MOD_CFG_OPT_REC_NIR
Definition: xsh_dfs.h:1225
#define max(a, b)
#define NIR_xsize_corr
#define UVB_xsize_corr
#define VIS_ysize_corr
#define VIS_xsize_corr
#define UVB_morder
#define NIR_morder
#define UVB_blaze_pad
#define NIR_ysize_corr
#define NIR_blaze_pad
#define VIS_morder
#define UVB_ysize_corr
#define VIS_blaze_pad
void xsh_model_io_output_cfg_txt(struct xs_3 *p_xs_3)
static int xsh_table_check_column(const cpl_table *, const char *)
cpl_table * xsh_load_table_check(const char *in, const char *procatg)
#define DEG2RAD
Definition: xsh_model_io.h:43
#define XSH_TABLE_FREE(TABLE)