00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "lamp_ini_by_cpl.h"
00018 #include "sinfoni_functions.h"
00019
00020
00021
00022
00023
00024
00025 static void parse_section_frames(lamp_config *, cpl_parameterlist* cpl_cfg, cpl_frameset* sof, cpl_frameset** raw, int* status);
00026 static void parse_section_resampling(lamp_config *, cpl_parameterlist* cpl_cfg);
00027 static void parse_section_extractspectrum(lamp_config *, cpl_parameterlist* cpl_cfg);
00028
00029
00030
00041
00042
00043 lamp_config * parse_cpl_input_lamp(cpl_parameterlist* cpl_cfg, cpl_frameset* sof,
00044 cpl_frameset** raw)
00045
00046 {
00047 lamp_config * cfg= lamp_cfg_create();
00048 int status=0;
00049 const cxchar * _id = "parse_cpl_input_lamp";
00050
00051
00052
00053
00054
00055
00056 parse_section_resampling (cfg, cpl_cfg);
00057 parse_section_extractspectrum (cfg, cpl_cfg);
00058 parse_section_frames (cfg, cpl_cfg, sof, raw,&status);
00059
00060 if (status > 0) {
00061 cpl_msg_error(_id,"parsing cpl input");
00062 lamp_cfg_destroy(cfg);
00063 cfg = NULL ;
00064 return NULL ;
00065 }
00066 return cfg ;
00067 }
00068
00069
00070 static void
00071 parse_section_frames(lamp_config * cfg,
00072 cpl_parameterlist * cpl_cfg,
00073 cpl_frameset * sof,
00074 cpl_frameset ** raw,
00075 int* status)
00076 {
00077
00078 const cxchar * _id = "parse_section_frames";
00079 cpl_frame* frame = NULL;
00080 cpl_parameter *p;
00081 int nraw=0;
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 *raw=cpl_frameset_new();
00090 sinfoni_extract_raw_frames_type(sof,raw,PRO_FLUX_LAMP_STACKED);
00091
00092 nraw = cpl_frameset_get_size(*raw);
00093
00094 if(nraw<1) {
00095 cpl_msg_error(_id,"no good raw frame %s in input!",PRO_FLUX_LAMP_STACKED);
00096 (*status)++;
00097 return;
00098 }
00099 frame = cpl_frameset_get_frame(*raw,0);
00100 strcpy(cfg -> inFrame,cpl_strdup(cpl_frame_get_filename(frame)));
00101
00102
00103 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.output_filename");
00104 strcpy(cfg -> outName, cpl_parameter_get_string(p));
00105
00106 sinfoni_get_spatial_res(frame,spat_res);
00107 switch(sinfoni_frame_is_on(frame))
00108 {
00109
00110 case 0:
00111 strcpy(lamp_status,"on");
00112 break;
00113 case 1:
00114 strcpy(lamp_status,"off");
00115 break;
00116 case -1:
00117 strcpy(lamp_status,"undefined");
00118 break;
00119 default:
00120 strcpy(lamp_status,"undefined");
00121 break;
00122
00123 }
00124 sinfoni_get_band(frame,band);
00125 cpl_msg_info(_id,"stat_res: %s lamp_status: %s band: %s \n",
00126 spat_res, lamp_status, band);
00127
00128
00129 sinfoni_get_ins_set(band,&ins_set);
00130
00131 if(NULL != cpl_frameset_find(sof,PRO_WAVE_MAP)) {
00132 frame = cpl_frameset_find(sof,PRO_WAVE_MAP);
00133 strcpy(cfg -> wavemapim,cpl_strdup(cpl_frame_get_filename(frame)));
00134 } else {
00135 cpl_msg_error(_id,"Frame %s not found! Exit!", PRO_WAVE_MAP);
00136 (*status)++;
00137 return;
00138 }
00139
00140
00141 return ;
00142
00143 }
00144
00145
00146
00147 static void
00148 parse_section_resampling(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00149 {
00150
00151 cpl_parameter *p;
00152 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.ncoeffs");
00153 cfg -> ncoeffs = cpl_parameter_get_int(p);
00154
00155 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.nrows");
00156 cfg -> nrows = cpl_parameter_get_int(p);
00157
00158 return ;
00159
00160 }
00161
00162 static void
00163 parse_section_extractspectrum(lamp_config * cfg, cpl_parameterlist * cpl_cfg)
00164 {
00165 cpl_parameter *p;
00166
00167 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.lower_rejection");
00168 cfg -> loReject = cpl_parameter_get_double(p);
00169
00170 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.higher_rejection");
00171 cfg -> hiReject = cpl_parameter_get_double(p);
00172
00173 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.lamp_spec.counts_to_intensity");
00174 cfg -> countsToIntensity = cpl_parameter_get_double(p);
00175
00176 return ;
00177
00178 }
00179
00180 void
00181 lamp_free(lamp_config * cfg)
00182 {
00183 lamp_cfg_destroy(cfg);
00184 return;
00185
00186 }