UVES Pipeline Reference Manual  5.4.0
flames_midas_def.h
1 /*
2  * This file is part of the ESO UVES Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2011-12-08 13:56:55 $
23  * $Revision: 1.4 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.3 2010/09/24 09:32:02 amodigli
27  * put back QFITS dependency to fix problem spot by NRI on FIBER mode (with MIDAS calibs) data
28  *
29  * Revision 1.1 2009/04/14 07:01:07 amodigli
30  * added to CVS (moded from flames tree)
31  *
32  * Revision 1.19 2007/10/01 17:19:50 amodigli
33  * added scdprs
34  *
35  * Revision 1.18 2007/06/22 14:52:18 jmlarsen
36  * Exported dtype_to_cpltype function
37  *
38  * Revision 1.17 2007/06/08 15:38:08 jmlarsen
39  * Added option to not automatically propagate NAXIS
40  *
41  * Revision 1.16 2007/06/06 08:17:33 amodigli
42  * replace tab with 4 spaces
43  *
44  * Revision 1.15 2007/06/04 11:26:40 jmlarsen
45  * Added SCKGETC_fsp for cpl_frameset pointers
46  *
47  * Revision 1.14 2007/05/30 12:06:03 amodigli
48  * #include<fitsio.h>
49  *
50  * Revision 1.13 2007/05/29 14:39:50 jmlarsen
51  * Readded 3d table functions but map them to simple (2d) table functions
52  *
53  * Revision 1.12 2007/05/29 13:46:23 jmlarsen
54  * Removed 3d table column stubs which were not needed for FLAMES
55  *
56  * Revision 1.11 2007/04/10 07:31:13 jmlarsen
57  * Added TCTID
58  *
59  * Revision 1.10 2007/04/03 11:05:33 jmlarsen
60  * Implemented table module
61  *
62  * Revision 1.9 2007/03/26 12:40:52 jmlarsen
63  * Converted SCTDIS calls
64  *
65  * Revision 1.8 2007/03/23 13:44:37 jmlarsen
66  * Implemented SCKWR- functions
67  *
68  * Revision 1.7 2007/03/23 10:10:15 jmlarsen
69  * Implemented catalog interface
70  *
71  * Revision 1.6 2007/03/05 09:40:31 jmlarsen
72  * Added SCDCOP
73  *
74  * Revision 1.5 2007/02/27 14:09:31 jmlarsen
75  * Extended interface of uves_find_property
76  *
77  * Revision 1.4 2007/01/31 13:14:57 jmlarsen
78  * Initial implementation of SCFGET
79  *
80  * Revision 1.3 2007/01/29 13:09:57 jmlarsen
81  * Work on conversion to CPL
82  *
83  * Revision 1.2 2007/01/15 14:00:23 jmlarsen
84  * Imported FLAMES sources from MIDAS pipeline
85  *
86  * Revision 1.1 2007/01/10 08:06:10 jmlarsen
87  * Added source files
88  *
89  * Revision 1.1 2006/10/20 06:42:09 jmlarsen
90  * Moved FLAMES source to flames directory
91  *
92  * Revision 1.78 2006/10/12 11:37:28 jmlarsen
93  * Temporarily disabled FLAMES code generation
94  *
95  */
96 #ifndef FLAMES_MIDAS_DEF_H
97 #define FLAMES_MIDAS_DEF_H
98 
99 #ifdef HAVE_CONFIG_H
100 # include <config.h>
101 #endif
102 #include <uves_cpl_size.h>
103 /*-----------------------------------------------------------------------------
104  Includes
105  -----------------------------------------------------------------------------*/
106 #include <fitsio.h>
107 #include <cpl.h>
108 /*-----------------------------------------------------------------------------
109  Typedefs
110  -----------------------------------------------------------------------------*/
111 
112 /*-----------------------------------------------------------------------------
113  Defines
114  -----------------------------------------------------------------------------*/
115 /* Definitions not used by FLAMES are commented out */
116 /* from flames_uves.h */
117 #define MAREMMA 2
118 
119 /* Data types */
120 #define D_OLD_FORMAT 0
121 #define D_I1_FORMAT 1 /* I*1 = 1 byte */
122 #define D_I2_FORMAT 2 /* I*2 = 16 bit integer */
123 #define D_UI2_FORMAT 102 /* I*2 = 16 bit unsigned integer */
124 #define D_I4_FORMAT 4 /* I*4 = 32 bit integer */
125 #define D_R4_FORMAT 10 /* R*4 = 32 bit floating point */
126 #define D_R8_FORMAT 18 /* R*8 = 64 bit floating point */
127 //#define D_L1_FORMAT 21 /* L*1 = 1 byte logical */
128 //#define D_L2_FORMAT 22 /* L*2 = 16 bit logical */
129 #define D_L4_FORMAT 24 /* L*4 = 32 bit logical */
130 #define D_C_FORMAT 30 /* 1 byte character */
131 //#define D_X_FORMAT 40 /* 1 byte flags */
132 //#define D_P_FORMAT 50 /* pointers */
133 
134 
135 
136 /* Filetypes */
137 //#define F_OLD_TYPE 0 /* use old type of files */
138 #define F_IMA_TYPE 1 /* type no. for image files */
139 //#define F_ASC_TYPE 2 /* type no. for ASCII files */
140 #define F_TBL_TYPE 3 /* type no. for table files */
141 //#define F_FIT_TYPE 4 /* type no. for fit files */
142 //#define F_FIMA_TYPE 11 /* type no. for FITS images */
143 //#define F_FTBL_TYPE 13 /* type no. for FITS tables */
144 //#define F_FFIT_TYPE 14 /* type no. for FITS fit files */
145 
146 
147 
148 /* Opening modes */
149 //#define F_TRANS 0 /* table transposed format */
150 //#define F_RECORD 1 /* table record format */
151 #define F_I_MODE 0 /* map file for input only */
152 #define F_O_MODE 1 /* map file for output */
153 #define F_IO_MODE 2 /* map file for updating */
154 //#define F_U_MODE 2 /* map file for updating */
155 //#define F_X_MODE 9 /* create/map virtual memory */
156 //#define F_H_MODE 7 /* create header file only */
157 //#define F_FO_MODE 11 /* map FITS file for output */
158 
159 /* May be combined with */
160 //#define F_MAP_FORCE 0x10 /* Force the mapping (modifier) */
161 //#define F_EIO_FORCE 0x20 /* Force the elementary i/o (modifier)*/
162 //#define F_ALL_FORCE 0x40 /* Force the allocated values */
163 
164 /* Table i/o modes */
165 #define F_D_MODE 2 /* map for descriptors only */
166 
167 /* From midas_def.h */
168 #define TEXT_LEN 84
169 
170 
171 
172 
173 
174 /* init, end */
175 #define SCSPRO(name) flames_midas_scspro(name)
176 #define SCSEPI() flames_midas_scsepi()
177 
178 /* error handling */
179 
180 /* display text */
181 #define SCTPUT(msg) flames_midas_sctput(msg, __func__, __FILE__, __LINE__)
182 
183 /* access keywords */
184 #define SCKGETC(key, felem, maxvals, actvals, values) flames_midas_sckgetc(key, felem, maxvals, actvals, values)
185 #define SCKGETC_fs(key, felem, maxvals, actvals, values) flames_midas_sckgetc_fs(key, felem, maxvals, actvals, values)
186 #define SCKGETC_fsp(key, felem, maxvals, actvals, values) flames_midas_sckgetc_fsp(key, felem, maxvals, actvals, values)
187 #define SCKFND(key, type, noelem, bytelem) flames_midas_sckfnd(key, type, noelem, bytelem)
188 #define SCKFND_double(key, type, noelem, bytelem) flames_midas_sckfnd_double(key, type, noelem, bytelem)
189 #define SCKFND_float(key, type, noelem, bytelem) flames_midas_sckfnd_float(key, type, noelem, bytelem)
190 #define SCKFND_int(key, type, noelem, bytelem) flames_midas_sckfnd_int(key, type, noelem, bytelem)
191 #define SCKFND_string(key, type, noelem, bytelem) flames_midas_sckfnd_string(key, type, noelem, bytelem)
192 
193 #define SCKRDD(key, felem, maxvals, actvals, values, unit, null) flames_midas_sckrdd(key, felem, maxvals, actvals, values, unit, null)
194 #define SCKRDC(key, noelem, felem, maxvals, actvals, values, unit, null) flames_midas_sckrdc(key, noelem, felem, maxvals, actvals, values, unit, null)
195 #define SCKRDI(key, felem, maxvals, actvals, values, unit, null) flames_midas_sckrdi(key, felem, maxvals, actvals, values, unit, null)
196 #define SCKRDR(key, felem, maxvals, actvals, values, unit, null) flames_midas_sckrdr(key, felem, maxvals, actvals, values, unit, null)
197 
198 #define SCKWRC(key, noelem, values, felem, maxval, unit) flames_midas_sckwrc(key, noelem, values, felem, maxval, unit)
199 #define SCKWRD(key, values, felem, maxval, unit) flames_midas_sckwrd(key, values, felem, maxval, unit)
200 #define SCKWRI(key, values, felem, maxval, unit) flames_midas_sckwri(key, values, felem, maxval, unit)
201 
202 /* manipulate catalogues */
203 #define SCCADD(catfile, name, ident) flames_midas_sccadd(catfile, name, ident)
204 #define SCCCRE(catfile, type, flag) flames_midas_scccre(catfile, type, flag)
205 #define SCCFND(catfile, frmno, frame) flames_midas_sccfnd(catfile, frmno, frame)
206 #define SCCGET(catfile, flag, name, ident, no) flames_midas_sccget(catfile, flag, name, ident, no)
207 #define SCCSHO(catfile, noent, last) flames_midas_sccsho(catfile, noent, last)
208 
209 /* access bulk data frames (bdf) */
210 #define SCFINF(name, fno, ibuf) flames_midas_scfinf(name, fno, ibuf)
211 #define SCFCRE(name, dattype, iomode, filtype, size, imno) flames_midas_scfcre(name, dattype, iomode, filtype, size, imno)
212 #define SCFOPN(name, dattype, newopn, filtype, imno) flames_midas_scfopn(name, dattype, newopn, filtype, imno)
213 #define SCFCLO(imno) flames_midas_scfclo(imno)
214 #define SCFPUT(imno, felem, size, bufadr) flames_midas_scfput(imno, felem, size, bufadr)
215 #define SCFGET(imno, felem, size, actsize, bufadr) flames_midas_scfget(imno, felem, size, actsize, bufadr)
216 
217 /* access descriptors */
218 #define SCDFND(imno, descr, type, noelem, bytelem) flames_midas_scdfnd(imno, descr, type, noelem, bytelem)
219 #define SCDPRS(imno, descr, type, noelem, bytelem) flames_midas_scdprs(imno, descr, type, noelem, bytelem)
220 #define SCDRDI(imno, descr, felem, maxvals, actvals, values, unit, null) flames_midas_scdrdi(imno, descr, felem, maxvals, actvals, values, unit, null)
221 #define SCDRDD(imno, descr, felem, maxvals, actvals, values, unit, null) flames_midas_scdrdd(imno, descr, felem, maxvals, actvals, values, unit, null)
222 #define SCDWRI(imno, descr, values, felem, nval, unit) flames_midas_scdwri(imno, descr, values, felem, nval, unit)
223 #define SCDWRD(imno, descr, values, felem, nval, unit) flames_midas_scdwrd(imno, descr, values, felem, nval, unit)
224 #define SCDWRR(imno, descr, values, felem, nval, unit) flames_midas_scdwrr(imno, descr, values, felem, nval, unit)
225 #define SCDWRC(imno, descr, noelm, values, felem, nval, unit) flames_midas_scdwrc(imno, descr, noelm, values, felem, nval, unit)
226 #define SCDCOP(from, to, mask) flames_midas_scdcop(from, to, mask)
227 #define SCDCOP_nonaxis(from, to, mask) flames_midas_scdcop_nonaxis(from, to, mask)
228 #define SCDDEL(imno, descr) flames_midas_scddel(imno, descr)
229 #define SCDRDR(imno, descr, felem, maxvals, actvals, values, unit, null) flames_midas_scdrdr(imno, descr, felem, maxvals, actvals, values, unit, null)
230 #define SCDRDC(imno, descr, noelem, felem, maxvals, actvals, values, unit, null) flames_midas_scdrdc(imno, descr, noelem, felem, maxvals, actvals, values, unit, null)
231 /* note: SCDGETC is same as SCDRDC with noelem = number of bytes per data value = 1 */
232 #define SCDGETC(imno, descr, felem, maxvals, actvals, values) SCDRDC(imno, descr, 1, felem, maxvals, actvals, values, NULL, NULL)
233 
234 /* table access */
235 #define TCTOPN(name, mode, tid) flames_midas_tctopn(name, mode, -1, tid)
236 #define TCTCLO(tid) flames_midas_tctclo(tid)
237 #define TCCSER(tid, colref, column) flames_midas_tccser(tid, colref, column)
238 #define TCIGET(tid, column, row) flames_midas_tciget(tid, column, row)
239 
240 #define TCERDD(tid, row, column, value, null) flames_midas_tcerdd(tid, row, column, value, null)
241 
242 #define TCBGET(tid, column, dtype, items, bytes) flames_midas_tcbget(tid, column, dtype, items, bytes)
243 
244 #define TCCINI(tid, dtype, alen, form, unit, label, column) flames_midas_tccini(tid, dtype, alen, form, unit, label, column)
245 #define TCDGET(tid, store) flames_midas_tcdget(tid, store)
246 
247 #define TCERDC(tid, row, column, values, null) flames_midas_tcerdc(tid, row, column, values, null)
248 #define TCERDI(tid, row, column, values, null) flames_midas_tcerdi(tid, row, column, values, null)
249 #define TCERDR(tid, row, column, values, null) flames_midas_tcerdr(tid, row, column, values, null)
250 #define TCEWRC(tid, row, column, value) flames_midas_tcewrc(tid, row, column, value)
251 #define TCEWRD(tid, row, column, value) flames_midas_tcewrd(tid, row, column, value)
252 #define TCEWRI(tid, row, column, value) flames_midas_tcewri(tid, row, column, value)
253 #define TCEWRR(tid, row, column, value) flames_midas_tcewrr(tid, row, column, value)
254 
255 #define TCARDC(tid, row, col, index, items, value) flames_midas_tcardc(tid, row, col, index, items, value)
256 #define TCARDD(tid, row, col, index, items, value) flames_midas_tcardd(tid, row, col, index, items, value)
257 #define TCARDI(tid, row, col, index, items, value) flames_midas_tcardi(tid, row, col, index, items, value)
258 #define TCARDR(tid, row, col, index, items, value) flames_midas_tcardr(tid, row, col, index, items, value)
259 #define TCAWRC(tid, row, col, index, items, value) flames_midas_tcawrc(tid, row, col, index, items, value)
260 #define TCAWRD(tid, row, col, index, items, value) flames_midas_tcawrd(tid, row, col, index, items, value)
261 #define TCAWRI(tid, row, col, index, items, value) flames_midas_tcawri(tid, row, col, index, items, value)
262 #define TCAWRR(tid, row, col, index, items, value) flames_midas_tcawrr(tid, row, col, index, items, value)
263 
264 #define TCFGET(tid, column, form, dtype) flames_midas_tcfget(tid, column, form, dtype)
265 #define TCLGET(tid, column, label) flames_midas_tclget(tid, column, label)
266 #define TCLSER(tid, label, column) flames_midas_tclser(tid, label, column)
267 #define TCSGET(tid, row, value) flames_midas_tcsget(tid, row, value)
268 #define TCSPUT(tid, row, value) flames_midas_tcsput(tid, row, value)
269 
270 /* TCTINI --> TCTOPN */
271 #define TCTINI(name, mode, allrow, tid) flames_midas_tctopn(name, mode, allrow, tid)
272 
273 #define TCUGET(tid, column, unit) flames_midas_tcuget(tid, column, unit)
274 
275 #define flames_midas_fail() flames_midas_fail_macro(__FILE__, __func__, __LINE__)
276 #define flames_midas_error(status) flames_midas_error_macro(__FILE__, __func__, __LINE__, status)
277 
278 /*-----------------------------------------------------------------------------
279  Prototypes
280  -----------------------------------------------------------------------------*/
281 
282 /* init, end */
283 int flames_midas_scspro(const char *name);
284 int flames_midas_scsepi(void);
285 int flames_midas_fail_macro(const char *file, const char *function, int line);
286 int flames_midas_error_macro(const char *file, const char *function, int line,
287  int status);
288 
289 /* error handling */
290 
291 
292 /* access keywords */
293 int flames_midas_sckgetc(const char *key,
294  int felem, int maxvals,
295  int *actvals, char *values);
296 int flames_midas_sckgetc_fs(const cpl_frameset *key,
297  int felem, int maxvals,
298  int *actvals, const cpl_frameset **values);
299 
300 int flames_midas_sckgetc_fsp(cpl_frameset **key,
301  int felem, int maxvals,
302  int *actvals, cpl_frameset ***values);
303 
304 int flames_midas_sckrdd(const double *key, int felem, int maxvals,
305  int *actvals, double *values, int *unit, int *null);
306 int flames_midas_sckrdi(const int *key, int felem, int maxvals,
307  int *actvals, int *values, int *unit, int *null);
308 int flames_midas_sckrdr(const float *key, int felem, int maxvals,
309  int *actvals, float *values, int *unit, int *null);
310 int flames_midas_sckrdc(const char *key, int noelem, int felem, int maxvals,
311  int *actvals, char *values, int *unit, int *null);
312 
313 int flames_midas_sckwri(int *key, const int *values,
314  int felem, int maxval, int *unit);
315 int flames_midas_sckwrd(double *key, const double *values,
316  int felem, int maxval, int *unit);
317 int flames_midas_sckwrc(char *key, int noelem,
318  const char *values, int felem, int maxvals, int *unit);
319 
320 int flames_midas_sckfnd_double(const double *key, char *type, int *noelem, int *bytelem);
321 int flames_midas_sckfnd_float(const float *key, char *type, int *noelem, int *bytelem);
322 int flames_midas_sckfnd_int(const int *key, char *type, int *noelem, int *bytelem);
323 int flames_midas_sckfnd_string(const char *key, char *type, int *noelem, int *bytelem);
324 
325 
326 /* display text */
327 int flames_midas_sctput(const char *msg,
328  const char *func, const char *file, int line);
329 
330 /* access bulk data frames (bdf) */
331 int flames_midas_scfopn(const char *name, int dattype, int newopn, int filtype, int *imno);
332 int flames_midas_scfclo(int imno);
333 int flames_midas_scfcre(const char *name, int dattype, int iomode, int filtype,
334  int size, int *imno);
335 int flames_midas_scfinf(const char *name, int fno, int *ibuf);
336 int flames_midas_scfget(int imno, int felem, int size, int *actsize, char *bufadr);
337 int flames_midas_scfput(int imno, int felem, int size, const char *bufadr);
338 
339 /* access descriptors */
340 int flames_midas_scdfnd(int imno, const char *descr,
341  char *type, int *noelem, int *bytelem);
342 
343 int flames_midas_scdprs(int imno, const char *descr,
344  char *type, int *noelem, int *bytelem);
345 
346 int flames_midas_scdrdi(int imno, const char *descr,
347  int felem, int maxvals,
348  int *actvals, int *values,
349  int *unit, int *null);
350 int flames_midas_scdrdd(int imno, const char *descr,
351  int felem, int maxvals,
352  int *actvals, double *values,
353  int *unit, int *null);
354 int flames_midas_scdrdr(int imno, const char *descr,
355  int felem, int maxvals,
356  int *actvals, float *values,
357  int *unit, int *null);
358 int flames_midas_scdrdc(int imno, const char *descr,
359  int noelem,
360  int felem, int maxvals,
361  int *actvals, char *values,
362  int *unit, int *null);
363 
364 int flames_midas_scdwri(int imno, const char *descr, const int *values,
365  int felem, int nval, const int *unit);
366 int flames_midas_scdwrd(int imno, const char *descr, const double *values,
367  int felem, int nval, const int *unit);
368 
369 int flames_midas_scdwrr(int imno, const char *descr, const float *values,
370  int felem, int nval, const int *unit);
371 int flames_midas_scdwrc(int imno, const char *descr, int noelm, const char *values,
372  int felem, int nval, const int *unit);
373 
374 int flames_midas_scdcop(int from, int to, int mask);
375 int flames_midas_scdcop_nonaxis(int from, int to, int mask);
376 
377 int flames_midas_scddel(int imno, const char *descr);
378 
379 /* tables */
380 int flames_midas_tctopn(const char *name, int mode, int allrow, int *tid);
381 int flames_midas_tctclo(int tid);
382 int flames_midas_tccser(int tid, const char *colref, int *column);
383 int flames_midas_tciget(int tid, int *column, int *row);
384 
385 int flames_midas_tcardc(int tid, int row, int col, int index, int items, char *value);
386 int flames_midas_tcardd(int tid, int row, int col, int index, int items, double *value);
387 int flames_midas_tcardi(int tid, int row, int col, int index, int items, int *value);
388 int flames_midas_tcardr(int tid, int row, int col, int index, int items, float *value);
389 int flames_midas_tcawrc(int tid, int row, int col, int index, int items, const char *value);
390 int flames_midas_tcawrd(int tid, int row, int col, int index, int items, const double *value);
391 int flames_midas_tcawri(int tid, int row, int col, int index, int items, const int *value);
392 int flames_midas_tcawrr(int tid, int row, int col, int index, int items, const float *value);
393 int flames_midas_tcbget(int tid, int column, int *dtype, int *items, int *bytes);
394 int flames_midas_tcdget(int tid, int *store);
395 int flames_midas_tcfget(int tid, int column, char *form, int *dtype);
396 int flames_midas_tclget(int tid, int column, char *label);
397 int flames_midas_tcuget(int tid, int column, char *unit);
398 int flames_midas_tclser(int tid, const char *label, int *column);
399 int flames_midas_tccini(int tid, int dtype, int alen,
400  const char *form, const char *unit, const char *label,
401  int *column);
402 int flames_midas_tcerdc(int tid, int row, int column, char *values, int *null);
403 int flames_midas_tcerdi(int tid, int row, int column, int *values, int *null);
404 int flames_midas_tcerdr(int tid, int row, int column, float *values, int *null);
405 int flames_midas_tcerdd(int tid, int row, int column,
406  double *value, int *null);
407 int flames_midas_tcewrc(int tid, int row, int column, const char *value);
408 int flames_midas_tcewri(int tid, int row, int column, const int *value);
409 int flames_midas_tcewrr(int tid, int row, int column, const float *value);
410 int flames_midas_tcewrd(int tid, int row, int column, const double *value);
411 int flames_midas_tcsget(int tid, int row, int *value);
412 int flames_midas_tcsput(int tid, int row, const int *value);
413 
414 /* catalogs */
415 int flames_midas_sccsho(const cpl_frameset *catfile,
416  int *noent,
417  int *last);
418 
419 int flames_midas_sccget(const cpl_frameset *catfile,
420  int flag,
421  char *name, char *ident,
422  int *no);
423 
424 int flames_midas_sccfnd(const cpl_frameset *catfile,
425  int frmno,
426  char *frame);
427 int flames_midas_scccre(cpl_frameset **catfile,
428  int type,
429  int flag);
430 int flames_midas_sccadd(cpl_frameset *catfile,
431  const char *name,
432  const char *ident);
433 
434 /* Other */
435 cpl_type
437 
438 
439 #endif