00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "detnoise_ini_by_cpl.h"
00018
00019
00020
00021
00022
00023 static void parse_section_frames(detnoise_config * cfg, cpl_frameset* sof, cpl_frameset** raw, int* status);
00024 static void parse_section_badsearch(detnoise_config * cfg, cpl_parameterlist* cpl_cfg);
00025
00026
00027
00028
00039
00040
00041 detnoise_config * parse_cpl_input_detnoise(cpl_parameterlist * cpl_cfg, cpl_frameset* sof, cpl_frameset** raw)
00042 {
00043
00044 const cxchar * _id = "detnoise_ini_by_cpl";
00045 detnoise_config * cfg ;
00046 int status=0;
00047
00048
00049 cfg = detnoise_cfg_create();
00050
00051
00052
00053
00054
00055 parse_section_badsearch(cfg, cpl_cfg);
00056 parse_section_frames(cfg, sof, raw, &status);
00057
00058 if (status > 0) {
00059 cpl_msg_error(_id,"parsing cpl input");
00060 detnoise_free(cfg);
00061 cfg = NULL ;
00062 return NULL ;
00063 }
00064 return cfg ;
00065 }
00066
00067
00068
00069
00070 static void
00071 parse_section_frames(detnoise_config * cfg,
00072 cpl_frameset * sof,
00073 cpl_frameset** raw,
00074 int* status)
00075 {
00076 int i;
00077 const cxchar * _id = "parse_section_frames";
00078
00079 cxint nraw = 0;
00080 cpl_frame* frame=NULL;
00081
00082 char spat_res[FILE_NAME_SZ];
00083 char lamp_status[FILE_NAME_SZ];
00084 char band[FILE_NAME_SZ];
00085 int ins_set=0;
00086
00087
00088
00089
00090 sinfoni_extract_raw_frames_type2(sof,raw,RAW_DARK);
00091
00092 nraw = cpl_frameset_get_size(*raw);
00093 if (nraw < 1) {
00094 cpl_msg_error(_id,"Too few (%d) raw frames (%s) present in"
00095 "frameset!Aborting...",nraw,RAW_DARK);
00096 (*status)++;
00097 return;
00098 }
00099
00100
00101
00102
00103 cfg->nframes = nraw ;
00104 cfg->framelist = cpl_malloc(nraw*sizeof(char*));
00105
00106 for (i=0 ; i<nraw ; i++) {
00107 frame = cpl_frameset_get_frame(*raw,i);
00108
00109
00110 cfg->framelist[i]=cpl_strdup(cpl_frame_get_filename(frame));
00111 }
00112
00113 strcpy(cfg -> outName, BP_NOISE_OUT_FILENAME);
00114
00115 frame = cpl_frameset_get_frame(*raw,0);
00116 sinfoni_get_spatial_res(frame,spat_res);
00117 switch(sinfoni_frame_is_on(frame))
00118 {
00119 case 0:
00120 strcpy(lamp_status,"on");
00121 break;
00122 case 1:
00123 strcpy(lamp_status,"off");
00124 break;
00125 case -1:
00126 strcpy(lamp_status,"undefined");
00127 break;
00128 default:
00129 strcpy(lamp_status,"undefined");
00130 break;
00131 }
00132
00133 sinfoni_get_band(frame,band);
00134 cpl_msg_info(_id,"Spatial resolution: %s lamp status: %s band: %s \n",
00135 spat_res, lamp_status, band);
00136
00137
00138 sinfoni_get_ins_set(band,&ins_set);
00139
00140 return;
00141
00142
00143
00144
00145 }
00146
00147 static void
00148 parse_section_badsearch(detnoise_config * cfg,cpl_parameterlist * cpl_cfg)
00149 {
00150 cpl_parameter *p;
00151
00152 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.low_rejection");
00153 cfg -> loReject = cpl_parameter_get_double(p);
00154
00155 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.high_rejection");
00156 cfg -> hiReject = cpl_parameter_get_double(p);
00157
00158 p = cpl_parameterlist_find(cpl_cfg,"sinfoni.bp_noise.thresh_sigma_factor");
00159 cfg->threshSigmaFactor = cpl_parameter_get_double(p);
00160
00161 }
00162
00163 void
00164 detnoise_free(detnoise_config * cfg)
00165 {
00166 int i=0;
00167 for(i=0;i<cfg->nframes;i++){
00168 cpl_free(cfg->framelist[i]);
00169 }
00170 if(cfg->framelist) {
00171 cpl_free(cfg->framelist);
00172 }
00173
00174
00175 detnoise_cfg_destroy(cfg);
00176
00177 }