SINFONI Pipeline Reference Manual  2.6.0
sinfo_tpl_dfs.c
1 /* $Id: sinfo_tpl_dfs.c,v 1.13 2012-03-03 10:17:31 amodigli Exp $
2  *
3  * This file is part of the SINFONI 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: 2012-03-03 10:17:31 $
24  * $Revision: 1.13 $
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 #include "sinfo_utilities.h"
41 
42 #include "sinfo_tpl_dfs.h"
43 #include "sinfo_pro_types.h"
44 #include "sinfo_raw_types.h"
45 #include "sinfo_ref_types.h"
46 #include "sinfo_error.h"
47 #include "sinfo_msg.h"
48 
50 /*----------------------------------------------------------------------------*/
56 /*----------------------------------------------------------------------------*/
57 
58 /*----------------------------------------------------------------------------*/
68 /*----------------------------------------------------------------------------*/
69 static int
70 sinfo_dfs_files_dont_exist(cpl_frameset *frameset)
71 {
72  const char *func = "dfs_files_dont_exist";
73 
74  if (frameset == NULL ) {
75  cpl_error_set(func, CPL_ERROR_NULL_INPUT);
76  return 1;
77  }
78 
79  if (cpl_frameset_is_empty(frameset)) {
80  return 0;
81  }
82 
83  cpl_frameset_iterator* it = cpl_frameset_iterator_new(frameset);
84  cpl_frame *frame = cpl_frameset_iterator_get(it);
85 
86  while (frame) {
87  if (access(cpl_frame_get_filename(frame), F_OK)) {
88  cpl_msg_error(func, "File %s (%s) was not found",
89  cpl_frame_get_filename(frame),
90  cpl_frame_get_tag(frame));
91  cpl_error_set(func, CPL_ERROR_FILE_NOT_FOUND);
92  }
93  cpl_frameset_iterator_advance(it, 1);
94  frame = cpl_frameset_iterator_get(it);
95 
96  }
97 
98  cpl_frameset_iterator_delete(it);
99 
100  if (cpl_error_get_code())
101  return 1;
102 
103  return 0;
104 }
105 
106 /*----------------------------------------------------------------------------*/
112 /*----------------------------------------------------------------------------*/
113 int
114 sinfo_dfs_set_groups(cpl_frameset * set)
115 {
116  cpl_frame * cur_frame = NULL;
117  const char * tag = NULL;
118  int nframes = 0;
119  int i = 0;
120 
121  sinfo_skip_if(cpl_error_get_code());
122 
123  /* Check entries */
124  if (set == NULL )
125  return -1;
126 
127  /* Initialize */
128  nframes = cpl_frameset_get_size(set);
129 
130  /* Loop on frames */
131  for (i = 0; i < nframes; i++) {
132  cur_frame = cpl_frameset_get_frame(set, i);
133  tag = cpl_frame_get_tag(cur_frame);
134  if (cpl_error_get_code())
135  break;
136  if (tag == NULL )
137  sinfo_msg_warning("Frame %d has no tag", i);
138  /* RAW frames */
139  else if (!strcmp(tag, RAW_LINEARITY_LAMP) || !strcmp(tag, RAW_ON)
140  || !strcmp(tag, RAW_OFF) || !strcmp(tag, RAW_DARK)
141  || !strcmp(tag, RAW_FIBRE_NS)
142  || !strcmp(tag, RAW_FIBRE_PSF)
143  || !strcmp(tag, RAW_FIBRE_DARK)
144  || !strcmp(tag, RAW_FLAT_NS)
145  || !strcmp(tag, RAW_WAVE_NS)
146  || !strcmp(tag, RAW_FLAT_LAMP)
147  || !strcmp(tag, RAW_WAVE_LAMP)
148  || !strcmp(tag, RAW_PSF_CALIBRATOR)
149  || !strcmp(tag, RAW_SKY_PSF_CALIBRATOR)
150  || !strcmp(tag, RAW_STD) || !strcmp(tag, RAW_SKY)
151  || !strcmp(tag, RAW_SKY_STD)
152  || !strcmp(tag, RAW_OBJECT_NODDING)
153  || !strcmp(tag, RAW_SKY_NODDING)
154  || !strcmp(tag, RAW_OBJECT_JITTER)
155  || !strcmp(tag, RAW_SKY_JITTER)
156  || !strcmp(tag, RAW_PUPIL_LAMP)
157  || !strcmp(tag, RAW_IMAGE_PRE_OBJECT)
158  || !strcmp(tag, RAW_IMAGE_PRE_SKY)
159  || !strcmp(tag, RAW_OBJECT_SKYSPIDER))
160  cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
161  /* CALIB frames */
162  else if (!strcmp(tag, PRO_BP_MAP_HP)
163  || !strcmp(tag, SINFO_UTL_STDSTARS_RAW)
164  || !strcmp(tag, SINFO_CALIB_STDSTARS)
165  || !strcmp(tag, SINFO_CALIB_SED)
166  || !strcmp(tag, PRO_BP_MAP_NL)
167  || !strcmp(tag, PRO_BP_MAP_NO)
168  || !strcmp(tag, PRO_BP_MAP_DI)
169  || !strcmp(tag, PRO_BP_MAP_NL)
170  || !strcmp(tag, PRO_BP_MAP_NO)
171  || !strcmp(tag, PRO_BP_MAP) || !strcmp(tag, PRO_ILL_COR)
172  || !strcmp(tag, PRO_MASTER_BP_MAP)
173  || !strcmp(tag, PRO_MASTER_DARK)
174  || !strcmp(tag, PRO_DISTORTION)
175  || !strcmp(tag, PRO_SLITLETS_DISTANCE)
176  || !strcmp(tag, PRO_MASTER_FLAT_LAMP)
177  || !strcmp(tag, PRO_SLIT_POS)
178  || !strcmp(tag, PRO_SLIT_POS_GUESS)
179  || !strcmp(tag, PRO_FIRST_COL)
180  || !strcmp(tag, PRO_WAVE_MAP)
181  || !strcmp(tag, REF_LINE_ARC)
182  || !strcmp(tag, DRS_SETUP_WAVE)
183  || !strcmp(tag, EXTCOEFF_TABLE)
184  || !strcmp(tag, FLUX_STD_TABLE)
185  || !strcmp(tag, FLUX_STD_CATALOG)
186  || !strcmp(tag, PRO_IMA) || !strcmp(tag, PRO_CUBE)
187  || !strcmp(tag, REF_BP_MAP)
188  || !strcmp(tag, PRO_SKY_DUMMY)
189  || !strcmp(tag, PRO_REF_ATM_REF_CORR)
190  || !strcmp(tag, PRO_SPECTRUM))
191  cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
192  else if (!strcmp(tag, PRO_OBS_OBJ) || !strcmp(tag, PRO_MED_OBS_OBJ)
193  || !strcmp(tag, PRO_OBS_STD)
194  || !strcmp(tag, PRO_MED_OBS_STD)
195  || !strcmp(tag, PRO_OBS_PSF)
196  || !strcmp(tag, PRO_MED_OBS_PSF)
197  || !strcmp(tag, PRO_COADD_OBJ)
198  || !strcmp(tag, PRO_COADD_STD)
199  || !strcmp(tag, PRO_COADD_PSF)
200  || !strcmp(tag, PRO_COADD_PUPIL)
201  || !strcmp(tag, PRO_MED_COADD_OBJ)
202  || !strcmp(tag, PRO_MED_COADD_STD)
203  || !strcmp(tag, PRO_MED_COADD_PSF)
204  || !strcmp(tag, PRO_MED_COADD_PUPIL)
205  || !strcmp(tag, PRO_MASK_COADD_OBJ)
206  || !strcmp(tag, PRO_MASK_COADD_STD)
207  || !strcmp(tag, PRO_MASK_COADD_PSF)
208  || !strcmp(tag, PRO_MASK_COADD_PUPIL)
209  || !strcmp(tag, PRO_PSF_CALIBRATOR_STACKED)
210  || !strcmp(tag, PRO_SKY_PSF_CALIBRATOR_STACKED)
211  || !strcmp(tag, PRO_AO_PERFORMANCE)
212  || !strcmp(tag, PRO_ENC_ENERGY) || !strcmp(tag, PRO_PSF)
213  || !strcmp(tag, PRO_STD_STAR_SPECTRA)
214  || !strcmp(tag, PRO_STD_STAR_SPECTRUM)
215  || !strcmp(tag, PRO_MFLAT_CUBE)
216  || !strcmp(tag, PRO_MFLAT_AVG)
217  || !strcmp(tag, PRO_MFLAT_MED)
218  || !strcmp(tag, PRO_STACK_MFLAT_DIST)
219  || !strcmp(tag, PRO_WAVE_LAMP_STACKED)
220  || !strcmp(tag, PRO_FIBRE_NS_STACKED_OFF)
221  || !strcmp(tag, PRO_FIBRE_NS_STACKED_ON)
222  || !strcmp(tag, PRO_FIBRE_NS_STACKED)
223  || !strcmp(tag, PRO_SLITLETS_POS_PREDIST)
224  || !strcmp(tag, PRO_OBS_SKY)
225  || !strcmp(tag, PRO_SKY_MED)
226  || !strcmp(tag, PRO_FIBRE_NS_STACKED_DIST))
227  cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_PRODUCT);
228  else
229  sinfo_msg_warning("Frame %d has unknown tag: %s", i, tag);
230  }
231  ck0_nomsg(sinfo_dfs_files_dont_exist(set));
232  sinfo_skip_if(i != nframes);
233 
234  sinfo_end_skip;
235 
236  if (cpl_error_get_code())
237  sinfo_msg_error("Could not identify RAW and CALIB frames (in "
238  "frame set of size %d)", nframes);
239 
240  return cpl_error_get_code();
241 }
242 
#define sinfo_msg_error(...)
Print an error message.
Definition: sinfo_msg.h:69
#define sinfo_msg_warning(...)
Print an warning message.
Definition: sinfo_msg.h:93