sinfo_detnoise_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_detnoise_ini.c
00022    Author       :   Andrea Modiglini
00023    Created on   :   May 17, 2004
00024    Description  :   produce and read an .ini file for the search of static
00025                     bad pixels
00026  ---------------------------------------------------------------------------*/
00027 #ifdef HAVE_CONFIG_H
00028 #  include <config.h>
00029 #endif
00030 /*---------------------------------------------------------------------------
00031                                 Includes
00032  ---------------------------------------------------------------------------*/
00033 #include <string.h>
00034 #include "sinfo_detnoise_ini_by_cpl.h"
00035 #include "sinfo_raw_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 
00043 static void  
00044 parse_section_frames(detnoise_config * cfg, 
00045                      cpl_frameset* sof, 
00046                      cpl_frameset** raw, 
00047                      int* status);
00048 static void  
00049 parse_section_badsearch(detnoise_config * cfg, cpl_parameterlist* cpl_cfg);
00050 
00058 /****************************************************************************/
00070 detnoise_config * 
00071 sinfo_parse_cpl_input_detnoise(cpl_parameterlist * cpl_cfg, 
00072                                cpl_frameset* sof, 
00073                                cpl_frameset** raw)
00074 {
00075 
00076   detnoise_config    *    cfg ;
00077   int status=0;
00078   /* Removed check on ini_file */
00079   /* Removed load of ini file */
00080 
00081   cfg = sinfo_detnoise_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_badsearch(cfg, cpl_cfg);
00088   parse_section_frames(cfg, sof, raw, &status);
00089 
00090          if (status > 0) {
00091                 sinfo_msg_error("parsing cpl input");
00092                 sinfo_detnoise_free(cfg);
00093                 cfg = NULL ;
00094                 return NULL ;
00095         }
00096   return cfg ;
00097 }
00098 
00099 
00110 static void     
00111 parse_section_frames(detnoise_config * cfg,
00112              cpl_frameset * sof,
00113                      cpl_frameset** raw,
00114                      int* status)
00115 {
00116    int                     i;
00117 
00118    int  nraw = 0;
00119    cpl_frame* frame=NULL;
00120 
00121     char spat_res[FILE_NAME_SZ];
00122    char lamp_status[FILE_NAME_SZ];
00123    char band[FILE_NAME_SZ];
00124    int ins_set=0;
00125 
00126 
00127 
00128    sinfo_extract_raw_frames_type2(sof,raw,RAW_DARK);
00129 
00130    nraw = cpl_frameset_get_size(*raw);
00131    if (nraw < 1) {
00132       sinfo_msg_error("Too few (%d) raw frames (%s) present in"
00133             "frameset!Aborting...",nraw,RAW_DARK);
00134       (*status)++;
00135           return;
00136    }
00137  
00138    /* get "general:infile" read it, check input sinfo_matrix */
00139    /* Allocate structures to go into the blackboard */
00140    /* Copy relevant information into the blackboard */
00141    cfg->nframes       = nraw ;
00142    cfg->framelist  =  cpl_malloc(nraw*sizeof(char*)); 
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->framelist[i]=cpl_strdup(cpl_frame_get_filename(frame));
00148    }
00149  
00150    strcpy(cfg -> outName, BP_NOISE_OUT_FILENAME);
00151 
00152    frame = cpl_frameset_get_frame(*raw,0);
00153    sinfo_get_spatial_res(frame,spat_res);
00154    switch(sinfo_frame_is_on(frame)) 
00155      {
00156    case 0: 
00157       strcpy(lamp_status,"on");
00158       break;
00159     case 1: 
00160       strcpy(lamp_status,"off");
00161       break;
00162     case -1:
00163       strcpy(lamp_status,"undefined");
00164       break;
00165     default: 
00166       strcpy(lamp_status,"undefined");
00167       break;
00168      }
00169 
00170    sinfo_get_band(frame,band);
00171    sinfo_msg("Spatial resolution: %s lamp status: %s band: %s \n",
00172                      spat_res,    lamp_status,    band);
00173    
00174 
00175    sinfo_get_ins_set(band,&ins_set);
00176    return;
00177 
00178 
00179 
00180 
00181 }
00182 
00190 static void     
00191 parse_section_badsearch(detnoise_config * cfg,cpl_parameterlist *   cpl_cfg)
00192 {  
00193    cpl_parameter *p;   
00194 
00195    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.low_rejection");
00196    cfg -> loReject = cpl_parameter_get_double(p);
00197 
00198    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.high_rejection");
00199    cfg -> hiReject = cpl_parameter_get_double(p);
00200 
00201    p = cpl_parameterlist_find(cpl_cfg,"sinfoni.bp_noise.thresh_sigma_factor");
00202    cfg->threshSigmaFactor = cpl_parameter_get_double(p);
00203 
00204 }
00212 void
00213 sinfo_detnoise_free(detnoise_config * cfg)
00214 {
00215   int i=0;
00216   if(cfg != NULL) {
00217     for(i=0;i<cfg->nframes;i++){
00218       if(cfg->framelist[i] != NULL) cpl_free(cfg->framelist[i]);
00219     }
00220     if(cfg->framelist) {
00221       if(cfg->framelist != NULL) cpl_free(cfg->framelist);
00222     }
00223     sinfo_detnoise_cfg_destroy(cfg);
00224   }
00225 }

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