sinfo_dark_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_dark_ini_by_cpl.c
00022    Author       :   Andrea Modigliani
00023    Created on   :   May 18, 2004
00024    Description  :   sinfo_dark cpl input file handling for SPIFFI
00025  ---------------------------------------------------------------------------*/
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 /*---------------------------------------------------------------------------
00030                                 Includes
00031  ---------------------------------------------------------------------------*/
00032 #include "sinfo_dark_ini_by_cpl.h"
00033 #include "sinfo_raw_types.h"
00034 #include "sinfo_pro_types.h"
00035 #include "sinfo_globals.h"
00036 #include "sinfo_hidden.h"
00037 #include "sinfo_functions.h"
00038 /*---------------------------------------------------------------------------
00039                     Functions private to this module
00040  ---------------------------------------------------------------------------*/
00041 static void     
00042 parse_section_frames(dark_config *, cpl_frameset* sof, 
00043                      cpl_frameset** raw, int* status);
00044 static void     
00045 parse_section_cleanmean(dark_config *, cpl_parameterlist* cpl_cfg);
00046 static void     
00047 parse_section_qclog(dark_config * cfg, cpl_parameterlist * cpl_cfg);
00048 
00049 void sinfo_detnoise_free(dark_config * cfg);
00069 dark_config * 
00070 sinfo_parse_cpl_input_dark(cpl_parameterlist * cpl_cfg, 
00071                            cpl_frameset* sof, 
00072                            cpl_frameset** raw)
00073 {
00074  int status=0;
00075 
00076         dark_config   *       cfg ;
00077 
00078         /* Removed check on ini_file */
00079         /* Removed load of ini file */
00080 
00081         cfg = sinfo_dark_cfg_create();
00082 
00083         /*
00084          * Perform sanity checks, fill up the structure with what was
00085          * found in the ini file
00086          */
00087         parse_section_cleanmean    (cfg, cpl_cfg);
00088         parse_section_qclog    (cfg, cpl_cfg); 
00089         parse_section_frames       (cfg, sof, raw, &status);
00090         if (status > 0) {
00091                 sinfo_msg_error("parsing cpl input");
00092                 sinfo_dark_cfg_destroy(cfg);
00093                 cfg = NULL ;
00094                 return NULL ;
00095         }
00096 
00097         return cfg ;
00098 }
00099 
00110 static void     
00111 parse_section_frames(dark_config * cfg,
00112              cpl_frameset * sof,
00113                      cpl_frameset** raw,
00114                      int* status)
00115 {
00116 
00117    int                     i;
00118    int                   nraw=0;
00119    int                   nraw_good=0;
00120    cpl_frame* frame=NULL;
00121 
00122    char spat_res[FILE_NAME_SZ];
00123    char lamp_status[FILE_NAME_SZ];
00124    char band[FILE_NAME_SZ];
00125    int ins_set=0;
00126    sinfo_extract_raw_frames_type(sof,raw,RAW_DARK);
00127 
00128    nraw=cpl_frameset_get_size(*raw);
00129    if (nraw < 1) {
00130       sinfo_msg_error("Too few (%d) raw frames (%s) present in"
00131             "frameset!Aborting...",nraw,RAW_DARK);
00132           (*status)++;
00133           return;
00134    }
00135 
00136 
00137 
00138    /* Removed: get "general:infile" read it, check input sinfo_matrix */
00139    /* Allocate structures to go into the blackboard */
00140    cfg->inFrameList     = cpl_malloc(nraw * sizeof(char*));
00141 
00142 
00143    /* read input frames */
00144    for (i=0 ; i<nraw ; i++) {
00145       frame = cpl_frameset_get_frame(*raw,i);
00146       /* Store file name into framelist */
00147       cfg->inFrameList[i]=cpl_strdup(cpl_frame_get_filename(frame));
00148       nraw_good++;
00149    }
00150 
00151    if(nraw_good<1) {
00152      sinfo_msg_error("no good raw frame in input, something wrong!");
00153      (*status)++;
00154      return;
00155    }
00156    /* Copy relevant information into the blackboard */
00157    cfg->nframes         = nraw ;
00158 
00159    strcpy(cfg -> outName, DARK_OUT_FILENAME);
00160   
00161 
00162    frame = cpl_frameset_get_frame(*raw,0);
00163    sinfo_get_spatial_res(frame,spat_res);
00164  
00165    switch(sinfo_frame_is_on(frame)) 
00166      {
00167    case 0: 
00168       strcpy(lamp_status,"on");
00169       break;
00170     case 1: 
00171       strcpy(lamp_status,"off");
00172       break;
00173     case -1:
00174       strcpy(lamp_status,"undefined");
00175       break;
00176     default: 
00177       strcpy(lamp_status,"undefined");
00178       break;
00179 
00180 
00181      }
00182 
00183    sinfo_get_band(frame,band);
00184    sinfo_msg("spatial resolution: %s lamp status: %s band: %s \n",
00185                      spat_res,    lamp_status,    band);
00186 
00187 
00188    sinfo_get_ins_set(band,&ins_set);
00189    return ;
00190 }
00191 
00200 static void     
00201 parse_section_cleanmean(dark_config * cfg, cpl_parameterlist *   cpl_cfg)
00202 {
00203    cpl_parameter *p;  
00204    
00205    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.low_rejection");
00206    cfg -> lo_reject = cpl_parameter_get_double(p);
00207 
00208    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.high_rejection");
00209    cfg -> hi_reject = cpl_parameter_get_double(p);
00210 
00211 }
00212 
00220 static void     
00221 parse_section_qclog(dark_config * cfg, cpl_parameterlist *   cpl_cfg)
00222 {
00223    cpl_parameter *p;  
00224    
00225    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_xmin");
00226    cfg -> qc_ron_xmin = cpl_parameter_get_int(p);
00227    
00228    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_xmax");
00229    cfg -> qc_ron_xmax = cpl_parameter_get_int(p);
00230 
00231    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_ymin");
00232    cfg -> qc_ron_ymin = cpl_parameter_get_int(p);
00233 
00234    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_ymax");
00235    cfg -> qc_ron_ymax = cpl_parameter_get_int(p);
00236 
00237    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_hsize");
00238    cfg -> qc_ron_hsize = cpl_parameter_get_int(p);
00239    
00240    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_ron_nsamp");
00241    cfg -> qc_ron_nsamp = cpl_parameter_get_int(p);
00242 
00243 
00244 
00245    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_xmin");
00246    cfg -> qc_fpn_xmin = cpl_parameter_get_int(p);
00247    
00248    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_xmax");
00249    cfg -> qc_fpn_xmax = cpl_parameter_get_int(p);
00250 
00251    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_ymin");
00252    cfg -> qc_fpn_ymin = cpl_parameter_get_int(p);
00253 
00254    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_ymax");
00255    cfg -> qc_fpn_ymax = cpl_parameter_get_int(p);
00256 
00257    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_hsize");
00258    cfg -> qc_fpn_hsize = cpl_parameter_get_int(p);
00259    
00260    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.dark.qc_fpn_nsamp");
00261    cfg -> qc_fpn_nsamp = cpl_parameter_get_int(p);
00262 
00263    
00264 }
00265 
00272 void
00273 sinfo_dark_free(dark_config ** cfg)
00274 {  
00275   int i=0;
00276  
00277   if((*cfg) != NULL) {
00278     for(i=0;i<(*cfg)->nframes;i++) {
00279       if((*cfg)->inFrameList[i] != NULL) {
00280     cpl_free((*cfg)->inFrameList[i]);
00281     (*cfg)->inFrameList[i]=NULL;
00282       }
00283     }
00284     cpl_free((*cfg)->inFrameList);
00285     (*cfg)->inFrameList=NULL;
00286     sinfo_dark_cfg_destroy((*cfg));
00287     *cfg = NULL;
00288   }
00289   return;
00290 
00291 }

Generated on Wed Jan 17 08:33:42 2007 for SINFONI Pipeline Reference Manual by  doxygen 1.4.4