MIDI Pipeline Reference Manual  2.8.3
midi_dfs.c
1 /* $Id: midi_dfs.c,v 1.11 2009-12-21 12:35:16 agabasch Exp $
2  *
3  * This file is part of the MIDI 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: agabasch $
23  * $Date: 2009-12-21 12:35:16 $
24  * $Revision: 1.11 $
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 <string.h>
37 #include <math.h>
38 
39 #include <cpl.h>
40 
41 #include "midi_dfs.h"
42 
43 /*----------------------------------------------------------------------------*/
49 /*----------------------------------------------------------------------------*/
50 
53 /*----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------*/
60 cpl_error_code midi_dfs_set_groups(cpl_frameset * set)
61 {
62  cpl_errorstate prestate = cpl_errorstate_get();
63  cpl_frame * frame = NULL;
64  int i = 0;
65 
66 
67  /* Loop on frames */
68  for (frame = cpl_frameset_get_first(set); frame != NULL;
69  frame = cpl_frameset_get_next(set), i++) {
70 
71  const char * tag = cpl_frame_get_tag(frame);
72 
73  if (tag == NULL) {
74  cpl_msg_warning(cpl_func, "Frame %d has no tag", i);
75  } else if (!strcmp(tag, MIDI_HIGH_SENS_CALIB ) ||
76  !strcmp(tag, MIDI_HIGH_SENS_SCIENCE ) ||
77  !strcmp(tag, MIDI_SCI_PHOT_CALIB ) ||
78  !strcmp(tag, MIDI_SCI_PHOT_SCIENCE ) ||
79  !strcmp(tag, MIDI_KAPPA_SP_CALIB ) ||
80  !strcmp(tag, MIDI_KAPPA_SP_SCIENCE ) ||
81  !strcmp(tag, MIDI_ACQ ) ||
82  !strcmp(tag, MIDI_DETLIN ) ||
83  !strcmp(tag, MIDI_DETRON ) ||
84  !strcmp(tag, MIDI_DSPTRN ) ||
85  !strcmp(tag, MIDI_REFPIX ) ||
86  !strcmp(tag, MIDI_WAVECAL ) ||
87  !strcmp(tag, MIDI_PHOTOM_SP_CALIB ) ||
88  !strcmp(tag, MIDI_PHOTOM_SP_SCIENCE ) ||
89  !strcmp(tag, MIDI_PHOTOM_HS_CALIB ) ||
90  !strcmp(tag, MIDI_PHOTOM_HS_SCIENCE ) ||
91  !strcmp(tag, MIDI_OTHER_DETLIN ) ||
92  !strcmp(tag, MIDI_OTHER_DETRON ) ||
93  !strcmp(tag, MIDI_OTHER_DSPTRN ) ||
94  !strcmp(tag, MIDI_OTHER_GENERIC ) ||
95  !strcmp(tag, MIDI_OTHER_REFPIX ) ||
96  !strcmp(tag, MIDI_OTHER_WAVECAL ) ||
97  !strcmp(tag, MIDI_OTHER_ACQ ) ||
98  !strcmp(tag, MIDI_DOME_AOPEN ) ||
99  !strcmp(tag, MIDI_DOME_BOPEN ) ||
100  !strcmp(tag, MIDI_INTERNAL_OPD ) ||
101  !strcmp(tag, MIDI_CAL_SEARCH ) ||
102  !strcmp(tag, MIDI_OTHER_FRINGE ))
103  {
104  /* RAW frames */
105  cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
106  } else if (!strcmp(tag, MIDI_CALIB_FLAT) ||
107  !strcmp(tag, MIDI_KAPPA_SP_MASK_PRISM) ||
108  !strcmp(tag, MIDI_KAPPA_SP_MASK_GRISM) ||
109  !strcmp(tag, MIDI_KAPPA_HS_MASK_PRISM) ||
110  !strcmp(tag, MIDI_KAPPA_HS_MASK_GRISM) ||
111  !strcmp(tag, MIDI_KAPPAMATRIX_PRISM) ||
112  !strcmp(tag, MIDI_KAPPAMATRIX_GRISM) ||
113  !strcmp(tag, MIDI_TRF_GRISM) ||
114  !strcmp(tag, MIDI_TRF_PRISM) ||
115  !strcmp(tag, MIDI_CALIB_DATABASE))
116  {
117  /* CALIB frames */
118  cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB);
119  }
120 
121 
122 
123 
124 
125 
126 
127  }
128 
129  if (!cpl_errorstate_is_equal(prestate)) {
130  return cpl_error_set_message(cpl_func, cpl_error_get_code(),
131  "Could not identify RAW and CALIB "
132  "frames");
133  }
134 
135  return CPL_ERROR_NONE;
136 }
137