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 "sinfo_detnoise_ini_by_cpl.h"
00034 #include "sinfo_raw_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 
00042 static void  
00043 parse_section_frames(detnoise_config * cfg, 
00044                      cpl_frameset* sof, 
00045                      cpl_frameset** raw, 
00046                      int* status);
00047 static void  
00048 parse_section_badsearch(detnoise_config * cfg, cpl_parameterlist* cpl_cfg);
00049 
00057 /****************************************************************************/
00069 detnoise_config * 
00070 sinfo_parse_cpl_input_detnoise(cpl_parameterlist * cpl_cfg, 
00071                                cpl_frameset* sof, 
00072                                cpl_frameset** raw)
00073 {
00074 
00075   detnoise_config    *    cfg ;
00076   int status=0;
00077   /* Removed check on ini_file */
00078   /* Removed load of ini file */
00079 
00080   cfg = sinfo_detnoise_cfg_create();
00081 
00082    /*
00083    * Perform sanity checks, fill up the structure with what was
00084    * found in the ini file
00085    */
00086   parse_section_badsearch(cfg, cpl_cfg);
00087   parse_section_frames(cfg, sof, raw, &status);
00088 
00089          if (status > 0) {
00090                 sinfo_msg_error("parsing cpl input");
00091                 sinfo_detnoise_free(cfg);
00092                 cfg = NULL ;
00093                 return NULL ;
00094         }
00095   return cfg ;
00096 }
00097 
00098 
00109 static void     
00110 parse_section_frames(detnoise_config * cfg,
00111              cpl_frameset * sof,
00112                      cpl_frameset** raw,
00113                      int* status)
00114 {
00115    int                     i;
00116 
00117    int  nraw = 0;
00118    cpl_frame* frame=NULL;
00119 
00120     char spat_res[FILE_NAME_SZ];
00121    char lamp_status[FILE_NAME_SZ];
00122    char band[FILE_NAME_SZ];
00123    int ins_set=0;
00124 
00125 
00126 
00127    sinfo_extract_raw_frames_type2(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    /* get "general:infile" read it, check input sinfo_matrix */
00138    /* Allocate structures to go into the blackboard */
00139    /* Copy relevant information into the blackboard */
00140    cfg->nframes       = nraw ;
00141    cfg->framelist  =  cpl_malloc(nraw*sizeof(char*)); 
00142   /* read input frames */
00143    for (i=0 ; i<nraw ; i++) {
00144       frame = cpl_frameset_get_frame(*raw,i);
00145       /* Store file name into framelist */
00146        cfg->framelist[i]=cpl_strdup(cpl_frame_get_filename(frame));
00147    }
00148  
00149    strcpy(cfg -> outName, BP_NOISE_OUT_FILENAME);
00150 
00151    frame = cpl_frameset_get_frame(*raw,0);
00152    sinfo_get_spatial_res(frame,spat_res);
00153    switch(sinfo_frame_is_on(frame)) 
00154      {
00155    case 0: 
00156       strcpy(lamp_status,"on");
00157       break;
00158     case 1: 
00159       strcpy(lamp_status,"off");
00160       break;
00161     case -1:
00162       strcpy(lamp_status,"undefined");
00163       break;
00164     default: 
00165       strcpy(lamp_status,"undefined");
00166       break;
00167      }
00168 
00169    sinfo_get_band(frame,band);
00170    sinfo_msg("Spatial resolution: %s lamp status: %s band: %s \n",
00171                      spat_res,    lamp_status,    band);
00172    
00173 
00174    sinfo_get_ins_set(band,&ins_set);
00175    return;
00176 
00177 
00178 
00179 
00180 }
00181 
00189 static void     
00190 parse_section_badsearch(detnoise_config * cfg,cpl_parameterlist *   cpl_cfg)
00191 {  
00192    cpl_parameter *p;   
00193 
00194    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.low_rejection");
00195    cfg -> loReject = cpl_parameter_get_double(p);
00196 
00197    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.high_rejection");
00198    cfg -> hiReject = cpl_parameter_get_double(p);
00199 
00200    p = cpl_parameterlist_find(cpl_cfg,"sinfoni.bp_noise.thresh_sigma_factor");
00201    cfg->threshSigmaFactor = cpl_parameter_get_double(p);
00202 
00203 }
00211 void
00212 sinfo_detnoise_free(detnoise_config * cfg)
00213 {
00214   int i=0;
00215   if(cfg != NULL) {
00216     for(i=0;i<cfg->nframes;i++){
00217       if(cfg->framelist[i] != NULL) cpl_free(cfg->framelist[i]);
00218     }
00219     if(cfg->framelist) {
00220       if(cfg->framelist != NULL) cpl_free(cfg->framelist);
00221     }
00222     sinfo_detnoise_cfg_destroy(cfg);
00223   }
00224 }

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