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

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