35 #include "muse_scipost_calibrate_flux_z.h" 49 static const char *muse_scipost_calibrate_flux_help =
50 "Replace the intensity in the MUSE pixel tables by the absolute flux. This is a task separated from muse_scipost.";
52 static const char *muse_scipost_calibrate_flux_help_esorex =
53 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n" 54 "\n Frame tag Type Req #Fr Description" 55 "\n -------------------- ---- --- --- ------------" 56 "\n PIXTABLE_OBJECT raw Y Pixel table without flux calibration" 57 "\n EXTINCT_TABLE calib Y 1 Atmospheric extinction table" 58 "\n STD_RESPONSE calib Y 1 Response curve as derived from standard star(s)" 59 "\n STD_TELLURIC calib . 1 Telluric absorption correction as derived from standard star(s)" 60 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n" 61 "\n Frame tag Level Description" 62 "\n -------------------- -------- ------------" 63 "\n PIXTABLE_OBJECT final Flux calibrated pixel table";
74 static cpl_recipeconfig *
75 muse_scipost_calibrate_flux_new_recipeconfig(
void)
77 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
79 cpl_recipeconfig_set_tag(recipeconfig,
"PIXTABLE_OBJECT", 1, -1);
80 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"EXTINCT_TABLE", 1, 1);
81 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"STD_RESPONSE", 1, 1);
82 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"STD_TELLURIC", -1, 1);
83 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_OBJECT",
"PIXTABLE_OBJECT");
100 muse_scipost_calibrate_flux_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
102 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
103 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
104 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
106 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
107 return CPL_ERROR_ILLEGAL_INPUT;
109 return CPL_ERROR_NONE;
122 static cpl_frame_level
123 muse_scipost_calibrate_flux_get_frame_level(
const char *aFrametag)
126 return CPL_FRAME_LEVEL_NONE;
128 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
129 return CPL_FRAME_LEVEL_FINAL;
131 return CPL_FRAME_LEVEL_NONE;
145 muse_scipost_calibrate_flux_get_frame_mode(
const char *aFrametag)
150 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
168 muse_scipost_calibrate_flux_create(cpl_plugin *aPlugin)
172 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
173 recipe = (cpl_recipe *)aPlugin;
181 muse_scipost_calibrate_flux_new_recipeconfig(),
182 muse_scipost_calibrate_flux_prepare_header,
183 muse_scipost_calibrate_flux_get_frame_level,
184 muse_scipost_calibrate_flux_get_frame_mode);
189 cpl_msg_set_time_on();
193 recipe->parameters = cpl_parameterlist_new();
198 p = cpl_parameter_new_value(
"muse.muse_scipost_calibrate_flux.lambdamin",
200 "Cut off the data below this wavelength after loading the pixel table(s).",
201 "muse.muse_scipost_calibrate_flux",
203 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
204 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
206 cpl_parameterlist_append(recipe->parameters, p);
209 p = cpl_parameter_new_value(
"muse.muse_scipost_calibrate_flux.lambdamax",
211 "Cut off the data above this wavelength after loading the pixel table(s).",
212 "muse.muse_scipost_calibrate_flux",
214 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
215 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
217 cpl_parameterlist_append(recipe->parameters, p);
237 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
238 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
241 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_calibrate_flux.lambdamin");
242 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
243 aParams->
lambdamin = cpl_parameter_get_double(p);
245 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_calibrate_flux.lambdamax");
246 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
247 aParams->
lambdamax = cpl_parameter_get_double(p);
261 muse_scipost_calibrate_flux_exec(cpl_plugin *aPlugin)
263 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
267 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
268 cpl_msg_set_threadid_on();
270 cpl_frameset *usedframes = cpl_frameset_new(),
271 *outframes = cpl_frameset_new();
273 muse_scipost_calibrate_flux_params_fill(¶ms, recipe->parameters);
275 cpl_errorstate prestate = cpl_errorstate_get();
279 int rc = muse_scipost_calibrate_flux_compute(proc, ¶ms);
280 cpl_frameset_join(usedframes, proc->
usedframes);
281 cpl_frameset_join(outframes, proc->
outframes);
284 if (!cpl_errorstate_is_equal(prestate)) {
288 cpl_msg_set_level(CPL_MSG_INFO);
299 cpl_frameset_join(recipe->frames, usedframes);
300 cpl_frameset_join(recipe->frames, outframes);
301 cpl_frameset_delete(usedframes);
302 cpl_frameset_delete(outframes);
315 muse_scipost_calibrate_flux_destroy(cpl_plugin *aPlugin)
319 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
320 recipe = (cpl_recipe *)aPlugin;
326 cpl_parameterlist_delete(recipe->parameters);
343 cpl_plugin_get_info(cpl_pluginlist *aList)
345 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
346 cpl_plugin *plugin = &recipe->interface;
350 helptext = cpl_sprintf(
"%s%s", muse_scipost_calibrate_flux_help,
351 muse_scipost_calibrate_flux_help_esorex);
353 helptext = cpl_sprintf(
"%s", muse_scipost_calibrate_flux_help);
357 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
358 CPL_PLUGIN_TYPE_RECIPE,
359 "muse_scipost_calibrate_flux",
360 "Calibrate flux for MUSE pixel tables.",
365 muse_scipost_calibrate_flux_create,
366 muse_scipost_calibrate_flux_exec,
367 muse_scipost_calibrate_flux_destroy);
368 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
cpl_frameset * usedframes
muse_processing * muse_processing_new(const char *aName, cpl_recipe *aRecipe)
Create a new processing structure.
const char * muse_get_license(void)
Get the pipeline copyright and license.
void muse_cplerrorstate_dump_some(unsigned aCurrent, unsigned aFirst, unsigned aLast)
Dump some CPL errors.
void muse_processinginfo_delete(cpl_recipe *)
Clear all information from the processing info and from the recipe config.
cpl_error_code muse_cplframeset_erase_duplicate(cpl_frameset *aFrames)
Erase all duplicate frames from a frameset.
cpl_error_code muse_cplframeset_erase_all(cpl_frameset *aFrames)
Erase all frames in a frameset.
Structure to hold the parameters of the muse_scipost_calibrate_flux recipe.
void muse_processinginfo_register(cpl_recipe *, cpl_recipeconfig *, muse_processing_prepare_header_func *, muse_processing_get_frame_level_func *, muse_processing_get_frame_mode_func *)
Register extended functionalities for MUSE recipes.
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
void muse_processing_recipeinfo(cpl_plugin *)
Output main pipeline configuration, inputs, and parameters.