baddist_ini_by_cpl.c

00001 
00002 /*----------------------------------------------------------------------------
00003    
00004    File name    :   baddist_ini_by_cpl.c
00005    Author       :   Andrea Modigliani
00006    Created on   :   Jun 16, 2004
00007    Description  :   parse cpl input for the search of static bad pixels
00008 
00009  ---------------------------------------------------------------------------*/
00010 
00011 
00012 /*---------------------------------------------------------------------------
00013                                 Includes
00014  ---------------------------------------------------------------------------*/
00015 
00016 #include "baddist_ini_by_cpl.h"
00017 /*---------------------------------------------------------------------------
00018                     Functions private to this module
00019  ---------------------------------------------------------------------------*/
00020 
00021 static void  parse_section_frames(bad_config * cfg, 
00022 cpl_frameset* sof, const char* procatg, cpl_frameset** raw, int* status);
00023 static void parse_section_badpix(bad_config * cfg, cpl_parameterlist* cpl_cfg);
00024 static void parse_section_thresh(bad_config * cfg, cpl_parameterlist* cpl_cfg);
00025 
00026 
00027 /* Removed generatebaddist_ini_file */
00028 
00029 
00030 /*-------------------------------------------------------------------------*/
00041 /*--------------------------------------------------------------------------*/
00042 
00043 bad_config * parse_cpl_input_baddist(cpl_parameterlist * cpl_cfg, 
00044                                      cpl_frameset* sof,
00045                                      const char* procatg,
00046                                      cpl_frameset** raw) 
00047 {
00048   const char* _id = "parse_cpl_input_baddist";
00049   bad_config    *       cfg ;
00050   int status = 0;
00051         /* Removed check on ini_file */
00052         /* Removed load of ini file */
00053 
00054   cfg = bad_cfg_create();
00055 
00056         /*
00057          * Perform sanity checks, fill up the structure with what was
00058          * found in the ini file
00059          */
00060 
00061   parse_section_badpix   (cfg, cpl_cfg);
00062   parse_section_thresh   (cfg, cpl_cfg);
00063   parse_section_frames   (cfg, sof, procatg, raw,&status);
00064   if(status>0) {
00065                cpl_msg_error(_id,"parsing cpl input");
00066                 bad_cfg_destroy(cfg);
00067                 cfg = NULL ;
00068                 return NULL ;
00069   }
00070   return cfg ;
00071 
00072 }
00073 
00074 static void     
00075 parse_section_frames(bad_config   * cfg,
00076                      cpl_frameset * sof,
00077                      const char    * procatg,          
00078                      cpl_frameset ** raw,
00079                      int* status)
00080 {
00081    const char * _id = "baddist_ini_by_cpl";
00082    int                i=0;
00083    int                nraw = 0;
00084    char *          tag=NULL;
00085 
00086    int  nraw_good = 0;
00087    cpl_frame* frame=NULL;
00088    char spat_res[FILE_NAME_SZ];
00089    char lamp_status[FILE_NAME_SZ];
00090    char band[FILE_NAME_SZ];
00091    int ins_set=0;
00092 
00093 
00094      if(strcmp(procatg,PRO_BP_MAP_DI) == 0 ) {
00095 
00096       sinfoni_extract_raw_frames_type(sof,raw,PRO_MASTER_FLAT_LAMP);
00097       nraw=cpl_frameset_get_size(*raw);
00098 
00099    } else if(strcmp(procatg,PRO_BP_MAP_NO) == 0 ) {
00100       
00101       sinfoni_extract_raw_frames_type(sof,raw,PRO_MASTER_FLAT_LAMP);
00102       nraw=cpl_frameset_get_size(*raw);
00103 
00104    } else {
00105       sinfoni_extract_raw_frames_type(sof,raw,RAW_FLAT_LAMP);
00106       nraw=cpl_frameset_get_size(*raw);
00107 
00108       if (nraw==0) {
00109          sinfoni_extract_raw_frames_type(sof,raw,RAW_FLAT_NS);
00110          nraw=cpl_frameset_get_size(*raw);
00111       }   
00112 
00113    }
00114     if (nraw==0) {
00115          sinfoni_extract_raw_frames_type(sof,raw,RAW_FLAT_LAMP);
00116          nraw=cpl_frameset_get_size(*raw);
00117     }
00118 
00119     if (nraw==0) {
00120          sinfoni_extract_raw_frames_type(sof,raw,RAW_FLAT_NS);
00121          nraw=cpl_frameset_get_size(*raw);
00122     }
00123 
00124 
00125 
00126    nraw=cpl_frameset_get_size(*raw);
00127    if (nraw < 1) {
00128       cpl_msg_error(_id, "Too few (%d) raw frames (%s or %s) present in"
00129              "frameset!Aborting...",nraw,
00130                          RAW_FLAT_LAMP,RAW_FLAT_NS);
00131       (*status)++;
00132       return;
00133    }
00134         
00135    /* Removed: get "general:infile" read it, check input matrix */
00136    /* Allocate structures to go into the blackboard */
00137    cfg->framelist     = cpl_malloc(nraw * sizeof(char*));
00138 
00139    /* read input frames */
00140    for (i=0 ; i<nraw ; i++) {
00141       frame = cpl_frameset_get_frame(*raw,i);
00142       tag = (char*)cpl_frame_get_tag(frame) ;
00143       if(file_exists((char*) cpl_frame_get_filename(frame))==1) 
00144     {
00145              /* Store file name into framelist */
00146              cfg->framelist[i]=(char*) cpl_frame_get_filename(frame);
00147              nraw_good++;
00148     }
00149    }
00150    if(nraw_good<1) {
00151      cpl_msg_error(_id,"Error: no good raw frame in input, something wrong!");
00152      (*status)++;
00153      return;
00154    }
00155 
00156    /* Copy relevant information into the blackboard */
00157    cfg->nframes         = nraw_good ;
00158 
00159    /* Output */
00160    strcpy(cfg -> outName, BP_DIST_OUT_FILENAME);
00161  
00162 
00163 
00164 
00165    frame = cpl_frameset_get_frame(*raw,0);
00166    sinfoni_get_spatial_res(frame,spat_res);
00167  
00168     switch(sinfoni_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     sinfoni_get_band(frame,band);
00185    cpl_msg_info(_id,"stat_res: %s lamp_status: %s band: %s \n",
00186                      spat_res,    lamp_status,    band);
00187 
00188 
00189    sinfoni_get_ins_set(band,&ins_set);
00190    /*
00191       cpl_msg_info(_id,MSG_OVER_WRITE_PAR);
00192       rec_bp_dist_set(cfg,cpl_cfg,ins_set);
00193    */
00194    /*
00195    printf("cfg -> sigmaFactor =%f\n", cfg -> sigmaFactor);
00196    printf("cfg -> methodInd   =%d\n", cfg -> methodInd);
00197    printf("cfg -> factor      =%f\n", cfg -> factor);
00198    printf("cfg -> iterations  =%d\n", cfg -> iterations);
00199    printf("cfg -> loReject    =%f\n", cfg -> loReject);
00200    printf("cfg -> hiReject    =%f\n", cfg -> hiReject);
00201    printf("cfg -> llx         =%d\n", cfg -> llx);
00202    printf("cfg -> lly         =%d\n", cfg -> lly);
00203    printf("cfg -> urx         =%d\n", cfg -> urx);
00204    printf("cfg -> ury         =%d\n", cfg -> ury);
00205 
00206    printf("cfg -> threshInd   =%d\n", cfg -> threshInd);
00207    printf("cfg -> meanfactor  =%f\n", cfg -> meanfactor);
00208    printf("cfg -> mincut      =%f\n", cfg -> mincut);
00209    printf("cfg -> maxcut      =%f\n", cfg -> maxcut);
00210    */
00211 
00212    return;
00213 
00214 }
00215 
00216 static void     
00217 parse_section_badpix(bad_config    * cfg, cpl_parameterlist *   cpl_cfg)
00218 {
00219    cpl_parameter *p;     
00220 
00221    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.sigma_factor");
00222    cfg -> sigmaFactor = cpl_parameter_get_double(p);
00223 
00224    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.method_index");
00225    cfg -> methodInd = cpl_parameter_get_int(p);
00226 
00227    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.factor");
00228    cfg -> factor = cpl_parameter_get_double(p);
00229 
00230    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.iterations");
00231    cfg -> iterations = cpl_parameter_get_int(p);
00232 
00233    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.low_rejection");
00234    cfg -> loReject = cpl_parameter_get_double(p);
00235 
00236    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.high_rejection");
00237    cfg -> hiReject = cpl_parameter_get_double(p);
00238 
00239    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.llx");
00240    cfg -> llx = cpl_parameter_get_int(p);
00241 
00242    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.lly");
00243    cfg -> lly = cpl_parameter_get_int(p);
00244 
00245    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.urx");
00246    cfg -> urx = cpl_parameter_get_int(p);
00247 
00248    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.ury");
00249    cfg -> ury = cpl_parameter_get_int(p);
00250 
00251 }
00252 
00253 static void     
00254 parse_section_thresh(bad_config    * cfg, cpl_parameterlist *   cpl_cfg)
00255 {
00256    cpl_parameter *p;     
00257 
00258    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.threshold_index");
00259    cfg -> threshInd  = cpl_parameter_get_bool(p);
00260 
00261    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.mean_factor");
00262    cfg -> meanfactor = cpl_parameter_get_double(p);
00263 
00264 
00265    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.min_cut");
00266    cfg -> mincut = cpl_parameter_get_double(p);
00267 
00268    p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_dist.max_cut");
00269    cfg -> maxcut = cpl_parameter_get_double(p);
00270 
00271 }

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