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 <string.h>
00034 #include "sinfo_detnoise_ini_by_cpl.h"
00035 #include "sinfo_raw_types.h"
00036 #include "sinfo_globals.h"
00037 #include "sinfo_hidden.h"
00038 #include "sinfo_functions.h"
00039
00040
00041
00042
00043 static void
00044 parse_section_frames(detnoise_config * cfg,
00045 cpl_frameset* sof,
00046 cpl_frameset** raw,
00047 int* status);
00048 static void
00049 parse_section_badsearch(detnoise_config * cfg, cpl_parameterlist* cpl_cfg);
00050
00058
00070 detnoise_config *
00071 sinfo_parse_cpl_input_detnoise(cpl_parameterlist * cpl_cfg,
00072 cpl_frameset* sof,
00073 cpl_frameset** raw)
00074 {
00075
00076 detnoise_config * cfg ;
00077 int status=0;
00078
00079
00080
00081 cfg = sinfo_detnoise_cfg_create();
00082
00083
00084
00085
00086
00087 parse_section_badsearch(cfg, cpl_cfg);
00088 parse_section_frames(cfg, sof, raw, &status);
00089
00090 if (status > 0) {
00091 sinfo_msg_error("parsing cpl input");
00092 sinfo_detnoise_free(cfg);
00093 cfg = NULL ;
00094 return NULL ;
00095 }
00096 return cfg ;
00097 }
00098
00099
00110 static void
00111 parse_section_frames(detnoise_config * cfg,
00112 cpl_frameset * sof,
00113 cpl_frameset** raw,
00114 int* status)
00115 {
00116 int i;
00117
00118 int nraw = 0;
00119 cpl_frame* frame=NULL;
00120
00121 char spat_res[FILE_NAME_SZ];
00122 char lamp_status[FILE_NAME_SZ];
00123 char band[FILE_NAME_SZ];
00124 int ins_set=0;
00125
00126
00127
00128 sinfo_extract_raw_frames_type2(sof,raw,RAW_DARK);
00129
00130 nraw = cpl_frameset_get_size(*raw);
00131 if (nraw < 1) {
00132 sinfo_msg_error("Too few (%d) raw frames (%s) present in"
00133 "frameset!Aborting...",nraw,RAW_DARK);
00134 (*status)++;
00135 return;
00136 }
00137
00138
00139
00140
00141 cfg->nframes = nraw ;
00142 cfg->framelist = cpl_malloc(nraw*sizeof(char*));
00143
00144 for (i=0 ; i<nraw ; i++) {
00145 frame = cpl_frameset_get_frame(*raw,i);
00146
00147 cfg->framelist[i]=cpl_strdup(cpl_frame_get_filename(frame));
00148 }
00149
00150 strcpy(cfg -> outName, BP_NOISE_OUT_FILENAME);
00151
00152 frame = cpl_frameset_get_frame(*raw,0);
00153 sinfo_get_spatial_res(frame,spat_res);
00154 switch(sinfo_frame_is_on(frame))
00155 {
00156 case 0:
00157 strcpy(lamp_status,"on");
00158 break;
00159 case 1:
00160 strcpy(lamp_status,"off");
00161 break;
00162 case -1:
00163 strcpy(lamp_status,"undefined");
00164 break;
00165 default:
00166 strcpy(lamp_status,"undefined");
00167 break;
00168 }
00169
00170 sinfo_get_band(frame,band);
00171 sinfo_msg("Spatial resolution: %s lamp status: %s band: %s \n",
00172 spat_res, lamp_status, band);
00173
00174
00175 sinfo_get_ins_set(band,&ins_set);
00176 return;
00177
00178
00179
00180
00181 }
00182
00190 static void
00191 parse_section_badsearch(detnoise_config * cfg,cpl_parameterlist * cpl_cfg)
00192 {
00193 cpl_parameter *p;
00194
00195 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.low_rejection");
00196 cfg -> loReject = cpl_parameter_get_double(p);
00197
00198 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.bp_noise.high_rejection");
00199 cfg -> hiReject = cpl_parameter_get_double(p);
00200
00201 p = cpl_parameterlist_find(cpl_cfg,"sinfoni.bp_noise.thresh_sigma_factor");
00202 cfg->threshSigmaFactor = cpl_parameter_get_double(p);
00203
00204 }
00212 void
00213 sinfo_detnoise_free(detnoise_config * cfg)
00214 {
00215 int i=0;
00216 if(cfg != NULL) {
00217 for(i=0;i<cfg->nframes;i++){
00218 if(cfg->framelist[i] != NULL) cpl_free(cfg->framelist[i]);
00219 }
00220 if(cfg->framelist) {
00221 if(cfg->framelist != NULL) cpl_free(cfg->framelist);
00222 }
00223 sinfo_detnoise_cfg_destroy(cfg);
00224 }
00225 }