Debian Codegraph @

gui/XEchelle/src/midasutil.c

raw
1 /*===========================================================================
2 Copyright (C) 1993-2009 European Southern Observatory (ESO)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
17 MA 02139, USA.
18
19 Corresponding concerning ESO-MIDAS should be addressed as follows:
20 Internet e-mail: [email protected]
21 Postal address: European Southern Observatory
22 Data Management Division
23 Karl-Schwarzschild-Strasse 2
24 D 85748 Garching bei Muenchen
25 GERMANY
26 ===========================================================================*/
27
28 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
29 /* .COPYRIGHT (C) 1993 European Southern Observatory */
30 /* .IDENT midasutil.c */
31 /* .AUTHORS Pascal Ballester (ESO/Garching) */
32 /* Cristian Levin (ESO/La Silla) */
33 /* .KEYWORDS XLong, Spectroscopy, Long-Slit */
34 /* .PURPOSE */
35 /* .VERSION 1.0 Package Creation 17-MAR-1993
36
37 090904 last modif */
38 /* ------------------------------------------------------- */
39
40 #include <gl_defs.h>
41 #include <xm_defs.h>
42 #include <midas_def.h>
43 #include <main_defs.h>
44 #include <spec_defs.h>
45 #include <spec_comm.h>
46
47 #include <UxLib.h>
48
49 #define MAXCDESC 20
50 #define DEFAULT_SKY "sky"
51
52 #define TOGGLE_STATE(x, y, z) XmToggleButtonSetState(UxGetWidget(UxFindSwidget(x)), y, z);
53 #define SET_SENSITIVE(x, y) XtSetSensitive(UxGetWidget(UxFindSwidget(x)), y);
54
55 extern void XmToggleButtonSetState();
56
57 extern void ReadDefaultsLong();
58 extern void DisplayParamsLong();
59 extern void WriteKeyword();
60 extern void GetCdesc();
61
62 extern int file_exists(), exist_descriptor();
63 extern int AppendDialogText(), read_catalog_table();
64
65
66 /****************************************************************************
67 GetCdesc(): returns the 'desc' character descriptor from the image 'image'.
68 */
69 void GetCdesc( image, desc, str )
70 char *image, *desc, *str;
71 {
72 char value[MAXCDESC];
73 int retval; /* useless */
74 int id ;
75
76 if ( file_exists(image, ".bdf") && exist_descriptor(image, desc) ) {
77 SCFOPN(image, D_R4_FORMAT, 0, F_IMA_TYPE, &id);
78 SCDGETC(id, desc, 1, MAXCDESC, &retval, value);
79 SCFCLO(id);
80 }
81 else
82 strcpy(value, "");
83
84 strcpy(str,value);
85 }
86
87 /****************************************************************************
88 exist_descriptor_table(): checks if the descriptor 'desc' exists in 'table'.
89 */
90 int exist_descriptor_table( table, desc )
91 char *table; /* name of the table */
92 char *desc; /* descriptor name */
93 {
94 int nulval, id;
95 char type;
96
97 if ( file_exists( table, ".tbl" ) ) {
98 TCTOPN( table, F_I_MODE, &id);
99 SCDFND( id, desc, &type, &nulval, &nulval );
100 if ( type != ' ' ) {
101 TCTCLO(id);
102 return(TRUE);
103 }
104 TCTCLO(id);
105 }
106 return(FALSE);
107 }
108 /****************************************************************************
109 exist_descriptor(): checks if the descriptor 'desc' exists in 'image'.
110 */
111 int exist_descriptor( image, desc )
112 char *image; /* name of the image */
113 char *desc; /* descriptor name */
114 {
115 int nulval, id;
116 char type;
117
118 if ( file_exists( image, ".bdf" ) ) {
119 SCFOPN( image, D_R4_FORMAT, 0, F_IMA_TYPE, &id );
120 SCDFND( id, desc, &type, &nulval, &nulval );
121 if ( type != ' ' ) {
122 SCFCLO(id);
123 return(TRUE);
124 }
125 SCFCLO(id);
126 }
127 return(FALSE);
128 }
129
130 void UpdateDescriptors( frame )
131 char frame[];
132 {
133 char str[MAXLINE];
134
135 GetCdesc(frame, "INSTRUME", str);
136 XmTextSetString(UxGetWidget(UxFindSwidget("tf_instrume")), str);
137 strcpy(Instrume, str);
138 WriteKeyword(str, K_INSTRUME);
139
140 GetCdesc(frame, "IDENT", str);
141 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wlc")), str);
142 strcpy(Wlc, frame);
143 WriteKeyword(frame, K_WLC);
144 }
145
146 void UpdateWlcIdent( frame )
147 char frame[];
148 {
149
150 }
151
152 void UpdateRebinParameters()
153 {
154 int unit; /* useless */
155 int actval, nulval; /* useless */
156 char str[MAXLINE];
157 int id;
158
159 if ( !exist_descriptor_table(Coerbr, "REBSTRT") )
160 return;
161
162 TCTOPN(Coerbr, F_I_MODE, &id);
163 SCDRDD(id, "REBSTRT", 1, 1, &actval, &Rebstrt, &unit, &nulval);
164 SCDRDD(id, "REBSTP", 1, 1, &actval, &Rebstp, &unit, &nulval);
165 SCDRDD(id, "REBEND", 1, 1, &actval, &Rebend, &unit, &nulval);
166 TCTCLO(id);
167
168 sprintf(str, "%.3f", Rebstrt);
169 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebstrt")), str);
170 sprintf(str, "%.3f", Rebend);
171 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebend")), str);
172 sprintf(str, "%.6g", Rebstp);
173 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebstp")), str);
174 }
175
176 void InitLong()
177 {
178 ReadDefaultsLong();
179 DisplayParamsLong();
180 }
181
182 void ReadDefaultsLong()
183 {
184 int unit; /* useless */
185 int actval, nulval; /* useless */
186
187 SCKGETC("COERBR", 1, 20, &actval, Coerbr);
188 SCKGETC("COORFIL", 1, 20, &actval, Coorfil);
189
190 /* main form */
191 SCKGETC("SESSION", 1, 20, &actval, Session);
192 SCKGETC("INSTRUME", 1, 20, &actval, Instrume);
193 SCKGETC("WLC", 1, 20, &actval, Wlc);
194 SCKRDI("YSTART", 1, 1, &actval, &Ystart, &unit, &nulval);
195 SCKGETC("LINCAT", 1, 20, &actval, Lincat);
196 SCKRDI("WRANG", 1, 2, &actval, Wrang, &unit, &nulval);
197 SCKRDR("IMIN", 1, 1, &actval, &Imin, &unit, &nulval);
198
199 /* search form */
200 SCKGETC("SEAMTD", 1, 12, &actval, Seamtd);
201 SCKRDI("YWIDTH", 1, 1, &actval, &Ywidth, &unit, &nulval);
202 SCKRDI("YSTEP", 1, 1, &actval, &Ystep, &unit, &nulval);
203 SCKRDR("THRES", 1, 1, &actval, &Thres, &unit, &nulval);
204 SCKRDI("WIDTH", 1, 1, &actval, &Width, &unit, &nulval);
205
206 /* wavelength calibration form */
207 SCKGETC("WLCMTD", 1, 10, &actval, Wlcmtd);
208 SCKRDR("TOL", 1, 1, &actval, &Tol, &unit, &nulval);
209 SCKRDI("DCX", 1, 2, &actval, Dcx, &unit, &nulval);
210 SCKRDI("WLCNITER", 1, 2, &actval, Wlcniter, &unit, &nulval);
211 SCKRDR("ALPHA", 1, 1, &actval, &Alpha, &unit, &nulval);
212 SCKRDR("MAXDEV", 1, 1, &actval, &Maxdev, &unit, &nulval);
213 SCKGETC("GUESS", 1, 60, &actval, Guess);
214 /* later
215 SCKRDR("SHIFT", 1, 1, &actval, &Shift, &unit, &nulval);
216 */
217 SCKGETC("COROPT", 1, 2, &actval, Coropt);
218 SCKGETC("TWODOPT", 1, 2, &actval, Twodopt);
219 /* not yet used
220 SCKRDR("AVDISP", 1, 1, &actval, &Avdisp, &unit, &nulval);
221 SCKRDR("WCENTER", 1, 1, &actval, &Wcenter, &unit, &nulval);
222 */
223
224 /* rebin form */
225 SCKGETC("REBMTD", 1, 12, &actval, Rebmtd);
226 SCKRDD("REBSTRT", 1, 1, &actval, &Rebstrt, &unit, &nulval);
227 SCKRDD("REBEND", 1, 1, &actval, &Rebend, &unit, &nulval);
228 SCKRDD("REBSTP", 1, 1, &actval, &Rebstp, &unit, &nulval);
229
230 /* flux calibration form */
231 SCKGETC("EXTAB", 1, 60, &actval, Extab);
232 SCKGETC("FLUXTAB", 1, 60, &actval, Fluxtab);
233 SCKGETC("RESPTAB", 1, 60, &actval, Resptab);
234 SCKGETC("PLOTYP", 1, 60, &actval, Plotyp);
235 SCKGETC("FITYP", 1, 60, &actval, Fityp);
236 SCKGETC("RESPONSE", 1, 60, &actval, Response);
237 SCKRDI("FITD", 1, 1, &actval, &Fitd, &unit, &nulval);
238 SCKRDR("SMOOTH", 1, 1, &actval, &Smooth, &unit, &nulval);
239
240 /* extraction form */
241 SCKGETC("EXTMTD", 1, 10, &actval, Extmtd);
242 SCKRDI("LOWSKY", 1, 2, &actval, Lowsky, &unit, &nulval);
243 SCKRDI("UPPSKY", 1, 2, &actval, Uppsky, &unit, &nulval);
244 SCKRDI("OBJECT", 1, 2, &actval, Objlim, &unit, &nulval);
245 SCKRDI("SKYORD", 1, 1, &actval, &Skyord, &unit, &nulval);
246 SCKRDI("ORDER", 1, 1, &actval, &Order, &unit, &nulval);
247 SCKRDI("NITER", 1, 1, &actval, &Niter, &unit, &nulval);
248 SCKRDI("RADIUS", 1, 1, &actval, &Radius, &unit, &nulval);
249 SCKRDI("SKYMOD", 1, 1, &actval, &Skymod, &unit, &nulval);
250 SCKRDR("RON", 1, 1, &actval, &Ron, &unit, &nulval);
251 SCKRDR("GAIN", 1, 1, &actval, &Gain, &unit, &nulval);
252 SCKRDR("SIGMA", 1, 1, &actval, &Sigma, &unit, &nulval);
253
254 if ( Tol >= 0.0 )
255 TolPixels = TRUE;
256 else {
257 TolPixels = FALSE;
258 Tol = -Tol;
259 }
260 }
261
262 void ReadParamsLong( session )
263 char session[];
264 {
265 int unit; /* useless */
266 int actval, nulval; /* useless */
267 int id;
268
269 TCTOPN(session, F_I_MODE, &id);
270 strcpy(Session, session);
271
272 SCDGETC(id, "COERBR", 1, 20, &actval, Coerbr);
273 SCDGETC(id, "COORFIL", 1, 20, &actval, Coorfil);
274
275 /* main form */
276 SCDGETC(id, "INSTRUME", 1, 20, &actval, Instrume);
277 SCDGETC(id, "WLC", 1, 20, &actval, Wlc);
278 SCDRDI(id, "YSTART", 1, 1, &actval, &Ystart, &unit, &nulval);
279 SCDGETC(id, "LINCAT", 1, 20, &actval, Lincat);
280 SCDRDI(id, "WRANG", 1, 2, &actval, Wrang, &unit, &nulval);
281 SCDRDR(id, "IMIN", 1, 1, &actval, &Imin, &unit, &nulval);
282
283 /* search form */
284 SCDGETC(id, "SEAMTD", 1, 12, &actval, Seamtd);
285 SCDRDI(id, "YWIDTH", 1, 1, &actval, &Ywidth, &unit, &nulval);
286 SCDRDI(id, "YSTEP", 1, 1, &actval, &Ystep, &unit, &nulval);
287 SCDRDR(id, "THRES", 1, 1, &actval, &Thres, &unit, &nulval);
288 SCDRDI(id, "WIDTH", 1, 1, &actval, &Width, &unit, &nulval);
289
290 /* wavelength calibration form */
291 SCDGETC(id, "WLCMTD", 1, 10, &actval, Wlcmtd);
292 SCDRDR(id, "TOL", 1, 1, &actval, &Tol, &unit, &nulval);
293 SCDRDI(id, "DCX", 1, 2, &actval, Dcx, &unit, &nulval);
294 SCDRDI(id, "WLCNITER", 1, 2, &actval, Wlcniter, &unit, &nulval);
295 SCDRDR(id, "ALPHA", 1, 1, &actval, &Alpha, &unit, &nulval);
296 SCDRDR(id, "MAXDEV", 1, 1, &actval, &Maxdev, &unit, &nulval);
297 SCDGETC(id, "GUESS", 1, 60, &actval, Guess);
298 /* later
299 SCDRDR(id, "SHIFT", 1, 1, &actval, &Shift, &unit, &nulval);
300 */
301 SCDGETC(id, "COROPT", 1, 2, &actval, Coropt);
302 SCDGETC(id, "TWODOPT", 1, 2, &actval, Twodopt);
303 /* not yet used
304 SCDRDR(id, "AVDISP", 1, 1, &actval, &Avdisp, &unit, &nulval);
305 SCDRDR(id, "WCENTER", 1, 1, &actval, &Wcenter, &unit, &nulval);
306 */
307 /* rebin form */
308 SCDGETC(id, "REBMTD", 1, 12, &actval, Rebmtd);
309 SCDRDD(id, "REBSTRT", 1, 1, &actval, &Rebstrt, &unit, &nulval);
310 SCDRDD(id, "REBEND", 1, 1, &actval, &Rebend, &unit, &nulval);
311 SCDRDD(id, "REBSTP", 1, 1, &actval, &Rebstp, &unit, &nulval);
312
313 /* flux calibration form */
314 SCDGETC(id, "EXTAB", 1, 60, &actval, Extab);
315 SCDGETC(id, "FLUXTAB", 1, 60, &actval, Fluxtab);
316 SCDGETC(id, "RESPTAB", 1, 60, &actval, Resptab);
317 SCDGETC(id, "PLOTYP", 1, 60, &actval, Plotyp);
318 SCDGETC(id, "FITYP", 1, 60, &actval, Fityp);
319 SCDGETC(id, "RESPONSE", 1, 60, &actval, Response);
320 SCDRDI(id, "FITD", 1, 1, &actval, &Fitd, &unit, &nulval);
321 SCDRDR(id, "SMOOTH", 1, 1, &actval, &Smooth, &unit, &nulval);
322
323 /* extraction form */
324 SCDGETC(id, "EXTMTD", 1, 10, &actval, Extmtd);
325 SCDRDI(id, "LOWSKY", 1, 2, &actval, Lowsky, &unit, &nulval);
326 SCDRDI(id, "UPPSKY", 1, 2, &actval, Uppsky, &unit, &nulval);
327 SCDRDI(id, "OBJECT", 1, 2, &actval, Objlim, &unit, &nulval);
328 SCDRDI(id, "SKYORD", 1, 1, &actval, &Skyord, &unit, &nulval);
329 SCDRDI(id, "ORDER", 1, 1, &actval, &Order, &unit, &nulval);
330 SCDRDI(id, "NITER", 1, 1, &actval, &Niter, &unit, &nulval);
331 SCDRDI(id, "RADIUS", 1, 1, &actval, &Radius, &unit, &nulval);
332 SCDRDI(id, "SKYMOD", 1, 1, &actval, &Skymod, &unit, &nulval);
333 SCDRDR(id, "RON", 1, 1, &actval, &Ron, &unit, &nulval);
334 SCDRDR(id, "GAIN", 1, 1, &actval, &Gain, &unit, &nulval);
335 SCDRDR(id, "SIGMA", 1, 1, &actval, &Sigma, &unit, &nulval);
336
337 TCTCLO(id);
338
339 if ( Tol >= 0.0 )
340 TolPixels = TRUE;
341 else {
342 TolPixels = FALSE;
343 Tol = -Tol;
344 }
345 }
346
347 void DisplayParamsLong()
348 {
349 int guess_selected;
350 char str[MAXLINE];
351
352 UpdateToggle = FALSE; /* ==> the interface doesn't send SET/LONG */
353
354 /* main form */
355 XmTextSetString(UxGetWidget(UxFindSwidget("tf_session")), Session);
356 XmTextSetString(UxGetWidget(UxFindSwidget("tf_instrume")), Instrume);
357 GetCdesc(Wlc, "IDENT", str);
358 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wlc")), str);
359 sprintf(str, "%d", Ystart);
360 XmTextSetString(UxGetWidget(UxFindSwidget("tf_ystart")), str);
361 XmTextSetString(UxGetWidget(UxFindSwidget("tf_lincat")), Lincat);
362 sprintf(str, "%d", Wrang[0]);
363 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wrang1")), str);
364 sprintf(str, "%d", Wrang[1]);
365 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wrang2")), str);
366 sprintf(str, "%.5g", Imin);
367 XmTextSetString(UxGetWidget(UxFindSwidget("tf_imin")), str);
368
369 /* search form */
370 TOGGLE_STATE("rb_seamtd_gaus", !strncmp(Seamtd, "GAUS", 4), False);
371 TOGGLE_STATE("rb_seamtd_grav", !strncmp(Seamtd, "GRAV", 4), False);
372 TOGGLE_STATE("rb_seamtd_maxi", !strncmp(Seamtd, "MAXI", 4), False);
373 sprintf(str, "%d", Ywidth);
374 XmTextSetString(UxGetWidget(UxFindSwidget("tf_ywidth")), str);
375 sprintf(str, "%d", Ystep);
376 XmTextSetString(UxGetWidget(UxFindSwidget("tf_ystep")), str);
377 sprintf(str, "%.1f", Thres);
378 XmTextSetString(UxGetWidget(UxFindSwidget("tf_thres")), str);
379 sprintf(str, "%d", Width);
380 XmTextSetString(UxGetWidget(UxFindSwidget("tf_width")), str);
381
382 /* wavelength calibration form */
383 sprintf(str, "%.2f", Tol);
384 XmTextSetString(UxGetWidget(UxFindSwidget("tf_tol")), str);
385 sprintf(str, "%d", Dcx[0]);
386 XmTextSetString(UxGetWidget(UxFindSwidget("tf_dcx1")), str);
387 sprintf(str, "%d", Dcx[1]);
388 XmTextSetString(UxGetWidget(UxFindSwidget("tf_dcx2")), str);
389 sprintf(str, "%d", Wlcniter[0]);
390 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wlcniter1")), str);
391 sprintf(str, "%d", Wlcniter[1]);
392 XmTextSetString(UxGetWidget(UxFindSwidget("tf_wlcniter2")), str);
393 sprintf(str, "%.1f", Alpha);
394 XmTextSetString(UxGetWidget(UxFindSwidget("tf_alpha")), str);
395 sprintf(str, "%.1f", Maxdev);
396 XmTextSetString(UxGetWidget(UxFindSwidget("tf_maxdev")), str);
397 XmTextSetString(UxGetWidget(UxFindSwidget("tf_guess")), Guess);
398 /* later
399 sprintf(str, "%.1f", Shift);
400 XmTextSetString(UxGetWidget(UxFindSwidget("tf_shift")), str);
401 */
402 TOGGLE_STATE("tg_coropt", !strncmp(Coropt, "YE", 2), False);
403 TOGGLE_STATE("tg_twodopt", !strncmp(Twodopt, "YE", 2), False);
404
405 guess_selected = !strncmp(Wlcmtd, "GUES", 4);
406 TOGGLE_STATE("rb_wlcmtd_iden", !guess_selected, True);
407 TOGGLE_STATE("rb_wlcmtd_gues", guess_selected, True);
408 SET_SENSITIVE("guess_session_label", guess_selected);
409 SET_SENSITIVE("tf_guess", guess_selected);
410 /* later
411 SET_SENSITIVE("shift_label", guess_selected);
412 SET_SENSITIVE("tf_shift", guess_selected);
413 */
414 SET_SENSITIVE("tg_coropt", guess_selected);
415
416 if ( TolPixels )
417 UxPutMenuHistory(UxFindSwidget("mn_tol"), "mn_tol_pixels");
418 else
419 UxPutMenuHistory(UxFindSwidget("mn_tol"), "mn_tol_angstroms");
420
421 /* rebin form */
422 sprintf(str, "%.2f", Rebstrt);
423 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebstrt")), str);
424 sprintf(str, "%.2f", Rebend);
425 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebend")), str);
426 sprintf(str, "%.6g", Rebstp);
427 XmTextSetString(UxGetWidget(UxFindSwidget("tf_rebstp")), str);
428 TOGGLE_STATE("rb_rebmtd_line", !strncmp(Rebmtd, "LINE", 4), False);
429 TOGGLE_STATE("rb_rebmtd_quad", !strncmp(Rebmtd, "QUAD", 4), False);
430 TOGGLE_STATE("rb_rebmtd_spli", !strncmp(Rebmtd, "SPLI", 4), False);
431
432 UpdateToggle = TRUE; /* ==> the interface can send SET/LONG again */
433
434 /* flux calibration form */
435 XmTextSetString(UxGetWidget(UxFindSwidget("tf_extin_tbl")), Extab);
436 XmTextSetString(UxGetWidget(UxFindSwidget("tf_flux_tbl")), Fluxtab);
437 XmTextSetString(UxGetWidget(UxFindSwidget("tf_output_resp")), Response);
438 TOGGLE_STATE("rb_plotyp_rati", !strncmp(Plotyp, "RATI", 4), False);
439 TOGGLE_STATE("rb_plotyp_colo", !strncmp(Plotyp, "COLO", 4), False);
440 TOGGLE_STATE("rb_fityp_poly", !strncmp(Fityp, "POLY", 4), False);
441 TOGGLE_STATE("rb_fityp_spli", !strncmp(Fityp, "SPLI", 4), False);
442 sprintf(str, "%d", Fitd);
443 XmTextSetString(UxGetWidget(UxFindSwidget("tf_fitd")), str);
444 sprintf(str, "%.2f", Smooth);
445 XmTextSetString(UxGetWidget(UxFindSwidget("tf_smooth")), str);
446
447 /* extraction form */
448 sprintf(str, "%d", Lowsky[0]);
449 XmTextSetString(UxGetWidget(UxFindSwidget("tf_lowsky1")), str);
450 sprintf(str, "%d", Lowsky[1]);
451 XmTextSetString(UxGetWidget(UxFindSwidget("tf_lowsky2")), str);
452 sprintf(str, "%d", Uppsky[0]);
453 XmTextSetString(UxGetWidget(UxFindSwidget("tf_uppsky1")), str);
454 sprintf(str, "%d", Uppsky[1]);
455 XmTextSetString(UxGetWidget(UxFindSwidget("tf_uppsky2")), str);
456 sprintf(str, "%d", Objlim[0]);
457 XmTextSetString(UxGetWidget(UxFindSwidget("tf_object1")), str);
458 sprintf(str, "%d", Objlim[1]);
459 XmTextSetString(UxGetWidget(UxFindSwidget("tf_object2")), str);
460 sprintf(str, "%d", Skyord);
461 XmTextSetString(UxGetWidget(UxFindSwidget("tf_skyord")), str);
462 sprintf(str, "%d", Order);
463 XmTextSetString(UxGetWidget(UxFindSwidget("tf_order")), str);
464 sprintf(str, "%d", Niter);
465 XmTextSetString(UxGetWidget(UxFindSwidget("tf_niter")), str);
466 sprintf(str, "%d", Radius);
467 XmTextSetString(UxGetWidget(UxFindSwidget("tf_radius")), str);
468 sprintf(str, "%g", Ron);
469 XmTextSetString(UxGetWidget(UxFindSwidget("tf_ron")), str);
470 sprintf(str, "%g", Gain);
471 XmTextSetString(UxGetWidget(UxFindSwidget("tf_gain")), str);
472 sprintf(str, "%g", Sigma);
473 XmTextSetString(UxGetWidget(UxFindSwidget("tf_sigma")), str);
474 TOGGLE_STATE("rb_extmtd_line", !strncmp(Extmtd, "LINE", 4), False);
475 TOGGLE_STATE("rb_extmtd_aver", !strncmp(Extmtd, "AVER", 4), False);
476 TOGGLE_STATE("rb_skymod_0", !Skymod, False);
477 TOGGLE_STATE("rb_skymod_1", Skymod, False);
478 XmTextSetString(UxGetWidget(UxFindSwidget("tf_sky")), DEFAULT_SKY);
479 }
480
481 int GetCoords( data, ncoords )
482 int data[];
483 int ncoords;
484 {
485 int nulval, sortcol, aw, ar, ncols, nrows;
486 char str[MAXLINE];
487 int aux, i, id, col_yw;
488
489 if ( ! file_exists( Coorfil, ".tbl" ) ) { /* do nothing */
490 sprintf(str, "*** Error: table %s could not be opened ***", Coorfil);
491 SCTPUT(str);
492 return FALSE;
493 }
494
495 TCTOPN(Coorfil, F_I_MODE, &id);
496
497 TCIGET(id, &ncols, &nrows, &sortcol, &aw, &ar);
498 if ( nrows < ncoords ) {
499 sprintf(str, "*** Error: only %d points given ***", nrows);
500 SCTPUT(str);
501 TCTCLO(id);
502 return FALSE;
503 }
504 TCCSER(id, ":y_wcoord", &col_yw);
505 if ( col_yw == -1 ) {
506 SCTPUT("*** Error: missing column :y_wcoord in 'COORTAB' ***");
507 TCTCLO(id);
508 return FALSE;
509 }
510
511 for ( i = 0; i < ncoords; i++ )
512 TCERDI(id, i+1, col_yw, &data[i], &nulval);
513
514 /* Now order from less to greater by pairs */
515 for ( i = 0; i < ncoords - 1; i += 2 )
516 if ( data[i] > data[i+1] ) {
517 aux = data[i+1];
518 data[i+1] = data[i];
519 data[i] = aux;
520 }
521
522 TCTCLO(id);
523
524 return TRUE;
525 }
526
527 /******************************************************************************
528 exist_airmass(): checks if the descriptor O_AIRM or AIRMASS exists in 'image'.
529 if it exists, returns the value in the variable 'airmass'.
530 */
531 int exist_airmass( image, airmass )
532 char *image;
533 float *airmass;
534 {
535 int nulval;
536 char descnam[10];
537 int unit;
538 int id;
539
540 if ( exist_descriptor(image, "O_AIRM") )
541 strcpy(descnam, "O_AIRM");
542 else if ( exist_descriptor(image, "AIRMASS") )
543 strcpy(descnam, "AIRMASS");
544 else
545 return FALSE;
546
547 SCFOPN(image, D_R4_FORMAT, 0, F_IMA_TYPE, &id);
548 SCDRDR( id, descnam, 1, 1, &nulval, airmass, &unit, &nulval );
549 SCFCLO(id);
550
551 return TRUE;
552 }
553
554 void WriteKeyword( text, keyword_cmd )
555 char *text;
556 char *keyword_cmd;
557 {
558 char command[MAXLINE];
559
560 sprintf(command, "%s%s", keyword_cmd, text);
561 AppendDialogText(command);
562 }
563
564 /*******************************************************************
565
566 Routines and variables needed to display the line catalog table in
567 a selection list.
568
569 ********************************************************************/
570
571 static LCTAB * Lc = NULL; /* Line catalog table */
572 static char * List[MAXTEXT];
573 static int LincatAllocated = FALSE;
574
575 float *fvector();
576 int *ivector();
577 char **cmatrix();
578
579 void free_catalog_table();
580 void free_lincat();
581
582 /*****************************************************************
583 * read_lincat_table(): reads line catalog named by 'Lincat' and
584 * stores the values in the 'Lc' structure, under the
585 * restrictions Wrang & Imin.
586 *****************************************************************/
587 int read_lincat_table()
588 {
589 if ( ! file_exists( Lincat, ".tbl" ) ) {
590 SCTPUT( "*** Line catalogue doesn't exist ***" );
591 return(FALSE);
592 }
593
594 if ( Lc != NULL ) /* deallocate space */
595 free_catalog_table(Lc);
596
597 Lc = (LCTAB *)osmmget( sizeof(LCTAB) );
598
599 if( !read_catalog_table( Lc, Lincat, Wrang, Imin ) ) {
600 Lc = NULL;
601
602 return FALSE;
603 }
604 return TRUE;
605 }
606
607 void display_lincat_table( wlist )
608 Widget wlist;
609 {
610 int i;
611 XmStringTable str_list;
612
613 if ( LincatAllocated )
614 free_lincat();
615 LincatAllocated = TRUE;
616
617 for ( i = 0; i < Lc->nrows; i++ )
618 List[i] = (char *)osmmget( 80 );
619 List[Lc->nrows] = NULL;
620
621 for ( i = 0; i < Lc->nrows; i++ )
622 sprintf( List[i], " %8.2f", Lc->wave[i]);
623
624 str_list = (XmStringTable)XtMalloc(Lc->nrows * sizeof(XmString *));
625 for ( i = 0; i < Lc->nrows; i++ )
626 str_list[i] = XmStringCreateSimple(List[i]);
627
628 XmListSetPos(wlist, 1);
629 XmListDeleteAllItems(wlist);
630 XmListAddItems(wlist, str_list, Lc->nrows, 1);
631
632 for ( i = 0; i < Lc->nrows; i++ )
633 XmStringFree(str_list[i]);
634 XtFree((char *)str_list);
635 }
636
637 void free_lincat()
638 {
639 int i;
640
641 for ( i = 0; i < Lc->nrows; i++ )
642 osmmfree( List[i] );
643 }
644