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

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