sinfo_lamp_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_lamp_ini_by_cpl.c
00022    Author       :   Andrea Modigliani
00023    Created on   :   May 26, 2004
00024    Description  :   lamp spectrum cpl input handling for SPIFFI
00025  ---------------------------------------------------------------------------*/
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 /*---------------------------------------------------------------------------
00030                                 Includes
00031  ---------------------------------------------------------------------------*/
00032 #include "sinfo_lamp_ini_by_cpl.h"
00033 #include "sinfo_functions.h"
00034 #include "sinfo_pro_types.h"
00035 /*---------------------------------------------------------------------------
00036                     Functions private to this module
00037  ---------------------------------------------------------------------------*/
00038 static void     
00039 parse_section_frames(lamp_config *, 
00040                      cpl_parameterlist* cpl_cfg, 
00041                      cpl_frameset* sof, 
00042                      cpl_frameset** raw, 
00043                      int* status);
00044 
00045 static void     
00046 parse_section_resampling(lamp_config *, cpl_parameterlist* cpl_cfg);
00047 static void     
00048 parse_section_extractspectrum(lamp_config *, cpl_parameterlist* cpl_cfg);
00049 
00068 lamp_config * 
00069 sinfo_parse_cpl_input_lamp(cpl_parameterlist* cpl_cfg, 
00070                            cpl_frameset* sof, 
00071                cpl_frameset** raw)
00072 
00073 {
00074         lamp_config   *       cfg= sinfo_lamp_cfg_create();
00075         int status=0;
00076         /*
00077          * Perform sanity checks, fill up the structure with what was
00078          * found in the ini file
00079          */
00080 
00081 
00082         parse_section_resampling    (cfg, cpl_cfg);
00083         parse_section_extractspectrum (cfg, cpl_cfg);
00084         parse_section_frames    (cfg, cpl_cfg, sof, raw,&status);
00085  
00086         if (status > 0) {
00087                 sinfo_msg_error("parsing cpl input");
00088                 sinfo_lamp_cfg_destroy(cfg);
00089                 cfg = NULL ;
00090                 return NULL ;
00091         }
00092         return cfg ;
00093 }
00094 
00095 
00105 static void     
00106 parse_section_frames(lamp_config * cfg,
00107              cpl_parameterlist * cpl_cfg,
00108              cpl_frameset * sof,
00109              cpl_frameset ** raw,
00110                      int* status)
00111 {
00112 
00113    cpl_frame* frame   = NULL;
00114    cpl_parameter *p; 
00115    int nraw=0;
00116     char spat_res[FILE_NAME_SZ];
00117    char lamp_status[FILE_NAME_SZ];
00118    char band[FILE_NAME_SZ];
00119    int ins_set=0;
00120 
00121    /* Input */
00122 
00123    *raw=cpl_frameset_new();
00124    sinfo_extract_raw_frames_type(sof,raw,PRO_FLUX_LAMP_STACKED);   
00125 
00126    nraw    = cpl_frameset_get_size(*raw);
00127 
00128    if(nraw<1) {
00129      sinfo_msg_error("no good raw frame %s in input!",PRO_FLUX_LAMP_STACKED);
00130      (*status)++;
00131      return;
00132    }
00133    frame = cpl_frameset_get_frame(*raw,0);
00134    strcpy(cfg -> inFrame,cpl_strdup(cpl_frame_get_filename(frame)));
00135 
00136    /* Output */
00137    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.output_filename");
00138    strcpy(cfg -> outName, cpl_parameter_get_string(p));
00139 
00140    sinfo_get_spatial_res(frame,spat_res);
00141    switch(sinfo_frame_is_on(frame))
00142      {
00143 
00144     case 0: 
00145       strcpy(lamp_status,"on");
00146       break;
00147     case 1: 
00148       strcpy(lamp_status,"off");
00149       break;
00150     case -1:
00151       strcpy(lamp_status,"undefined");
00152       break;
00153     default: 
00154       strcpy(lamp_status,"undefined");
00155       break;
00156 
00157      }
00158    sinfo_get_band(frame,band);
00159    sinfo_msg("stat_res: %s lamp_status: %s band: %s \n",
00160                      spat_res,    lamp_status,    band);
00161 
00162    
00163    sinfo_get_ins_set(band,&ins_set);
00164 
00165    if(NULL != cpl_frameset_find(sof,PRO_WAVE_MAP)) {
00166       frame = cpl_frameset_find(sof,PRO_WAVE_MAP);
00167       strcpy(cfg -> wavemapim,cpl_strdup(cpl_frame_get_filename(frame)));
00168    } else {
00169      sinfo_msg_error("Frame %s not found! Exit!", PRO_WAVE_MAP);
00170      (*status)++;
00171      return;
00172    }
00173 
00174 
00175    return ;
00176 
00177 }
00178 
00179 
00180 
00188 static void     
00189 parse_section_resampling(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00190 {
00191 
00192    cpl_parameter *p; 
00193    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.ncoeffs");
00194    cfg -> ncoeffs =  cpl_parameter_get_int(p);
00195 
00196    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.nrows");
00197    cfg -> nrows =  cpl_parameter_get_int(p);
00198 
00199    return ;
00200 
00201 }
00209 static void     
00210 parse_section_extractspectrum(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00211 {
00212    cpl_parameter *p; 
00213   
00214    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.lower_rejection");
00215    cfg -> loReject = cpl_parameter_get_double(p);
00216 
00217    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.higher_rejection");
00218    cfg -> hiReject = cpl_parameter_get_double(p);
00219 
00220    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.counts_to_intensity");
00221    cfg -> countsToIntensity = cpl_parameter_get_double(p);
00222 
00223    return ;
00224 
00225 }
00232 void
00233 sinfo_lamp_free(lamp_config * cfg)
00234 {  
00235   sinfo_lamp_cfg_destroy(cfg);
00236   return;
00237 
00238 }

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