62 const int num_ph,
const int sky)
67 struct xs_3* p_xs_3_config=NULL;
68 struct xs_3 xs_3_config;
69 const char* line_list=NULL;
70 cpl_frame* THE_frm=NULL;
72 char THE_filename[256];
74 const char* pro_catg=NULL;
75 cpl_propertylist* plist=NULL;
77 const char* seq_arm=NULL;
79 int* pslit_index=NULL;
83 p_xs_3_config=&xs_3_config;
87 cpl_frame_get_filename(config_frame)) ;
110 check(line_list=cpl_frame_get_filename(wave_list));
127 sprintf(THE_filename,
"%s%s",pro_catg,
".fits");
131 num_ph,-1,THE_filename));
133 check(plist=cpl_propertylist_load(THE_filename,0));
134 check(tab=cpl_table_load(THE_filename,1,0));
154 cpl_propertylist_append_string(plist,
XSH_SEQ_ARM,seq_arm);
160 check(cpl_table_save(tab,plist,NULL,THE_filename,CPL_IO_DEFAULT));
164 check(cpl_frame_set_filename(THE_frm,THE_filename));
167 CPL_FRAME_GROUP_PRODUCT,CPL_FRAME_LEVEL_FINAL,
171 check(tab=cpl_table_load(THE_filename,1,0));
172 check(plist=cpl_propertylist_load(THE_filename,0));
173 pslit_index=cpl_table_get_data_int(tab,
"slit_index");
174 for(i=0;i<cpl_table_get_nrow(tab);i++){
177 check(cpl_table_save(tab,plist,NULL,THE_filename,CPL_IO_DEFAULT));
181 xsh_msg(
"model THE table corresponding to optimized configuration %s %s",
182 cpl_frame_get_filename(THE_frm),
183 cpl_frame_get_tag(THE_frm));
191 if(cpl_error_get_code() == CPL_ERROR_NONE) {
213 cpl_frame* ref_frame,
216 double zeroK=-273.15;
217 const char* ref_name=NULL;
218 cpl_propertylist* ref_head=NULL;
219 check(ref_name=cpl_frame_get_filename(ref_frame));
220 check(ref_head=cpl_propertylist_load(ref_name,0));
242 return cpl_error_get_code();
255 cpl_frame* ref_frame,
259 double zeroK=-273.15;
260 const char* cfg_name=NULL;
261 const char* ref_name=NULL;
262 cpl_table* cfg_tab=NULL;
263 cpl_propertylist* cfg_head=NULL;
264 cpl_propertylist* ref_head=NULL;
266 double old_focu1enc=0.0;
271 char local_cfg_name[256];
278 check(cfg_name=cpl_frame_get_filename(*model_config_frame));
279 check(ref_name=cpl_frame_get_filename(ref_frame));
280 check(ref_head=cpl_propertylist_load(ref_name,0));
282 check(cfg_tab=cpl_table_load(cfg_name,1,0));
283 check(cfg_head=cpl_propertylist_load(cfg_name,0));
284 sprintf(local_cfg_name,
"local_cfg_name_%s.fits",
288 check(old_fdet=cpl_table_get_double(cfg_tab,
"Best_Guess",36,NULL));
291 if(cpl_error_get_code() != CPL_ERROR_NONE) {
298 xsh_msg(
"XSH_FOCU1ENC_VAL =%f ( %f )",focu1enc,old_fdet+(focu1enc-old_focu1enc)*0.00034065216);
301 check(cpl_table_set_double(cfg_tab,
"Best_Guess",36,old_fdet+(focu1enc-old_focu1enc)*0.00034065216));
306 if(cpl_error_get_code() != CPL_ERROR_NONE) {
313 xsh_msg(
"XSH_TEMP5_VAL=%f [C]",temp5);
315 check(cpl_table_set_double(cfg_tab,
"Best_Guess",1,temp5-zeroK));
319 if(cpl_error_get_code() != CPL_ERROR_NONE) {
326 xsh_msg(
"XSH_TEMP2_VAL=%f [C]",temp2);
328 check(cpl_table_set_double(cfg_tab,
"Best_Guess",1,temp2-zeroK));
333 if(cpl_error_get_code() != CPL_ERROR_NONE || temp82 >200.0) {
341 xsh_msg(
"XSH_TEMP82_VAL=%f [K]",temp82);
343 check(cpl_table_set_double(cfg_tab,
"Best_Guess",1,temp82));
344 check(cpl_table_set_double(cfg_tab,
"Best_Guess",2,temp82));
345 check(cpl_table_set_double(cfg_tab,
"Best_Guess",3,temp82));
347 check(cpl_table_save(cfg_tab, cfg_head, NULL, local_cfg_name, CPL_IO_DEFAULT));
348 cpl_frame_set_filename(*model_config_frame,local_cfg_name);
356 return cpl_error_get_code();
static xsh_instrument * instrument
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
cpl_error_code xsh_model_config_load_best(cpl_frame *config_frame, xsh_xs_3 *p_xs_3)
Load the config model table and fill the struct.
void xsh_model_binxy(xsh_xs_3 *p_xs_3, int bin_X, int bin_Y)
corrects model for detector's binning
cpl_frame * xsh_model_THE_create(xsh_xs_3 *p_xs_3, xsh_instrument *instr, const char *line_list, int num_ph, double sep_ph, const char *THE_filename)
Compute the THE table (centroid for each feature in lamp spectrum)
#define xsh_msg_warning(...)
Print an warning message.
#define xsh_msg_error(...)
Print an error message.
#define xsh_msg(...)
Print a message on info level.
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
double xsh_pfits_get_temp5(const cpl_propertylist *plist)
find out the temp5 (VIS prism)
double xsh_pfits_get_temp2(const cpl_propertylist *plist)
find out the temp2 (UVB prism)
int xsh_pfits_get_FOCU1ENC(const cpl_propertylist *plist)
find out the FOCU1 POS (UVB prism auto-focus temperature)
double xsh_pfits_get_temp82(const cpl_propertylist *plist)
find out the temp82 (NIR prisms)
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
int xsh_print_rec_status(const int val)
Check if an error has happened and returns error kind and location.
void xsh_frame_config(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level, cpl_frame **frame)
Define a frame characteristics.
#define XSH_THEO_TAB_SING
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_THEO_TAB_MULT
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
cpl_error_code xsh_model_temperature_update_structure(struct xs_3 *p_xs_3_config, cpl_frame *ref_frame, xsh_instrument *instrument)
cpl_frame * xsh_util_physmod_model_THE_create(cpl_frame *config_frame, xsh_instrument *instrument, cpl_frame *wave_list, const int binx, const int biny, const int num_ph, const int sky)