67"This recipe is used to generate the model configuration file.\n"
68"The sof file contains the names of the input ASCII file\n"
70"The ASCII file must contain five columns:\n"
71"1st: The best guess value\n"
73"3th: The high limit\n"
74"4th: The Flag to recompute or not\n"
75"5th: Name of the Parameter\n"
76"The ASCII files are in the catalogs/ directory of the XSH distribution.\n"
77"This recipe produces 1 file:\n"
78"First product: the table with the configuration for the model.\n"
79" (PRO CATG = XSH_MOD_CFG_TAB_ARM)\n" ;
96 cpl_recipe * recipe = cpl_calloc(1,
sizeof(*recipe));
97 cpl_plugin * plugin = &recipe->interface;
99 cpl_plugin_init(plugin,
102 CPL_PLUGIN_TYPE_RECIPE,
103 "xsh_util_genconfig",
104 "Generate spectrum calibration FITS tables",
113 cpl_pluginlist_append(list, plugin);
130 cpl_recipe * recipe ;
133 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
134 recipe = (cpl_recipe *)plugin ;
138 recipe->parameters = cpl_parameterlist_new() ;
152 cpl_recipe * recipe ;
155 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
156 recipe = (cpl_recipe *)plugin ;
171 cpl_recipe * recipe ;
174 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
175 recipe = (cpl_recipe *)plugin ;
178 cpl_parameterlist_delete(recipe->parameters) ;
192 cpl_parameterlist * parlist,
193 cpl_frameset * framelist)
197 cpl_frame * cur_frame ;
198 const char * cur_fname ;
201 double best, low, high ;
213 cur_frame = cpl_frameset_get_frame(framelist, 0) ;
214 cur_fname = cpl_frame_get_filename(cur_frame) ;
217 if ((in = fopen(cur_fname,
"r")) == NULL) {
218 cpl_msg_error(__func__,
"Could not open %s", cur_fname) ;
224 while (fgets(line, 1024, in) != NULL) {
227 if (line[0] !=
'#' && sscanf(line,
"%64lg %64lg %64lg %64d %1023s",
228 &best, &low, &high, &flag, name) == 5) nentries++ ;
231 cpl_msg_error(__func__,
"No valid entry in the file") ;
237 tab = cpl_table_new(nentries) ;
247 while (fgets(line, 1024, in) != NULL) {
248 if (line[0] !=
'#' && sscanf(line,
"%64lg %64lg %64lg %64d %1023s",
249 &best, &low, &high, &flag, name) == 5) {
261 cpl_msg_info(__func__,
"Saving the table with %d rows", nentries) ;
263 cpl_msg_error(__func__,
"Cannot write the table") ;
264 cpl_table_delete(tab) ;
267 cpl_table_delete(tab) ;
281 cpl_table * out_table,
282 cpl_parameterlist * parlist,
286 cpl_propertylist * plist ;
287 cpl_frame * product_frame ;
295 sprintf(name_o,
"xsh_util_genconfig_save.fits") ;
296 cpl_msg_info(__func__,
"Writing %s" , name_o) ;
299 plist = cpl_propertylist_new();
300 cpl_propertylist_append_string(plist,
"INSTRUME",
"XSH") ;
303 product_frame = cpl_frame_new() ;
304 cpl_frame_set_filename(product_frame, name_o) ;
306 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_TABLE);
307 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
308 cpl_frame_set_level(product_frame, CPL_FRAME_LEVEL_FINAL);
311 if (cpl_dfs_setup_product_header(plist, product_frame, set, parlist,
312 "xsh_util_genconfig", PACKAGE
"/" PACKAGE_VERSION,
313 "PRO-1.15",NULL)!=CPL_ERROR_NONE) {
314 cpl_msg_warning(__func__,
"Problem in the product DFS-compliance") ;
319 if (cpl_table_save(out_table, plist, NULL, name_o,
320 CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
321 cpl_msg_error(__func__,
"Cannot save the product");
322 cpl_frame_delete(product_frame) ;
323 cpl_propertylist_delete(plist) ;
326 cpl_propertylist_delete(plist) ;
329 cpl_frameset_insert(set, product_frame);
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_util_genconfig_save(cpl_table *, cpl_parameterlist *, cpl_frameset *)
Save the product of the recipe.
static char xsh_util_genconfig_description[]
static int xsh_util_genconfig_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static int xsh_util_genconfig_create(cpl_plugin *)
Setup the recipe options
static int xsh_util_genconfig(cpl_parameterlist *, cpl_frameset *)
The FITS file creation occurs here.
static int xsh_util_genconfig_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
const char * xsh_get_license(void)
Get the pipeline copyright and license.
#define XSH_UTIL_GENCONFIG_RAW
#define XSH_COL_MODEL_CONF_HIGH
#define XSH_COL_MODEL_CONF_BEST
#define XSH_COL_MODEL_CONF_LOW
#define XSH_COL_MODEL_CONF_NAME
#define XSH_COL_MODEL_CONF_FLAG