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
00028
00029 #ifdef HAVE_CONFIG_H
00030 # include <config.h>
00031 #endif
00032
00033
00034
00035
00036
00037 #include <string.h>
00038 #include "sinfo_standstar_ini_by_cpl.h"
00039 #include "sinfo_pro_types.h"
00040 #include "sinfo_hidden.h"
00041 #include "sinfo_functions.h"
00042 #include "sinfo_file_handling.h"
00043
00044
00045
00046
00047
00048
00049
00050 static void
00051 parse_section_frames(standstar_config *,
00052 cpl_frameset* sof,
00053 cpl_frameset** raw,
00054 int* status);
00055 static void
00056 parse_section_extraction(standstar_config *, cpl_parameterlist* cpl_cfg);
00066
00077
00078
00079 standstar_config *
00080 sinfo_parse_cpl_input_standstar(cpl_parameterlist* cpl_cfg,
00081 cpl_frameset* sof,
00082 cpl_frameset** raw)
00083 {
00084
00085 standstar_config * cfg = sinfo_standstar_cfg_create();
00086 int status=0;
00087
00088
00089
00090
00091 parse_section_extraction (cfg, cpl_cfg);
00092 parse_section_frames (cfg, sof, raw,&status);
00093 if (status > 0) {
00094 sinfo_msg_error("parsing cpl input");
00095 sinfo_standstar_cfg_destroy(cfg);
00096 cfg = NULL ;
00097 return NULL ;
00098 }
00099 return cfg ;
00100 }
00101
00102 static void
00103 parse_section_frames(standstar_config * cfg,
00104 cpl_frameset* sof,
00105 cpl_frameset** raw,
00106 int* status)
00107 {
00108 int i;
00109 int nval ;
00110 cpl_frame* frame=NULL;
00111 char spat_res[FILE_NAME_SZ];
00112 char lamp_status[FILE_NAME_SZ];
00113 char band[FILE_NAME_SZ];
00114 int ins_set=0;
00115 cpl_frameset* tmp=NULL;
00116
00117 sinfo_extract_frames_group_type(sof,&tmp,CPL_FRAME_GROUP_PRODUCT);
00118 sinfo_extract_raw_frames_type(tmp,raw,PRO_COADD_STD);
00119 cpl_frameset_delete(tmp);
00120 nval = cpl_frameset_get_size(*raw);
00121 if (nval < 1) {
00122 sinfo_extract_raw_frames_type(sof,raw,PRO_OBS_STD);
00123 }
00124 nval = cpl_frameset_get_size(*raw);
00125 if (nval < 1) {
00126 sinfo_extract_raw_frames_type(sof,raw,PRO_COADD_PSF);
00127 }
00128 nval = cpl_frameset_get_size(*raw);
00129 if (nval < 1) {
00130 sinfo_extract_raw_frames_type(sof,raw,PRO_OBS_PSF);
00131 }
00132 nval = cpl_frameset_get_size(*raw);
00133 if (nval < 1) {
00134 sinfo_extract_raw_frames_type(sof,raw,PRO_COADD_OBJ);
00135 }
00136 nval = cpl_frameset_get_size(*raw);
00137 if (nval < 1) {
00138 sinfo_extract_raw_frames_type(sof,raw,PRO_OBS_OBJ);
00139 }
00140 nval = cpl_frameset_get_size(*raw);
00141 if (nval < 1) {
00142 sinfo_msg_error("Too few (%d) raw frames "
00143 "(%s or %s or %s or %s or %s or %s ) "
00144 "present in frameset!Aborting...",nval,
00145 PRO_COADD_STD,PRO_OBS_STD,
00146 PRO_COADD_PSF,PRO_OBS_PSF,
00147 PRO_COADD_OBJ,PRO_OBS_OBJ);
00148 (*status)++;
00149 return;
00150 }
00151
00152
00153 cfg->inFrameList = cpl_malloc(nval * sizeof(char*));
00154
00155
00156 for (i=0 ; i<nval ; i++) {
00157 frame = cpl_frameset_get_frame(*raw,i);
00158 if(sinfo_file_exists((char*) cpl_frame_get_filename(frame))==1)
00159 {
00160
00161 cfg->inFrameList[i]=cpl_strdup(cpl_frame_get_filename(frame));
00162 }
00163 }
00164
00165
00166 cfg->nframes = nval ;
00167
00168 strcpy(cfg -> outName, STDSTAR_OUT_FILENAME);
00169
00170
00171
00172
00173
00174 frame = cpl_frameset_get_frame(*raw,0);
00175
00176 sinfo_get_spatial_res(frame,spat_res);
00177 switch(sinfo_frame_is_on(frame))
00178 {
00179
00180 case 0:
00181 strcpy(lamp_status,"on");
00182 break;
00183 case 1:
00184 strcpy(lamp_status,"off");
00185 break;
00186 case -1:
00187 strcpy(lamp_status,"undefined");
00188 break;
00189 default:
00190 strcpy(lamp_status,"undefined");
00191 break;
00192 }
00193 sinfo_get_band(frame,band);
00194 sinfo_msg("Spatial resolution: %s lamp_status: %s band: %s",
00195 spat_res, lamp_status, band);
00196
00197
00198 sinfo_get_ins_set(band,&ins_set);
00199 return ;
00200 }
00201
00202 static void
00203 parse_section_extraction(standstar_config * cfg,cpl_parameterlist* cpl_cfg)
00204 {
00205 cpl_parameter* p;
00206 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.low_rejection");
00207 cfg -> lo_reject = cpl_parameter_get_double(p);
00208
00209 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.high_rejection");
00210 cfg -> hi_reject = cpl_parameter_get_double(p);
00211
00212 cfg -> llx = 8;
00213 cfg -> lly = 8;
00214 cfg -> halfbox_x = 16;
00215 cfg -> halfbox_y = 16;
00216
00217 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.fwhm_factor");
00218 cfg -> fwhm_factor = cpl_parameter_get_double(p);
00219
00220 cfg -> backvariance = BKG_VARIANCE;
00221 cfg -> sky = SKY_FLUX;
00222 cfg -> gain = GAIN ;
00223
00224 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.conversion_index");
00225 cfg -> convInd = cpl_parameter_get_bool(p);
00226
00227 strcpy(cfg -> convName, STDSTAR_CONV_OUT_FILENAME);
00228
00229 cfg -> mag = 0;
00230
00231
00232 return ;
00233 }
00234
00235 void
00236 sinfo_stdstar_free(standstar_config ** cfg)
00237 {
00238 int i=0;
00239 if((*cfg) != NULL) {
00240 for (i=0 ; i<(*cfg)->nframes ; i++) {
00241 if((*cfg)->inFrameList[i] != NULL) {
00242 cpl_free((*cfg)->inFrameList[i]);
00243 (*cfg)->inFrameList[i]= NULL;
00244 }
00245 }
00246 cpl_free((*cfg)->inFrameList);
00247 (*cfg)->inFrameList=NULL;
00248 sinfo_standstar_cfg_destroy (*cfg);
00249 (*cfg) = NULL;
00250 }
00251 }