00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "standstar_ini_by_cpl.h"
00018 #include "sinfoni_functions.h"
00019
00020
00021
00022
00023
00024
00025
00026 static void parse_section_frames(standstar_config *,cpl_frameset* sof, cpl_frameset** raw, int* status);
00027 static void parse_section_extraction(standstar_config *, cpl_parameterlist* cpl_cfg);
00028
00029
00030
00041
00042
00043 standstar_config * parse_cpl_input_standstar(cpl_parameterlist* cpl_cfg, cpl_frameset* sof, cpl_frameset** raw)
00044 {
00045
00046 const char * _id = "parse_cpl_input_standstar";
00047 standstar_config * cfg = standstar_cfg_create();
00048 int status=0;
00049
00050
00051
00052
00053 parse_section_extraction (cfg, cpl_cfg);
00054 parse_section_frames (cfg, sof, raw,&status);
00055 if (status > 0) {
00056 cpl_msg_error(_id,"parsing cpl input");
00057 standstar_cfg_destroy(cfg);
00058 cfg = NULL ;
00059 return NULL ;
00060 }
00061 return cfg ;
00062 }
00063
00064 static void
00065 parse_section_frames(standstar_config * cfg,
00066 cpl_frameset* sof,
00067 cpl_frameset** raw,
00068 int* status)
00069 {
00070 const char * _id = "parse_section_frames";
00071 int i;
00072 int nval ;
00073 cpl_frame* frame=NULL;
00074 char spat_res[FILE_NAME_SZ];
00075 char lamp_status[FILE_NAME_SZ];
00076 char band[FILE_NAME_SZ];
00077 int ins_set=0;
00078
00079
00080
00081 sinfoni_extract_raw_frames_type(sof,raw,PRO_COADD_STD);
00082 nval = cpl_frameset_get_size(*raw);
00083 if (nval < 1) {
00084 cpl_msg_error(_id,"Too few (%d) raw frames (%s) present in"
00085 "frameset!Aborting...",nval,PRO_COADD_STD);
00086 (*status)++;
00087 return;
00088 }
00089
00090
00091 cfg->inFrameList = cpl_malloc(nval * sizeof(char*));
00092
00093
00094 for (i=0 ; i<nval ; i++) {
00095 frame = cpl_frameset_get_frame(*raw,i);
00096
00097
00098 if(file_exists((char*) cpl_frame_get_filename(frame))==1)
00099 {
00100
00101 cfg->inFrameList[i]=cpl_strdup(cpl_frame_get_filename(frame));
00102 }
00103 }
00104
00105
00106 cfg->nframes = nval ;
00107
00108 strcpy(cfg -> outName, STDSTAR_OUT_FILENAME);
00109
00110
00111
00112
00113
00114 frame = cpl_frameset_get_frame(*raw,0);
00115
00116 sinfoni_get_spatial_res(frame,spat_res);
00117 switch(sinfoni_frame_is_on(frame))
00118 {
00119
00120 case 0:
00121 strcpy(lamp_status,"on");
00122 break;
00123 case 1:
00124 strcpy(lamp_status,"off");
00125 break;
00126 case -1:
00127 strcpy(lamp_status,"undefined");
00128 break;
00129 default:
00130 strcpy(lamp_status,"undefined");
00131 break;
00132 }
00133 sinfoni_get_band(frame,band);
00134 cpl_msg_info(_id,"stat_res: %s lamp_status: %s band: %s",
00135 spat_res, lamp_status, band);
00136
00137
00138 sinfoni_get_ins_set(band,&ins_set);
00139 return ;
00140 }
00141
00142 static void
00143 parse_section_extraction(standstar_config * cfg,cpl_parameterlist* cpl_cfg)
00144 {
00145 cpl_parameter* p;
00146 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.low_rejection");
00147 cfg -> lo_reject = cpl_parameter_get_double(p);
00148
00149 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.high_rejection");
00150 cfg -> hi_reject = cpl_parameter_get_double(p);
00151
00152 cfg -> llx = 8;
00153 cfg -> lly = 8;
00154 cfg -> halfbox_x = 16;
00155 cfg -> halfbox_y = 16;
00156
00157 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.fwhm_factor");
00158 cfg -> fwhm_factor = cpl_parameter_get_double(p);
00159
00160 cfg -> backvariance = BKG_VARIANCE;
00161 cfg -> sky = SKY_FLUX;
00162 cfg -> gain = GAIN ;
00163
00164 p = cpl_parameterlist_find(cpl_cfg, "sinfoni.std_star.conversion_index");
00165 cfg -> convInd = cpl_parameter_get_bool(p);
00166
00167 strcpy(cfg -> convName, STDSTAR_CONV_OUT_FILENAME);
00168
00169 cfg -> mag = 0;
00170
00171
00172 return ;
00173 }
00174
00175 void
00176 stdstar_free(standstar_config * cfg)
00177 {
00178 int i=0;
00179 for (i=0 ; i<cfg->nframes ; i++) {
00180 cpl_free(cfg->inFrameList[i]);
00181 }
00182 cpl_free(cfg->inFrameList);
00183 standstar_cfg_destroy (cfg);
00184 }