sinfo_psf_ini_by_cpl.c

00001 /*
00002  * This file is part of the ESO SINFONI Pipeline
00003  * Copyright (C) 2004,2005 European Southern Observatory
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00018  */
00019 /*----------------------------------------------------------------------------
00020    
00021    File name    :   sinfo_psf_ini_by_cpl.c
00022    Author       :   Andrea Modigliani
00023    Created on   :   May 20, 2004
00024    Description  :   cpl input for sinfo_psf step for SPIFFI
00025 
00026 
00027  ---------------------------------------------------------------------------*/
00028 
00029 
00030 
00031 #ifdef HAVE_CONFIG_H
00032 #  include <config.h>
00033 #endif
00034 /*---------------------------------------------------------------------------
00035                                 Includes
00036  ---------------------------------------------------------------------------*/
00037 
00038 #include "sinfo_psf_ini_by_cpl.h"
00039 #include "sinfo_hidden.h"
00040 
00041 
00042 /*---------------------------------------------------------------------------
00043                     Functions private to this module
00044  ---------------------------------------------------------------------------*/
00045 static void      parse_section_frames(psf_config *, 
00046                    cpl_frameset* sof,cpl_frameset** stk,int* status);
00047 static void     parse_section_reconstruction(psf_config *);
00048 
00049 
00058 /*-------------------------------------------------------------------------*/
00069 /*--------------------------------------------------------------------------*/
00070 
00071 psf_config * sinfo_parse_cpl_input_psf(cpl_frameset* sof, 
00072                  cpl_frameset** stk)
00073 {
00074         psf_config  *       cfg =NULL;
00075         int status=0;
00076         /*
00077          * Perform sanity checks, fill up the structure with what was
00078          * found in the ini file
00079          */
00080 
00081         cfg = sinfo_psf_cfg_create();
00082         parse_section_reconstruction   (cfg);
00083          parse_section_frames       (cfg, sof,stk,&status);
00084         if (status > 0) {
00085                 sinfo_msg_error("parsing cpl input");
00086                 sinfo_psf_cfg_destroy(cfg);
00087                 cfg = NULL ;
00088                 return NULL ;
00089         }
00090         return cfg ;
00091 }
00092 
00093 static void
00094 parse_section_frames(psf_config * cfg, 
00095              cpl_frameset* sof,
00096                      cpl_frameset** stk,
00097                      int* status)
00098 {
00099    cpl_frame* frame   = NULL;
00100 
00101    int                 npsf=0;
00102    int nraw=0;
00103    char spat_res[FILE_NAME_SZ];
00104    char lamp_status[FILE_NAME_SZ];
00105    char band[FILE_NAME_SZ];
00106    int ins_set=0;
00107 
00108      sinfo_contains_frames_type(sof,stk,PRO_PSF_CALIBRATOR_STACKED);
00109      npsf = cpl_frameset_get_size(*stk);
00110      if (npsf < 1) {
00111        sinfo_contains_frames_type(sof,stk,PRO_STD_NODDING_STACKED);
00112        npsf = cpl_frameset_get_size(*stk);
00113      }
00114 
00115      npsf = cpl_frameset_get_size(*stk);
00116      if (npsf < 1) {
00117        sinfo_contains_frames_type(sof,stk,PRO_OBJECT_NODDING_STACKED);
00118        npsf = cpl_frameset_get_size(*stk);
00119      }
00120 
00121 
00122      npsf = cpl_frameset_get_size(*stk);
00123      if (npsf < 1) {
00124        sinfo_contains_frames_type(sof,stk,PRO_PUPIL_LAMP_STACKED);
00125        npsf = cpl_frameset_get_size(*stk);
00126      }
00127 
00128      npsf = cpl_frameset_get_size(*stk);
00129      if (npsf < 1) {
00130          sinfo_msg_error("Cannot find input stacked frames") ;
00131          (*status)++;
00132          return;
00133      }
00134 
00135     if(NULL != cpl_frameset_find(sof,PRO_COADD_PSF)) {
00136       frame = cpl_frameset_find(sof,PRO_COADD_PSF);
00137       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00138     } else if(NULL != cpl_frameset_find(sof,PRO_OBS_PSF)) {
00139       frame = cpl_frameset_find(sof,PRO_OBS_PSF);
00140       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00141     } else if(NULL != cpl_frameset_find(sof,PRO_COADD_STD)) {
00142       frame = cpl_frameset_find(sof,PRO_COADD_STD);
00143       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00144     } else if(NULL != cpl_frameset_find(sof,PRO_OBS_STD)) {
00145       frame = cpl_frameset_find(sof,PRO_OBS_STD);
00146       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00147     } else if(NULL != cpl_frameset_find(sof,PRO_COADD_OBJ)) {
00148       frame = cpl_frameset_find(sof,PRO_COADD_OBJ);
00149       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00150     } else if(NULL != cpl_frameset_find(sof,PRO_OBS_OBJ)) {
00151       frame = cpl_frameset_find(sof,PRO_OBS_OBJ);
00152       strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
00153     } else {
00154       sinfo_msg_error("Frame %s or %s or %s or %s or %s or %s not found!", 
00155        PRO_COADD_PSF,PRO_OBS_PSF,
00156        PRO_COADD_STD,PRO_OBS_STD,
00157        PRO_COADD_OBJ,PRO_OBS_OBJ);
00158       (*status)++;
00159       return;
00160     }
00161 
00162    strcpy(cfg -> outName, PSF_OUT_FILENAME);
00163    nraw    = cpl_frameset_get_size(*stk);
00164    frame = cpl_frameset_get_frame(*stk,0);
00165 
00166    sinfo_get_spatial_res(frame,spat_res);
00167    switch(sinfo_frame_is_on(frame))
00168      {
00169 
00170     case 0: 
00171       strcpy(lamp_status,"on");
00172       break;
00173     case 1: 
00174       strcpy(lamp_status,"off");
00175       break;
00176     case -1:
00177       strcpy(lamp_status,"undefined");
00178       break;
00179     default: 
00180       strcpy(lamp_status,"undefined");
00181       break;
00182 
00183      }
00184 
00185    sinfo_get_band(frame,band);
00186    sinfo_msg("Spatial resolution: %s lamp status: %s band: %s \n",
00187                      spat_res,    lamp_status,    band);
00188 
00189    sinfo_get_ins_set(band,&ins_set);
00190 
00191    return;
00192 
00193 }
00194 
00195 static void     
00196 parse_section_reconstruction(psf_config * cfg)
00197 {
00198    cfg -> nslits = NSLITLETS;
00199    return;
00200 }
00201 
00202 void
00203 sinfo_free_psf(psf_config ** cfg) {
00204    sinfo_psf_cfg_destroy (*cfg);
00205    *cfg=NULL;
00206   return;
00207 }

Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1