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 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030
00031
00032 #include <string.h>
00033 #include "sinfo_lamp_ini_by_cpl.h"
00034 #include "sinfo_functions.h"
00035 #include "sinfo_pro_types.h"
00036
00037
00038
00039 static void
00040 parse_section_frames(lamp_config *,
00041 cpl_parameterlist* cpl_cfg,
00042 cpl_frameset* sof,
00043 cpl_frameset** raw,
00044 int* status);
00045
00046 static void
00047 parse_section_resampling(lamp_config *, cpl_parameterlist* cpl_cfg);
00048 static void
00049 parse_section_extractspectrum(lamp_config *, cpl_parameterlist* cpl_cfg);
00050
00069 lamp_config *
00070 sinfo_parse_cpl_input_lamp(cpl_parameterlist* cpl_cfg,
00071 cpl_frameset* sof,
00072 cpl_frameset** raw)
00073
00074 {
00075 lamp_config * cfg= sinfo_lamp_cfg_create();
00076 int status=0;
00077
00078
00079
00080
00081
00082
00083 parse_section_resampling (cfg, cpl_cfg);
00084 parse_section_extractspectrum (cfg, cpl_cfg);
00085 parse_section_frames (cfg, cpl_cfg, sof, raw,&status);
00086
00087 if (status > 0) {
00088 sinfo_msg_error("parsing cpl input");
00089 sinfo_lamp_cfg_destroy(cfg);
00090 cfg = NULL ;
00091 return NULL ;
00092 }
00093 return cfg ;
00094 }
00095
00096
00106 static void
00107 parse_section_frames(lamp_config * cfg,
00108 cpl_parameterlist * cpl_cfg,
00109 cpl_frameset * sof,
00110 cpl_frameset ** raw,
00111 int* status)
00112 {
00113
00114 cpl_frame* frame = NULL;
00115 cpl_parameter *p;
00116 int nraw=0;
00117 char spat_res[FILE_NAME_SZ];
00118 char lamp_status[FILE_NAME_SZ];
00119 char band[FILE_NAME_SZ];
00120 int ins_set=0;
00121
00122
00123
00124 *raw=cpl_frameset_new();
00125 sinfo_extract_raw_frames_type(sof,raw,PRO_FLUX_LAMP_STACKED);
00126
00127 nraw = cpl_frameset_get_size(*raw);
00128
00129 if(nraw<1) {
00130 sinfo_msg_error("no good raw frame %s in input!",PRO_FLUX_LAMP_STACKED);
00131 (*status)++;
00132 return;
00133 }
00134 frame = cpl_frameset_get_frame(*raw,0);
00135 strcpy(cfg -> inFrame,cpl_strdup(cpl_frame_get_filename(frame)));
00136
00137
00138 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.output_filename");
00139 strcpy(cfg -> outName, cpl_parameter_get_string(p));
00140
00141 sinfo_get_spatial_res(frame,spat_res);
00142 switch(sinfo_frame_is_on(frame))
00143 {
00144
00145 case 0:
00146 strcpy(lamp_status,"on");
00147 break;
00148 case 1:
00149 strcpy(lamp_status,"off");
00150 break;
00151 case -1:
00152 strcpy(lamp_status,"undefined");
00153 break;
00154 default:
00155 strcpy(lamp_status,"undefined");
00156 break;
00157
00158 }
00159 sinfo_get_band(frame,band);
00160 sinfo_msg("Spatial resolution: %s lamp_status: %s band: %s \n",
00161 spat_res, lamp_status, band);
00162
00163
00164 sinfo_get_ins_set(band,&ins_set);
00165
00166 if(NULL != cpl_frameset_find(sof,PRO_WAVE_MAP)) {
00167 frame = cpl_frameset_find(sof,PRO_WAVE_MAP);
00168 strcpy(cfg -> wavemapim,cpl_strdup(cpl_frame_get_filename(frame)));
00169 } else {
00170 sinfo_msg_error("Frame %s not found! Exit!", PRO_WAVE_MAP);
00171 (*status)++;
00172 return;
00173 }
00174
00175
00176 return ;
00177
00178 }
00179
00180
00181
00189 static void
00190 parse_section_resampling(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00191 {
00192
00193 cpl_parameter *p;
00194 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.ncoeffs");
00195 cfg -> ncoeffs = cpl_parameter_get_int(p);
00196
00197 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.nrows");
00198 cfg -> nrows = cpl_parameter_get_int(p);
00199
00200 return ;
00201
00202 }
00210 static void
00211 parse_section_extractspectrum(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00212 {
00213 cpl_parameter *p;
00214
00215 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.lower_rejection");
00216 cfg -> loReject = cpl_parameter_get_double(p);
00217
00218 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.higher_rejection");
00219 cfg -> hiReject = cpl_parameter_get_double(p);
00220
00221 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.counts_to_intensity");
00222 cfg -> countsToIntensity = cpl_parameter_get_double(p);
00223
00224 return ;
00225
00226 }
00233 void
00234 sinfo_lamp_free(lamp_config * cfg)
00235 {
00236 sinfo_lamp_cfg_destroy(cfg);
00237 return;
00238
00239 }