00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifdef HAVE_CONFIG_H
00028 # include <config.h>
00029 #endif
00030
00031
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
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
00078
00079
00080 cfg = sinfo_detnoise_cfg_create();
00081
00082
00083
00084
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
00138
00139
00140 cfg->nframes = nraw ;
00141 cfg->framelist = cpl_malloc(nraw*sizeof(char*));
00142
00143 for (i=0 ; i<nraw ; i++) {
00144 frame = cpl_frameset_get_frame(*raw,i);
00145
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 }