focus_ini_by_cpl.c

00001 
00002 /*----------------------------------------------------------------------------
00003    
00004    File name    :   focus_ini_by_cpl.c
00005    Author       :   Andrea Modigliani
00006    Created on   :   May 20, 2004
00007    Description  :   cpl input handling for SPIFFI
00008 
00009  ---------------------------------------------------------------------------*/
00010 
00011 
00012 
00013 /*---------------------------------------------------------------------------
00014                                 Includes
00015  ---------------------------------------------------------------------------*/
00016 
00017 #include "focus_ini_by_cpl.h"
00018 
00019 /*---------------------------------------------------------------------------
00020                     Functions private to this module
00021  ---------------------------------------------------------------------------*/
00022 static void parse_section_frames(focus_config *, cpl_parameterlist* cpl_cfg, 
00023                    cpl_frameset* sof,cpl_frameset** stk, int* status);
00024 static void parse_section_reconstruction(focus_config *, cpl_parameterlist* cpl_cfg);
00025 static void parse_section_gauss2dfit(focus_config *, cpl_parameterlist* cpl_cfg);
00026 
00027 
00028 /* removed generateFocus_ini_file */
00029 
00030 
00031 /*-------------------------------------------------------------------------*/
00042 /*--------------------------------------------------------------------------*/
00043 
00044 focus_config * parse_cpl_input_focus(cpl_parameterlist * cpl_cfg, cpl_frameset* sof,
00045                      cpl_frameset** stk)
00046 {
00047         focus_config  *       cfg = focus_cfg_create();
00048   const cxchar * _id = "parse_cpl_input_focus";
00049   int status=0;
00050         /*
00051          * Perform sanity checks, fill up the structure with what was
00052          * found in the ini file
00053          */
00054 
00055         parse_section_reconstruction   (cfg, cpl_cfg);
00056         parse_section_gauss2dfit       (cfg, cpl_cfg);
00057         parse_section_frames           (cfg, cpl_cfg,sof,stk,&status);
00058         if (status > 0) {
00059                 cpl_msg_error(_id,"parsing cpl input");
00060                 focus_cfg_destroy(cfg);
00061                 cfg = NULL ;
00062                 return NULL ;
00063         }
00064         return cfg ;
00065 }
00066 
00067 static void   
00068 parse_section_frames(focus_config * cfg,cpl_parameterlist* cpl_cfg,
00069 cpl_frameset* sof,cpl_frameset** raw, int* status)
00070 {
00071 
00072    const char* _id = "parse_section_frames";
00073 
00074    char            *       name ;
00075     int nframes=0;
00076    int nraw=0;
00077    cpl_frame* frame   = NULL;
00078    cpl_parameter *p; 
00079 
00080 
00081    char spat_res[FILE_NAME_SZ];
00082    char lamp_status[FILE_NAME_SZ];
00083    char band[FILE_NAME_SZ];
00084    int ins_set=0;
00085 
00086 
00087    char * tag;
00088    int i=0;
00089    nframes = cpl_frameset_get_size(sof);
00090     /* Get the raw and the calibration files */
00091     /* Labelise the input frames according to their tags */
00092 
00093   *raw=cpl_frameset_new();
00094    sinfoni_extract_raw_frames_type(sof,raw,PRO_FOCUS_STACKED);
00095 
00096 
00097    nraw=cpl_frameset_get_size(*raw);
00098    if (nraw < 1) {
00099       cpl_msg_error(_id,"Too few (%d) raw frames (%s) present in"
00100             "frameset!Aborting...",nraw,PRO_FOCUS_STACKED);
00101           (*status)++;
00102           return;
00103    }
00104    /* Allocate structures to go into the blackboard */
00105    cfg->inFrameList     = cpl_malloc(nraw * sizeof(char*));
00106  
00107    /* Browse through the charmatrix to get names and file types */
00108    for (i=0 ; i<nraw ; i++) {
00109       frame = cpl_frameset_get_frame(*raw,i);
00110       name= (char*) cpl_frame_get_filename(frame);
00111       if(file_exists(name)==1) {
00112     /* to go on the file must exist */
00113     if(cpl_frame_get_tag(frame) != NULL) {
00114       /* If the frame has a tag we process it. Else it is an object */ 
00115       tag= (char*) cpl_frame_get_tag(frame);
00116           if(sinfoni_is_stack(tag)) 
00117         {
00118              cfg->inFrameList[i]=cpl_strdup(cpl_frame_get_filename(frame));
00119         }
00120           else {
00121             cpl_msg_error(_id,"No good frame tag %s in input frame set",tag);
00122         (*status)++;
00123             return;
00124       }
00125     }
00126       }
00127       /* Store file name into inFrameList */
00128    }
00129 
00130    /* Copy relevant information into the blackboard */
00131    cfg->nframes = nraw ;
00132 
00133 
00134    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.output_filename");
00135    strcpy(cfg -> outName, cpl_parameter_get_string(p));
00136 
00137    if(NULL != cpl_frameset_find(sof,PRO_FIRST_COL)) {
00138       frame = cpl_frameset_find(sof,PRO_FIRST_COL);
00139       strcpy(cfg -> firstCol,cpl_strdup(cpl_frame_get_filename(frame)));
00140    } else {
00141       cpl_msg_error(_id,"Frame %s not found! Exit!", PRO_FIRST_COL);
00142         (*status)++;
00143       return;
00144    }
00145 
00146    if(NULL != cpl_frameset_find(sof,PRO_SLITLETS_DISTANCE)) {
00147       frame = cpl_frameset_find(sof,PRO_SLITLETS_DISTANCE);
00148       strcpy(cfg -> poslist,cpl_strdup(cpl_frame_get_filename(frame)));
00149    } else {
00150       cpl_msg_error(_id,"Frame %s not found! Exit!", PRO_SLITLETS_DISTANCE);
00151         (*status)++;
00152       return;
00153    }
00154 
00155 
00156 
00157    frame = cpl_frameset_get_frame(*raw,0);
00158    sinfoni_get_spatial_res(frame,spat_res);
00159  
00160    switch(sinfoni_frame_is_on(frame)) 
00161      {
00162    case 0: 
00163       strcpy(lamp_status,"on");
00164       break;
00165     case 1: 
00166       strcpy(lamp_status,"off");
00167       break;
00168     case -1:
00169       strcpy(lamp_status,"undefined");
00170       break;
00171     default: 
00172       strcpy(lamp_status,"undefined");
00173       break;
00174      }
00175 
00176    sinfoni_get_band(frame,band);
00177    cpl_msg_info(_id,"stat_res: %s lamp_status: %s band: %s \n",
00178                      spat_res,    lamp_status,    band);
00179 
00180 
00181    sinfoni_get_ins_set(band,&ins_set);
00182    return;
00183 }
00184 
00185 static void     
00186 parse_section_reconstruction(focus_config * cfg,cpl_parameterlist * cpl_cfg)
00187 {
00188 
00189 
00190   cpl_parameter* p;
00191 
00192    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.lower_rejection");
00193    cfg -> lo_reject = cpl_parameter_get_double(p);
00194 
00195    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.higher_rejection");
00196    cfg -> hi_reject =  cpl_parameter_get_double(p);
00197 
00198    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.north_south_index");
00199    cfg -> northsouthInd = cpl_parameter_get_bool(p);
00200 
00201    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.nslits");
00202    cfg -> nslits = cpl_parameter_get_int(p);
00203  
00204    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.method");
00205    strcpy(cfg->method, cpl_parameter_get_string(p));
00206 
00207    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.order");
00208    cfg -> order= cpl_parameter_get_int(p);
00209 
00210 }
00211 
00212 static void     
00213 parse_section_gauss2dfit(focus_config * cfg,cpl_parameterlist * cpl_cfg)
00214 {
00215  cpl_parameter* p;
00216    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.llx");
00217    cfg -> llx = cpl_parameter_get_int(p);
00218 
00219    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.lly");
00220    cfg -> lly = cpl_parameter_get_int(p);
00221 
00222    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.halfbox_x");
00223    cfg -> halfbox_x =  cpl_parameter_get_int(p);
00224 
00225    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.halfbox_y");
00226    cfg -> halfbox_y = cpl_parameter_get_int(p);
00227 
00228    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar0");
00229    cfg -> mpar0 = cpl_parameter_get_int(p);
00230 
00231    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar1");
00232    cfg -> mpar1 = cpl_parameter_get_int(p);
00233 
00234    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar2");
00235    cfg -> mpar2 = cpl_parameter_get_int(p);
00236 
00237    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar3");
00238    cfg -> mpar3 = cpl_parameter_get_int(p);
00239 
00240    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar4");
00241    cfg -> mpar4 = cpl_parameter_get_int(p);
00242 
00243    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar5");
00244    cfg -> mpar5 = cpl_parameter_get_int(p);
00245 
00246    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.mpar6");
00247    cfg -> mpar6 = cpl_parameter_get_int(p);
00248 
00249    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.fit_list");
00250    strcpy(cfg -> fitlist, cpl_parameter_get_string(p));
00251 
00252    /* int or string ?*/
00253    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.plot_gauss_ind");
00254    cfg -> plotGaussInd = cpl_parameter_get_bool(p);
00255 
00256    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.focus.gauss_plot_name");
00257    strcpy( cfg -> gaussplotName, cpl_parameter_get_string(p));
00258 
00259    return ;
00260 }
00261 
00262 void
00263 free_focus(focus_config * cfg) {
00264    cpl_free(cfg->inFrameList);
00265    focus_cfg_destroy (cfg);
00266   
00267    return;
00268 }

Generated on Wed Oct 26 13:08:52 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001