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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifdef HAVE_CONFIG_H
00050 #include <config.h>
00051 #endif
00052
00053
00054
00055
00056 #include <string.h>
00057
00058
00059 #include <cpl.h>
00060
00061
00062 #include <irplib_utils.h>
00063
00064 #include <sinfo_tpl_utils.h>
00065 #include <sinfo_pfits.h>
00066 #include <sinfo_tpl_dfs.h>
00067 #include <sinfo_key_names.h>
00068 #include <sinfo_pro_types.h>
00069 #include <sinfo_ref_types.h>
00070 #include <sinfo_functions.h>
00071 #include <sinfo_msg.h>
00072 #include <sinfo_error.h>
00073 #include <sinfo_utils_wrappers.h>
00074 #include <sinfo_utl_efficiency.h>
00075
00076
00077
00078
00079
00080 static int sinfo_utl_eff_create(cpl_plugin *) ;
00081 static int sinfo_utl_eff_exec(cpl_plugin *) ;
00082 static int sinfo_utl_eff_destroy(cpl_plugin *) ;
00083 static int sinfo_utl_eff(cpl_parameterlist *, cpl_frameset *) ;
00084
00085
00086
00087
00088
00089 static char sinfo_utl_eff_description[] =
00090 "This recipe calculate a efficiency\n"
00091 "esorex --params sinfo_utl_eff\n"
00092 "esorex --help sinfo_utl_eff\n"
00093 "\n";
00094
00095
00096
00097
00098
00099
00100
00104
00105
00107
00115
00116 int cpl_plugin_get_info(cpl_pluginlist * list)
00117 {
00118 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00119 cpl_plugin * plugin = &recipe->interface ;
00120
00121 cpl_plugin_init(plugin,
00122 CPL_PLUGIN_API,
00123 SINFONI_BINARY_VERSION,
00124 CPL_PLUGIN_TYPE_RECIPE,
00125 "sinfo_utl_eff",
00126 "Produce a table with efficiency",
00127 sinfo_utl_eff_description,
00128 "Konstantin Mirny",
00129 "kmirny@eso.org",
00130 sinfo_get_license(),
00131 sinfo_utl_eff_create,
00132 sinfo_utl_eff_exec,
00133 sinfo_utl_eff_destroy) ;
00134
00135 cpl_pluginlist_append(list, plugin) ;
00136
00137 return 0;
00138 }
00139
00140
00149
00150 static int sinfo_utl_eff_create(cpl_plugin * plugin)
00151 {
00152 cpl_recipe * recipe ;
00153
00154
00155 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00156 recipe = (cpl_recipe *)plugin ;
00157 else return -1 ;
00158 cpl_error_reset();
00159 irplib_reset();
00160
00161
00162 recipe->parameters = cpl_parameterlist_new() ;
00163
00164
00165
00166
00167
00168 return 0;
00169 }
00170
00171
00177
00178 static int sinfo_utl_eff_exec(cpl_plugin * plugin)
00179 {
00180 cpl_recipe * recipe ;
00181 int code=0;
00182 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00183
00184
00185 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00186 recipe = (cpl_recipe *)plugin ;
00187 else return -1 ;
00188 cpl_error_reset();
00189 irplib_reset();
00190 code = sinfo_utl_eff(recipe->parameters, recipe->frames) ;
00191
00192
00193 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00194
00195
00196 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00197 }
00198
00199 return code ;
00200 }
00201
00202
00208
00209 static int sinfo_utl_eff_destroy(cpl_plugin * plugin)
00210 {
00211 cpl_recipe * recipe ;
00212
00213
00214 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00215 recipe = (cpl_recipe *)plugin ;
00216 else return -1 ;
00217
00218 cpl_parameterlist_delete(recipe->parameters) ;
00219 return 0 ;
00220 }
00221
00222
00229
00230 static int
00231 sinfo_utl_eff( cpl_parameterlist * parlist,
00232 cpl_frameset * framelist)
00233 {
00234
00235 const char * name_o = NULL ;
00236
00237 cpl_frame* product_frame = 0;
00238 cpl_propertylist * plist = NULL ;
00239 int pos = 0;
00240 int npos = 0;
00241 cpl_frame* frm_sci=NULL;
00242 cpl_frame* frm_atm_ext=NULL;
00243 cpl_frame* frm_std_cat=NULL;
00244 cpl_table* eff_tbl=NULL;
00245
00246 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00247 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00248 ck0(sinfo_dfs_set_groups(framelist),"Cannot indentify RAW and CALIB frames");
00249
00250
00251 check(plist=cpl_propertylist_new(),"Cannot create a Property List");
00252
00253
00254
00255 name_o = "eff_res.fits" ;
00256
00257 check_nomsg(frm_sci=cpl_frameset_find (framelist, PRO_STD_STAR_SPECTRA));
00258 check_nomsg(frm_std_cat=cpl_frameset_find (framelist, FLUX_STD_CATALOG));
00259 check_nomsg(frm_atm_ext=cpl_frameset_find (framelist, EXTCOEFF_TABLE));
00260 sinfo_msg("frm_sci=%p frm_std=%p frm_atm_ext=%p",frm_sci,frm_std_cat,frm_atm_ext);
00261 check_nomsg(eff_tbl=sinfo_efficiency_compute(frm_sci,frm_std_cat,frm_atm_ext));
00262 npos = cpl_frameset_get_size(framelist);
00263 for (pos = 0; pos < npos; pos++)
00264 {
00265 cpl_frame* pframe = cpl_frameset_get_frame(framelist, pos);
00266 cpl_frame_group group = cpl_frame_get_group(pframe);
00267 if (CPL_FRAME_GROUP_PRODUCT == group)
00268 {
00269 check_nomsg(cpl_frame_set_group (pframe, CPL_FRAME_GROUP_CALIB));
00270 }
00271 }
00272
00273 check_nomsg(product_frame = cpl_frame_new());
00274 check_nomsg(cpl_frame_set_filename(product_frame, name_o)) ;
00275 check_nomsg(cpl_frame_set_tag(product_frame,"sinfo_efficiency" )) ;
00276 check_nomsg(cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_TABLE)) ;
00277 check_nomsg(cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT)) ;
00278 check(cpl_frame_set_level(product_frame, CPL_FRAME_LEVEL_FINAL),
00279 "Error while initialising the product frame") ;
00280
00281
00282 check_nomsg(cpl_propertylist_erase_regexp(plist, "^ESO PRO CATG",0));
00283
00284 check_nomsg(cpl_frameset_insert(framelist, product_frame)) ;
00285 check(cpl_dfs_setup_product_header(plist,
00286 product_frame,
00287 framelist,
00288 parlist,
00289 "sinfo_utl_eff",
00290 "SINFONI",
00291 KEY_VALUE_HPRO_DID,NULL),
00292 "Problem in the product DFS-compliance") ;
00293 sinfo_free_propertylist(&plist) ;
00294
00295 cleanup:
00296 sinfo_free_propertylist(&plist) ;
00297 return (cpl_error_get_code()) ? -1 : 0;
00298 }