VIRCAM Pipeline  1.3.3
vircam_dfs.c
1 /* $Id: vircam_dfs.c,v 1.43 2013-10-15 16:32:50 jim Exp $
2  *
3  * This file is part of the VIRCAM Pipeline
4  * Copyright (C) 2005 Cambridge Astronomy Survey Unit
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: jim $
23  * $Date: 2013-10-15 16:32:50 $
24  * $Revision: 1.43 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 
29 /* Includes */
30 
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
34 
35 #include <string.h>
36 #include <cpl.h>
37 
38 #include "vircam_dfs.h"
39 #include "vircam_utils.h"
40 
41 #define PACKSZ 1024
42 #define DELEXTN "^(ESO.INS |ESO.OBS |ESO.TEL |INSTRUME|PIPEFILE|ORIGIN" \
43  "|TELESCOP|OBJECT|RA|DEC|EPOCH|EQUINOX|DATAMD5|RADECSYS" \
44  "|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER).*$"
45 
46 #define REGFIX "^(ORIGIN|TELESCOP|INSTRUME|OBJECT|RA|DEC|EPOCH|EQUINOX" \
47  "|RADECSYS|DATE-OBS|MJD-OBS|UTC|LST|PI-COI|OBSERVER)$"
48 
63 /*---------------------------------------------------------------------------*/
85 /*---------------------------------------------------------------------------*/
86 
87 extern int vircam_dfs_set_groups(cpl_frameset *set) {
88  cpl_frame *cur_frame;
89  const char *tag;
90  const char *fctid = "vircam_dfs_set_groups";
91  int nframes,i;
92 
93  /* Check entries */
94 
95  if (set == NULL)
96  return(VIR_FATAL);
97 
98  /* Initialize */
99 
100  nframes = cpl_frameset_get_size(set);
101 
102  /* Loop on frames */
103 
104  for (i = 0; i < nframes; i++) {
105  cur_frame = cpl_frameset_get_frame(set,i);
106  tag = cpl_frame_get_tag(cur_frame);
107 
108  /* RAW frames */
109 
110  if (!strcmp(tag,VIRCAM_CROSSTALK_RAW) ||
111  !strcmp(tag,VIRCAM_DARK_RAW) ||
112  !strcmp(tag,VIRCAM_DARKCUR_RAW) ||
113  !strcmp(tag,VIRCAM_NOISE_FLAT_RAW) ||
114  !strcmp(tag,VIRCAM_NOISE_DARK_RAW) ||
115  !strcmp(tag,VIRCAM_DOME_RAW) ||
116  !strcmp(tag,VIRCAM_SCI_OBJECT_RAW) ||
117  !strcmp(tag,VIRCAM_SCI_OBJECT_EXT_RAW) ||
118  !strcmp(tag,VIRCAM_OFFSET_SKY_RAW) ||
119  !strcmp(tag,VIRCAM_TEST_SCIENCE_RAW) ||
120  !strcmp(tag,VIRCAM_LIN_DOME_RAW) ||
121  !strcmp(tag,VIRCAM_LIN_DOME_CHECK) ||
122  !strcmp(tag,VIRCAM_LIN_DARK_RAW) ||
123  !strcmp(tag,VIRCAM_LIN_DARK_CHECK) ||
124  !strcmp(tag,VIRCAM_ILLUM_RAW) ||
125  !strcmp(tag,VIRCAM_PERSIST_OBJ_RAW) ||
126  !strcmp(tag,VIRCAM_PERSIST_DARK_RAW) ||
127  !strcmp(tag,VIRCAM_RESET_RAW) ||
128  !strcmp(tag,VIRCAM_STD_OBJECT_RAW) ||
129  !strcmp(tag,VIRCAM_TWI_RAW))
130  cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_RAW);
131 
132  /* CALIB frames */
133 
134  else if (!strcmp(tag,VIRCAM_CAL_RESET) ||
135  !strcmp(tag,VIRCAM_CAL_DARK) ||
136  !strcmp(tag,VIRCAM_CAL_DOME_FLAT) ||
137  !strcmp(tag,VIRCAM_CAL_TWILIGHT_FLAT) ||
138  !strcmp(tag,VIRCAM_CAL_CONF) ||
139  !strcmp(tag,VIRCAM_CAL_BPM) ||
140  !strcmp(tag,VIRCAM_CAL_FRINGE) ||
141  !strcmp(tag,VIRCAM_CAL_CHANTAB) ||
142  !strcmp(tag,VIRCAM_CAL_READGAINFILE) ||
143  !strcmp(tag,VIRCAM_CAL_CHANTAB_INIT) ||
144  !strcmp(tag,VIRCAM_CAL_PHOTTAB) ||
145  !strcmp(tag,VIRCAM_CAL_STDTAB) ||
146  !strcmp(tag,VIRCAM_CAL_OBJCAT) ||
147  !strcmp(tag,VIRCAM_CAL_MSTDTAB) ||
148  !strcmp(tag,VIRCAM_CAL_2MASS) ||
149  !strcmp(tag,VIRCAM_CAL_SCHL_N) ||
150  !strcmp(tag,VIRCAM_CAL_SCHL_S) ||
151  !strcmp(tag,VIRCAM_CAL_REFCAT) ||
152  !strcmp(tag,VIRCAM_CAL_SKY) ||
153  !strcmp(tag,VIRCAM_CAL_OBJMASK) ||
154  !strcmp(tag,VIRCAM_REF_RESET) ||
155  !strcmp(tag,VIRCAM_REF_DARK) ||
156  !strcmp(tag,VIRCAM_REF_DOME_FLAT) ||
157  !strcmp(tag,VIRCAM_REF_TWILIGHT_FLAT))
158  cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_CALIB);
159  else if (!strcmp(tag,VIRCAM_PRO_OBJCAT_SCI) ||
160  !strcmp(tag,VIRCAM_PRO_CONF_SCI) ||
161  !strcmp(tag,VIRCAM_PRO_JITTERED_SCI))
162  cpl_frame_set_group(cur_frame,CPL_FRAME_GROUP_PRODUCT);
163  else
164  cpl_msg_info(fctid,"No such tag as %s in frame %s",tag,
165  cpl_frame_get_filename(cur_frame));
166  }
167  return(VIR_OK);
168 }
169 
170 /*---------------------------------------------------------------------------*/
201 /*---------------------------------------------------------------------------*/
202 
203 extern void vircam_dfs_set_product_primary_header(cpl_propertylist *plist,
204  cpl_frame *frame,
205  cpl_frameset *frameset,
206  cpl_parameterlist *parlist,
207  char *recipeid,
208  const char *dict,
209  cpl_frame *inherit,
210  int synch) {
211  const char *fctid="vircam_dfs_set_product_primary_header";
212  char package[PACKSZ];
213  cpl_propertylist *pcopy;
214 
215  /* Get the package name and version */
216 
217  (void)snprintf(package,PACKSZ,"%s/%s",PACKAGE,PACKAGE_VERSION);
218 
219  /* Make a copy of the input propertylist so that we can restore the
220  time and position dependent headers back to the way they were before
221  cpl_dfs_setup_product_header worked on it. */
222 
223  pcopy = cpl_propertylist_duplicate(plist);
224 
225  /* Add the data-flow keywords */
226 
227  if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
228  package,dict,inherit) != CPL_ERROR_NONE) {
229  cpl_msg_warning(fctid,
230  "Problem with the product primary DFS compliance -- %s",
231  cpl_error_get_message());
232  cpl_error_reset();
233  }
234 
235  /* Now fix the time/position information back to the way it was */
236 
237  if (synch)
238  cpl_propertylist_copy_property_regexp(plist,
239  (const cpl_propertylist *)pcopy,
240  REGFIX,0);
241  cpl_propertylist_delete(pcopy);
242 }
243 
244 /*---------------------------------------------------------------------------*/
271 /*---------------------------------------------------------------------------*/
272 
273 extern void vircam_dfs_set_product_exten_header(cpl_propertylist *plist,
274  cpl_frame *frame,
275  cpl_frameset *frameset,
276  cpl_parameterlist *parlist,
277  char *recipeid,
278  const char *dict,
279  cpl_frame *inherit) {
280  const char *fctid="vircam_dfs_set_product_exten_header";
281  char package[PACKSZ];
282 
283  /* Get the package name and version */
284 
285  (void)snprintf(package,PACKSZ,"%s/%s",PACKAGE,PACKAGE_VERSION);
286 
287  /* Add the data-flow keywords */
288 
289  if (cpl_dfs_setup_product_header(plist,frame,frameset,parlist,recipeid,
290  package,dict,inherit) != CPL_ERROR_NONE) {
291  cpl_msg_warning(fctid,
292  "Problem with the product extn DFS compliance -- %s",
293  cpl_error_get_message());
294  cpl_error_reset();
295  }
296 
297  /* Remove the stuff that isn't supposed to be here */
298 
299  cpl_propertylist_erase_regexp(plist,DELEXTN,0);
300 
301 }
302 
305 /*
306 
307 $Log: not supported by cvs2svn $
308 Revision 1.42 2010/09/10 11:22:44 jim
309 Added VIRCAM_CAL_SKY entry
310 
311 Revision 1.41 2010/01/31 18:59:54 jim
312 Removed references to master sky
313 
314 Revision 1.40 2009/09/22 12:27:01 jim
315 Added entry for raw offset sky exposures
316 
317 Revision 1.39 2009/09/09 09:44:54 jim
318 Modified in final ditch effort to get headers right...
319 
320 Revision 1.38 2009/03/02 20:00:10 jim
321 Uses new version of cpl_dfs_set_product_header
322 
323 Revision 1.37 2008/11/02 14:33:11 jim
324 Modified vircam_dfs_set_product_primary_header so that critical positional
325 and timing data are not overwritten
326 
327 Revision 1.36 2008/10/21 08:37:15 jim
328 Added VIRCAM_PRO_SKYMAP_SCI, VIRCAM_CAL_SKY and VIRCAM_CAL_SKY_MASK
329 
330 Revision 1.35 2008/10/07 11:21:56 jim
331 Fixed regexp again...
332 
333 Revision 1.34 2008/09/30 11:34:14 jim
334 modified definition of DELEXTN
335 
336 Revision 1.33 2008/09/29 11:20:17 jim
337 Modified to keep PRO keywords in the primary header. Extended the list of
338 items to be removed from the extension header.
339 
340 Revision 1.32 2007/11/20 09:37:56 jim
341 Added VIRCAM_LIN_DOME_CHECK and VIRCAM_LIN_DARK_CHECK
342 
343 Revision 1.31 2007/10/19 06:55:06 jim
344 Modifications made to use new method for directing the recipes to the
345 standard catalogues using the sof
346 
347 Revision 1.30 2007/08/23 09:00:59 jim
348 Removed annoying error messages in the product header routines which used
349 to tell you if it couldn't find stuff to erase.
350 
351 Revision 1.29 2007/04/23 12:50:22 jim
352 Added VIRCAM_TEST_SCIENCE_RAW
353 
354 Revision 1.28 2007/04/04 10:34:42 jim
355 Complete rewrite of the dfs tags
356 
357 Revision 1.27 2007/03/23 10:53:22 jim
358 Fixed little documentation errors
359 
360 Revision 1.26 2007/03/01 12:42:41 jim
361 Modified slightly after code checking
362 
363 Revision 1.25 2007/02/15 11:53:45 jim
364 Added type CHANNEL_TABLE_INIT
365 
366 Revision 1.24 2007/02/05 13:54:00 jim
367 Added REFERENCE tags
368 
369 Revision 1.23 2007/01/17 23:53:43 jim
370 Modified to remove INS, OBS and TEL structures from extension headers
371 
372 Revision 1.22 2006/12/06 12:58:57 jim
373 Added MASTER_FRINGE
374 
375 Revision 1.21 2006/11/28 20:57:05 jim
376 Added ILLUM types
377 
378 Revision 1.20 2006/10/05 09:22:59 jim
379 Small modifications to a couple of cpl calls to bring them into line with
380 cpl v3.0
381 
382 Revision 1.19 2006/07/04 09:19:04 jim
383 replaced all sprintf statements with snprintf
384 
385 Revision 1.18 2006/06/14 14:13:58 jim
386 fixed minor doc problem
387 
388 Revision 1.17 2006/06/13 21:26:02 jim
389 Added VIRCAM_CALIB_READNOISE_FILE
390 
391 Revision 1.16 2006/05/24 13:33:56 jim
392 Added VIRCAM_PHOTTAB
393 
394 Revision 1.15 2006/05/18 12:32:23 jim
395 Added channel table and object catalogue to calib list
396 
397 Revision 1.14 2006/04/27 09:46:27 jim
398 Modified to conform to new dictionary
399 
400 Revision 1.13 2006/04/26 09:39:35 jim
401 Fixes the pipeline id to the header
402 
403 Revision 1.12 2006/04/25 13:47:59 jim
404 Modified calls to vircam_dfs_set_product_*_header routines
405 
406 Revision 1.11 2006/04/20 11:19:22 jim
407 *** empty log message ***
408 
409 Revision 1.10 2006/03/22 13:14:24 jim
410 Sorted data categories
411 
412 Revision 1.9 2006/02/27 13:53:32 jim
413 Added new categories to vircam_dfs_set_groups
414 
415 Revision 1.8 2006/02/18 11:45:01 jim
416 Added vircam_dfs_set_product_primary_header and
417 vircam_dfs_set_product_exten_header
418 
419 Revision 1.7 2006/01/23 10:30:49 jim
420 Mainly documentation mods
421 
422 Revision 1.6 2005/12/14 22:17:33 jim
423 Updated docs
424 
425 Revision 1.5 2005/11/29 14:56:36 jim
426 Added a few new categories
427 
428 Revision 1.4 2005/11/25 09:56:14 jim
429 Tidied up some more documentation
430 
431 Revision 1.3 2005/11/03 13:28:48 jim
432 All sorts of changes to tighten up error handling
433 
434 Revision 1.2 2005/09/20 15:07:46 jim
435 Fixed a few bugs and added a few things
436 
437 Revision 1.1.1.1 2005/08/05 08:29:09 jim
438 Initial import
439 
440 
441 */