VISIR Pipeline Reference Manual  4.1.7
visir_dfs.c
1 /* $Id: visir_dfs.c,v 1.79 2013-05-14 12:59:23 jtaylor Exp $
2  *
3  * This file is part of the VISIR 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., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: jtaylor $
23  * $Date: 2013-05-14 12:59:23 $
24  * $Revision: 1.79 $
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 "irplib_utils.h"
37 #include "visir_utils.h"
38 #include "visir_pfits.h"
39 #include "visir_dfs.h"
40 #include <cpl.h>
41 
42 #include <stdarg.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <math.h>
46 
47 
48 /*-----------------------------------------------------------------------------
49  Private function prototypes
50  -----------------------------------------------------------------------------*/
51 
52 static const char * visir_dfs_find_tag_from_dpr(const char *, const char *,
53  const char *);
54 
55 /*----------------------------------------------------------------------------*/
61 /*----------------------------------------------------------------------------*/
62 
65 /*----------------------------------------------------------------------------*/
71 /*----------------------------------------------------------------------------*/
72 int visir_dfs_set_groups(cpl_frameset * set)
73 {
74  int i = 0;
75 
76 
77  skip_if (0);
78 
79  /* Loop on frames */
80  FOR_EACH_FRAMESET(frame, set) {
81  const char * tag = cpl_frame_get_tag(frame);
82 
83  skip_if (0);
84 
85  /* RAW frames */
86  if (tag == NULL) cpl_msg_warning(cpl_func,
87  "Frame %d has no tag", i);
88  else if (!strcmp(tag, VISIR_IMG_ACHRO_RAW) ||
89  !strcmp(tag, VISIR_IMG_COMBINE_CN) ||
90  !strcmp(tag, VISIR_IMG_COMBINE_CN_BURST) ||
91  !strcmp(tag, VISIR_IMG_COMBINE_CNJ) ||
92  !strcmp(tag, VISIR_IMG_COMBINE_CNJ_BURST) ||
93  !strcmp(tag, VISIR_IMG_COMBINE_CJ) ||
94  !strcmp(tag, VISIR_IMG_COMBINE_NJ) ||
95  !strcmp(tag, VISIR_IMG_COMBINE_DJ) ||
96  !strcmp(tag, VISIR_IMG_CAL_PHOT) ||
97  !strcmp(tag, VISIR_IMG_CAL_PHOT_BURST) ||
98  !strcmp(tag, VISIR_IMG_CAL_OBJ) ||
99  !strcmp(tag, VISIR_IMG_CAL_OBJ_BURST) ||
100  !strcmp(tag, VISIR_IMG_FF_RAW) ||
101  !strcmp(tag, VISIR_IMG_TECH_FF_RAW) ||
102  !strcmp(tag, VISIR_IMG_FOCFWHM_RAW) ||
103  !strcmp(tag, VISIR_IMG_ILLU_RAW) ||
104  !strcmp(tag, VISIR_IMG_PFOV_BIN) ||
105  !strcmp(tag, VISIR_IMG_PFOV_TEL) ||
106  !strcmp(tag, VISIR_IMG_PHOT_RAW) ||
107  !strcmp(tag, VISIR_IMG_PSF_RAW) ||
108  !strcmp(tag, VISIR_IMG_TRANS_RAW) ||
109  !strcmp(tag, VISIR_IMG_DARK_RAW) ||
110  !strcmp(tag, VISIR_ACQ_CNJ) ||
111  !strcmp(tag, VISIR_SPC_OBS_ECH_RAW) ||
112  !strcmp(tag, VISIR_SPC_OBS_RAW) ||
113  !strcmp(tag, VISIR_SPC_OBS_PP) ||
114  !strcmp(tag, VISIR_SPC_OBS_HR_RAW) ||
115  !strcmp(tag, VISIR_SPC_PHOT_RAW) ||
116  !strcmp(tag, VISIR_SPC_PHOT_PP) ||
117  !strcmp(tag, VISIR_SPC_PHOT_ECH_RAW) ||
118  !strcmp(tag, VISIR_SPC_PHOT_ECH_PP) ||
119  !strcmp(tag, VISIR_SPC_WCAL_ECH_RAW) ||
120  !strcmp(tag, VISIR_SPC_WCAL_RAW) ||
121  !strcmp(tag, VISIR_SPC_FF_RAW) ||
122  !strcmp(tag, VISIR_SPC_TECH_FF_RAW) ||
123  !strcmp(tag, VISIR_SPC_DARK_RAW) ||
124  !strcmp(tag, VISIR_IMG_LINES_ASCII) ||
125  !strcmp(tag, VISIR_SPC_LINES_ASCII) ||
126  !strcmp(tag, VISIR_SPC_QEFF_ASCII) ||
127  !strcmp(tag, VISIR_SAM_CAL_N_RAW) ||
128  !strcmp(tag, VISIR_SAM_CAL_CN_RAW) ||
129  !strcmp(tag, VISIR_SAM_CAL_NJ_RAW) ||
130  !strcmp(tag, VISIR_SAM_CAL_CNJ_RAW) ||
131  !strcmp(tag, VISIR_CORO_CAL_CNJ_RAW) ||
132  !strcmp(tag, VISIR_SAM_OBS_N_RAW) ||
133  !strcmp(tag, VISIR_SAM_OBS_CN_RAW) ||
134  !strcmp(tag, VISIR_SAM_OBS_NJ_RAW) ||
135  !strcmp(tag, VISIR_SAM_OBS_CNJ_RAW) ||
136  !strcmp(tag, VISIR_CORO_OBS_CNJ_RAW) ||
137  !strcmp(tag, VISIR_UTIL_INPUTS_RAW) ||
138  !strcmp(tag, VISIR_UTIL_CORRECTED) ||
139  !strcmp(tag, VISIR_UTIL_NODDED) ||
140  !strcmp(tag, VISIR_UTIL_CONVERT_RAW) ||
141  !strcmp(tag, VISIR_UTIL_CONVERT_TAB) ||
142  !strcmp(tag, VISIR_UTIL_CONVERT_INV) ||
143  !strcmp(tag, VISIR_UTIL_CONVERT_POS_AUX) ||
144  !strcmp(tag, VISIR_UTIL_CONVERT_INV_AUX) ||
145  !strcmp(tag, VISIR_UTIL_WEIGHT2ERROR) ||
146  !strcmp(tag, VISIR_IMG_BURST) ||
147  !strcmp(tag, VISIR_UTIL_DATA) ||
148  !strcmp(tag, VISIR_UTIL_UNDISTORT_RAW) ||
149  !strcmp(tag, VISIR_UTIL_REPACK_RAW))
150  cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
151  /* CALIB frames */
152  else if (!strcmp(tag, VISIR_CALIB_FLAT) ||
153  !strcmp(tag, VISIR_CALIB_BPM) ||
154  !strcmp(tag, VISIR_CALIB_STATIC_MASK) ||
155  !strcmp(tag, VISIR_CALIB_STATIC_MASK_IMG) ||
156  !strcmp(tag, VISIR_CALIB_STATIC_MASK_SPC) ||
157  !strcmp(tag, VISIR_CALIB_STDSTAR_IMG) ||
158  !strcmp(tag, VISIR_CALIB_STDSTAR_SPC) ||
159  !strcmp(tag, VISIR_CALIB_LINES_SPC) ||
160  !strcmp(tag, VISIR_CALIB_LIN) ||
161  !strcmp(tag, VISIR_SPC_OBS_SKYFRAME) ||
162  !strcmp(tag, VISIR_UTIL_WEIGHT2ERROR_PROCATG) ||
163  !strcmp(tag, VISIR_IMG_CLIPPED_MAP_PROCATG) ||
164  !strcmp(tag, VISIR_UTIL_WEIGHT2ERROR) ||
165  !strcmp(tag, VISIR_UTIL_WEIGHT_MAP) ||
166  !strcmp(tag, VISIR_UTIL_ERROR_MAP) ||
167  !strcmp(tag, VISIR_UTIL_VARIANCE_MAP) ||
168  !strcmp(tag, VISIR_SPC_CAT_ASCII) ||
169  !strcmp(tag, VISIR_CALIB_QEFF_SPC))
170  cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB);
171  else cpl_msg_warning(cpl_func,
172  "Frame %d has unknown tag: %s", i, tag);
173  }
174 
175  end_skip;
176 
177  if (cpl_error_get_code())
178  cpl_msg_error(cpl_func, "Could not identify RAW and CALIB frames "
179  "(after processing %d frames)", i);
180 
181  return cpl_error_get_code();
182 }
183 
184 const char *
185 visir_dfs_output_catg(const char * inpcatg, const char * pipecatg)
186 {
187  int phot = 0;
188  if (!strcmp(pipecatg, VISIR_IMG_PHOT_ONEBEAM_PROCATG) ||
189  !strcmp(pipecatg, VISIR_IMG_PHOT_COMBINED_PROCATG)) {
190  phot = 1;
191  }
192  if (!strcmp(inpcatg, VISIR_ACQ_CNJ)) {
193  if (phot) {
194  return "ACQ_IMG_PHOT_COMBINED";
195  }
196  else {
197  return "ACQ_IMG_OBJ_COMBINED";
198  }
199  }
200  else if (!strcmp(inpcatg, VISIR_IMG_CAL_PHOT_BURST)) {
201  return VISIR_IMG_PHOT_COMBINED_PROCATG"_BURST";
202  }
203  else if (!strcmp(inpcatg, VISIR_IMG_CAL_OBJ_BURST) ||
204  !strcmp(inpcatg, VISIR_IMG_COMBINE_CN_BURST) ||
205  !strcmp(inpcatg, VISIR_IMG_COMBINE_CNJ_BURST)) {
206  return VISIR_IMG_OBJ_COMBINED_PROCATG"_BURST";
207  }
208  return pipecatg;
209 }
210 
211 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 cpl_error_code visir_dfs_check_framelist_tag(const irplib_framelist * self)
219 {
220 
221  if (cpl_error_get_code()) return cpl_error_get_code();
222 
223  cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
224 
225  return irplib_dfs_check_framelist_tag(self, visir_dfs_find_tag_from_dpr);
226 
227 }
228 
231 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 static const char * visir_dfs_find_tag_from_dpr(const char * catg,
242  const char * type,
243  const char * tech)
244 {
245  const char * docatg = NULL;
246 
247 
248  if (cpl_error_get_code()) return NULL;
249 
250  cpl_ensure(catg != NULL, CPL_ERROR_NULL_INPUT, NULL);
251  cpl_ensure(type != NULL, CPL_ERROR_NULL_INPUT, NULL);
252  cpl_ensure(tech != NULL, CPL_ERROR_NULL_INPUT, NULL);
253 
254 #include "visir_dfs_dpr.h"
255 
256  return docatg;
257 
258 }
259 
260 
cpl_error_code visir_dfs_check_framelist_tag(const irplib_framelist *self)
Check the tags in a frameset (group raw only)
Definition: visir_dfs.c:218
cpl_error_code irplib_dfs_check_framelist_tag(const irplib_framelist *self, const char *(*pfind)(const char *, const char *, const char *))
Check the tags in a frameset (group raw only)
Definition: irplib_pfits.c:225
int visir_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
Definition: visir_dfs.c:72