40 #include <irplib_utils.h>
42 #include <sinfo_tpl_utils.h>
43 #include <sinfo_pfits.h>
44 #include <sinfo_tpl_dfs.h>
45 #include <sinfo_key_names.h>
46 #include <sinfo_pro_types.h>
47 #include <sinfo_ref_types.h>
48 #include <sinfo_functions.h>
49 #include <sinfo_msg.h>
50 #include <sinfo_error.h>
51 #include <sinfo_utils_wrappers.h>
52 #include <sinfo_utl_efficiency.h>
58 static int sinfo_utl_eff_create(cpl_plugin *) ;
59 static int sinfo_utl_eff_exec(cpl_plugin *) ;
60 static int sinfo_utl_eff_destroy(cpl_plugin *) ;
61 static int sinfo_utl_eff(cpl_parameterlist *, cpl_frameset *) ;
67 static char sinfo_utl_eff_description[] =
68 "This recipe calculate a efficiency\n"
69 "esorex --params sinfo_utl_eff\n"
70 "esorex --help sinfo_utl_eff\n"
96 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe ) ;
97 cpl_plugin * plugin = &recipe->interface ;
99 cpl_plugin_init(plugin,
101 SINFONI_BINARY_VERSION,
102 CPL_PLUGIN_TYPE_RECIPE,
104 "Produce a table with efficiency",
105 sinfo_utl_eff_description,
109 sinfo_utl_eff_create,
111 sinfo_utl_eff_destroy) ;
113 cpl_pluginlist_append(list, plugin) ;
128 static int sinfo_utl_eff_create(cpl_plugin * plugin)
130 cpl_recipe * recipe ;
133 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
134 recipe = (cpl_recipe *)plugin ;
140 recipe->parameters = cpl_parameterlist_new() ;
156 static int sinfo_utl_eff_exec(cpl_plugin * plugin)
158 cpl_recipe * recipe ;
160 cpl_errorstate initial_errorstate = cpl_errorstate_get();
163 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
164 recipe = (cpl_recipe *)plugin ;
168 code = sinfo_utl_eff(recipe->parameters, recipe->frames) ;
171 if (!cpl_errorstate_is_equal(initial_errorstate)) {
174 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
187 static int sinfo_utl_eff_destroy(cpl_plugin * plugin)
189 cpl_recipe * recipe ;
192 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
193 recipe = (cpl_recipe *)plugin ;
196 cpl_parameterlist_delete(recipe->parameters) ;
209 sinfo_utl_eff( cpl_parameterlist * parlist,
210 cpl_frameset * framelist)
213 const char * name_o = NULL ;
215 cpl_frame* product_frame = 0;
216 cpl_propertylist * plist = NULL ;
219 cpl_frame* frm_sci=NULL;
220 cpl_frame* frm_atm_ext=NULL;
221 cpl_frame* frm_std_cat=NULL;
222 cpl_table* eff_tbl=NULL;
224 sinfo_msg(
"Welcome to SINFONI Pipeline release %d.%d.%d",
225 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
226 ck0(sinfo_dfs_set_groups(framelist),
"Cannot indentify RAW and CALIB frames");
229 check(plist=cpl_propertylist_new(),
"Cannot create a Property List");
233 name_o =
"eff_res.fits" ;
235 check_nomsg(frm_sci=cpl_frameset_find (framelist, PRO_STD_STAR_SPECTRA));
236 check_nomsg(frm_std_cat=cpl_frameset_find (framelist, FLUX_STD_CATALOG));
237 check_nomsg(frm_atm_ext=cpl_frameset_find (framelist, EXTCOEFF_TABLE));
238 sinfo_msg(
"frm_sci=%p frm_std=%p frm_atm_ext=%p",frm_sci,frm_std_cat,frm_atm_ext);
239 check_nomsg(eff_tbl=sinfo_efficiency_compute(frm_sci,frm_std_cat,frm_atm_ext));
240 npos = cpl_frameset_get_size(framelist);
241 for (pos = 0; pos < npos; pos++)
243 cpl_frame* pframe = cpl_frameset_get_frame(framelist, pos);
244 cpl_frame_group group = cpl_frame_get_group(pframe);
245 if (CPL_FRAME_GROUP_PRODUCT == group)
247 check_nomsg(cpl_frame_set_group (pframe, CPL_FRAME_GROUP_CALIB));
251 check_nomsg(product_frame = cpl_frame_new());
252 check_nomsg(cpl_frame_set_filename(product_frame, name_o)) ;
253 check_nomsg(cpl_frame_set_tag(product_frame,
"sinfo_efficiency" )) ;
254 check_nomsg(cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_TABLE)) ;
255 check_nomsg(cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT)) ;
256 check(cpl_frame_set_level(product_frame, CPL_FRAME_LEVEL_FINAL),
257 "Error while initialising the product frame") ;
260 check_nomsg(cpl_propertylist_erase_regexp(plist,
"^ESO PRO CATG",0));
262 check_nomsg(cpl_frameset_insert(framelist, product_frame)) ;
263 check(cpl_dfs_setup_product_header(plist,
269 KEY_VALUE_HPRO_DID,NULL),
270 "Problem in the product DFS-compliance") ;
271 sinfo_free_propertylist(&plist) ;
274 sinfo_free_propertylist(&plist) ;
275 return (cpl_error_get_code()) ? -1 : 0;
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
void irplib_reset(void)
Reset IRPLIB state.