sinfo_tpl_dfs.c

00001 /* $Id: sinfo_tpl_dfs.c,v 1.13 2012/03/03 10:17:31 amodigli Exp $
00002  *
00003  * This file is part of the SINFONI Pipeline
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: amodigli $
00023  * $Date: 2012/03/03 10:17:31 $
00024  * $Revision: 1.13 $
00025  * $Name: HEAD $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                    Includes
00034  -----------------------------------------------------------------------------*/
00035 
00036 #include <string.h>
00037 #include <math.h>
00038 
00039 #include <cpl.h>
00040 #include "sinfo_utilities.h"
00041 
00042 #include "sinfo_tpl_dfs.h"
00043 #include "sinfo_pro_types.h"
00044 #include "sinfo_raw_types.h"
00045 #include "sinfo_ref_types.h"
00046 #include "sinfo_error.h"
00047 #include "sinfo_msg.h"
00048 
00049 
00051 /*----------------------------------------------------------------------------*/
00057 /*----------------------------------------------------------------------------*/
00058 
00059 
00060 
00061 /*----------------------------------------------------------------------------*/
00071 /*----------------------------------------------------------------------------*/
00072 static int
00073 sinfo_dfs_files_dont_exist(cpl_frameset *frameset)
00074 {
00075     const char *func = "dfs_files_dont_exist";
00076     cpl_frame  *frame;
00077 
00078 
00079     if (frameset == NULL) {
00080         cpl_error_set(func, CPL_ERROR_NULL_INPUT);
00081         return 1;
00082     }
00083 
00084     if (cpl_frameset_is_empty(frameset)) {
00085         return 0;
00086     }
00087 
00088     frame = cpl_frameset_get_first(frameset);
00089 
00090     while (frame) {
00091         if (access(cpl_frame_get_filename(frame), F_OK)) {
00092             cpl_msg_error(func, "File %s (%s) was not found",
00093                           cpl_frame_get_filename(frame),
00094                           cpl_frame_get_tag(frame));
00095             cpl_error_set(func, CPL_ERROR_FILE_NOT_FOUND);
00096         }
00097 
00098         frame = cpl_frameset_get_next(frameset);
00099     }
00100 
00101     if (cpl_error_get_code())
00102         return 1;
00103 
00104     return 0;
00105 }
00106 
00107 /*----------------------------------------------------------------------------*/
00113 /*----------------------------------------------------------------------------*/
00114 int sinfo_dfs_set_groups(cpl_frameset * set)
00115 {
00116     cpl_frame   *   cur_frame=NULL ;
00117     const char  *   tag=NULL ;
00118     int             nframes=0 ;
00119     int             i=0 ;
00120 
00121     sinfo_skip_if (cpl_error_get_code());
00122 
00123     /* Check entries */
00124     if (set == NULL) return -1 ;
00125 
00126     /* Initialize */
00127     nframes = cpl_frameset_get_size(set) ;
00128 
00129     /* Loop on frames */
00130     for (i=0 ; i<nframes ; i++) {
00131         cur_frame = cpl_frameset_get_frame(set, i) ;
00132         tag = cpl_frame_get_tag(cur_frame) ;
00133         if (cpl_error_get_code()) break;
00134         if (tag == NULL) sinfo_msg_warning( "Frame %d has no tag", i);
00135         /* RAW frames */
00136         else if (!strcmp(tag, RAW_LINEARITY_LAMP) ||
00137              !strcmp(tag, RAW_ON) ||
00138              !strcmp(tag, RAW_OFF) ||
00139              !strcmp(tag, RAW_DARK) ||
00140                  !strcmp(tag, RAW_FIBRE_NS) ||
00141                  !strcmp(tag, RAW_FIBRE_PSF) ||
00142                  !strcmp(tag, RAW_FIBRE_DARK) ||
00143                  !strcmp(tag, RAW_FLAT_NS) ||
00144                  !strcmp(tag, RAW_WAVE_NS) ||
00145                  !strcmp(tag, RAW_FLAT_LAMP) ||
00146                  !strcmp(tag, RAW_WAVE_LAMP) ||
00147                  !strcmp(tag, RAW_PSF_CALIBRATOR) ||
00148              !strcmp(tag, RAW_SKY_PSF_CALIBRATOR) ||
00149              !strcmp(tag, RAW_STD) ||
00150              !strcmp(tag, RAW_SKY) ||
00151                  !strcmp(tag, RAW_SKY_STD) ||
00152              !strcmp(tag, RAW_OBJECT_NODDING) ||
00153              !strcmp(tag, RAW_SKY_NODDING) ||
00154                  !strcmp(tag, RAW_OBJECT_JITTER) ||
00155                  !strcmp(tag, RAW_SKY_JITTER) ||
00156                  !strcmp(tag, RAW_PUPIL_LAMP) ||
00157                  !strcmp(tag, RAW_IMAGE_PRE_OBJECT) ||
00158                  !strcmp(tag, RAW_IMAGE_PRE_SKY) ||
00159                  !strcmp(tag, RAW_OBJECT_SKYSPIDER))
00160             cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW) ;
00161         /* CALIB frames */
00162         else if (!strcmp(tag, PRO_BP_MAP_HP)  ||
00163          !strcmp(tag,SINFO_UTL_STDSTARS_RAW) ||
00164          !strcmp(tag,SINFO_CALIB_STDSTARS) ||
00165          !strcmp(tag,SINFO_CALIB_SED) ||
00166          !strcmp(tag,PRO_BP_MAP_NL) ||
00167          !strcmp(tag,PRO_BP_MAP_NO) ||
00168          !strcmp(tag,PRO_BP_MAP_DI) ||
00169          !strcmp(tag,PRO_BP_MAP_NL) ||
00170          !strcmp(tag,PRO_BP_MAP_NO) ||
00171          !strcmp(tag,PRO_BP_MAP) ||
00172          !strcmp(tag,PRO_ILL_COR) ||
00173          !strcmp(tag,PRO_MASTER_BP_MAP) ||
00174          !strcmp(tag,PRO_MASTER_DARK) ||
00175                  !strcmp(tag,PRO_DISTORTION) ||
00176          !strcmp(tag,PRO_SLITLETS_DISTANCE) ||
00177          !strcmp(tag,PRO_MASTER_FLAT_LAMP) ||
00178          !strcmp(tag,PRO_SLIT_POS) ||
00179          !strcmp(tag,PRO_SLIT_POS_GUESS) ||
00180          !strcmp(tag,PRO_FIRST_COL) ||
00181          !strcmp(tag,PRO_WAVE_MAP ) ||
00182          !strcmp(tag,REF_LINE_ARC ) ||
00183          !strcmp(tag,DRS_SETUP_WAVE ) ||
00184          !strcmp(tag,EXTCOEFF_TABLE ) ||
00185          !strcmp(tag,FLUX_STD_TABLE ) ||
00186          !strcmp(tag,FLUX_STD_CATALOG ) ||
00187          !strcmp(tag,PRO_IMA ) ||
00188          !strcmp(tag,PRO_CUBE ) ||
00189          !strcmp(tag,REF_BP_MAP ) ||
00190          !strcmp(tag,PRO_SKY_DUMMY ) ||
00191          !strcmp(tag,PRO_REF_ATM_REF_CORR) ||
00192          !strcmp(tag,PRO_SPECTRUM))
00193             cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB) ;
00194         else if (!strcmp(tag, PRO_OBS_OBJ)  ||
00195          !strcmp(tag,PRO_MED_OBS_OBJ) ||
00196          !strcmp(tag,PRO_OBS_STD) ||
00197          !strcmp(tag,PRO_MED_OBS_STD) ||
00198          !strcmp(tag,PRO_OBS_PSF) ||
00199          !strcmp(tag,PRO_MED_OBS_PSF) ||
00200          !strcmp(tag,PRO_COADD_OBJ) ||
00201          !strcmp(tag,PRO_COADD_STD) ||
00202          !strcmp(tag,PRO_COADD_PSF) ||
00203          !strcmp(tag,PRO_COADD_PUPIL) ||
00204          !strcmp(tag,PRO_MED_COADD_OBJ) ||
00205          !strcmp(tag,PRO_MED_COADD_STD) ||
00206          !strcmp(tag,PRO_MED_COADD_PSF) ||
00207          !strcmp(tag,PRO_MED_COADD_PUPIL) ||
00208          !strcmp(tag,PRO_MASK_COADD_OBJ) ||
00209          !strcmp(tag,PRO_MASK_COADD_STD) ||
00210          !strcmp(tag,PRO_MASK_COADD_PSF) ||
00211          !strcmp(tag,PRO_MASK_COADD_PUPIL) ||
00212          !strcmp(tag,PRO_PSF_CALIBRATOR_STACKED) ||
00213          !strcmp(tag,PRO_SKY_PSF_CALIBRATOR_STACKED) ||
00214          !strcmp(tag,PRO_AO_PERFORMANCE) ||
00215          !strcmp(tag,PRO_ENC_ENERGY) ||
00216          !strcmp(tag,PRO_PSF) ||
00217          !strcmp(tag,PRO_STD_STAR_SPECTRA) ||
00218          !strcmp(tag,PRO_STD_STAR_SPECTRUM) ||
00219          !strcmp(tag,PRO_MFLAT_CUBE) ||
00220          !strcmp(tag,PRO_MFLAT_AVG) ||
00221          !strcmp(tag,PRO_MFLAT_MED) ||
00222          !strcmp(tag,PRO_STACK_MFLAT_DIST) ||
00223          !strcmp(tag,PRO_WAVE_LAMP_STACKED ) ||
00224          !strcmp(tag,PRO_FIBRE_NS_STACKED_OFF) ||
00225          !strcmp(tag,PRO_FIBRE_NS_STACKED_ON) ||
00226          !strcmp(tag,PRO_FIBRE_NS_STACKED) ||
00227          !strcmp(tag,PRO_SLITLETS_POS_PREDIST) ||
00228          !strcmp(tag,PRO_OBS_SKY) ||
00229          !strcmp(tag,PRO_SKY_MED) ||
00230          !strcmp(tag,PRO_FIBRE_NS_STACKED_DIST))
00231             cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_PRODUCT) ;
00232         else sinfo_msg_warning( "Frame %d has unknown tag: %s", i, tag);
00233     }
00234     ck0_nomsg(sinfo_dfs_files_dont_exist(set));
00235     sinfo_skip_if (i != nframes);
00236 
00237     sinfo_end_skip;
00238 
00239     if (cpl_error_get_code())
00240         sinfo_msg_error( "Could not identify RAW and CALIB frames (in "
00241                       "frame set of size %d)", nframes);
00242 
00243 
00244     return cpl_error_get_code();
00245 }
00246 

Generated on 3 Mar 2013 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1