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