35 #include "muse_scipost_combine_pixtables_z.h"
52 static const char *muse_scipost_combine_pixtables_help =
53 "Sort pixel tables by exposure and combine them with applied weights into one big pixel table. This is a task separated from muse_scipost.";
55 static const char *muse_scipost_combine_pixtables_help_esorex =
56 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
57 "\n Frame tag Type Req #Fr Description"
58 "\n -------------------- ---- --- --- ------------"
59 "\n PIXTABLE_OBJECT raw Y Input pixel tables"
60 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
61 "\n Frame tag Level Description"
62 "\n -------------------- -------- ------------"
63 "\n PIXTABLE_COMBINED intermed Combined pixel table";
74 static cpl_recipeconfig *
75 muse_scipost_combine_pixtables_new_recipeconfig(
void)
77 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
80 tag =
"PIXTABLE_OBJECT";
81 cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
82 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_COMBINED");
99 muse_scipost_combine_pixtables_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
101 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
102 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
103 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
105 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
106 return CPL_ERROR_ILLEGAL_INPUT;
108 return CPL_ERROR_NONE;
121 static cpl_frame_level
122 muse_scipost_combine_pixtables_get_frame_level(
const char *aFrametag)
125 return CPL_FRAME_LEVEL_NONE;
127 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
128 return CPL_FRAME_LEVEL_INTERMEDIATE;
130 return CPL_FRAME_LEVEL_NONE;
144 muse_scipost_combine_pixtables_get_frame_mode(
const char *aFrametag)
149 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
167 muse_scipost_combine_pixtables_create(cpl_plugin *aPlugin)
171 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
172 recipe = (cpl_recipe *)aPlugin;
180 muse_scipost_combine_pixtables_new_recipeconfig(),
181 muse_scipost_combine_pixtables_prepare_header,
182 muse_scipost_combine_pixtables_get_frame_level,
183 muse_scipost_combine_pixtables_get_frame_mode);
188 cpl_msg_set_time_on();
192 recipe->parameters = cpl_parameterlist_new();
197 p = cpl_parameter_new_value(
"muse.muse_scipost_combine_pixtables.lambdamin",
199 "Cut off the data below this wavelength after loading the pixel table(s).",
200 "muse.muse_scipost_combine_pixtables",
202 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
203 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
205 cpl_parameterlist_append(recipe->parameters, p);
208 p = cpl_parameter_new_value(
"muse.muse_scipost_combine_pixtables.lambdamax",
210 "Cut off the data above this wavelength after loading the pixel table(s).",
211 "muse.muse_scipost_combine_pixtables",
213 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
214 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
216 cpl_parameterlist_append(recipe->parameters, p);
219 p = cpl_parameter_new_enum(
"muse.muse_scipost_combine_pixtables.weight",
221 "Type of weighting scheme to use when combining multiple exposures.",
222 "muse.muse_scipost_combine_pixtables",
223 (
const char *)
"exptime",
225 (
const char *)
"exptime",
226 (
const char *)
"fwhm");
227 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"weight");
228 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"weight");
230 cpl_parameterlist_append(recipe->parameters, p);
250 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
251 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
254 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.lambdamin");
255 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
256 aParams->
lambdamin = cpl_parameter_get_double(p);
258 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.lambdamax");
259 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
260 aParams->
lambdamax = cpl_parameter_get_double(p);
262 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.weight");
263 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
264 aParams->
weight_s = cpl_parameter_get_string(p);
266 (!strcasecmp(aParams->
weight_s,
"exptime")) ? MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_EXPTIME :
267 (!strcasecmp(aParams->
weight_s,
"fwhm")) ? MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_FWHM :
268 MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_INVALID_VALUE;
269 cpl_ensure_code(aParams->
weight != MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_INVALID_VALUE,
270 CPL_ERROR_ILLEGAL_INPUT);
284 muse_scipost_combine_pixtables_exec(cpl_plugin *aPlugin)
286 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
289 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
290 cpl_msg_set_threadid_on();
292 cpl_frameset *usedframes = cpl_frameset_new(),
293 *outframes = cpl_frameset_new();
295 muse_scipost_combine_pixtables_params_fill(¶ms, recipe->parameters);
297 cpl_errorstate prestate = cpl_errorstate_get();
301 int rc = muse_scipost_combine_pixtables_compute(proc, ¶ms);
302 cpl_frameset_join(usedframes, proc->
usedFrames);
306 if (!cpl_errorstate_is_equal(prestate)) {
310 cpl_msg_set_level(CPL_MSG_INFO);
320 cpl_frameset_join(recipe->frames, usedframes);
321 cpl_frameset_join(recipe->frames, outframes);
322 cpl_frameset_delete(usedframes);
323 cpl_frameset_delete(outframes);
336 muse_scipost_combine_pixtables_destroy(cpl_plugin *aPlugin)
340 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
341 recipe = (cpl_recipe *)aPlugin;
347 cpl_parameterlist_delete(recipe->parameters);
364 cpl_plugin_get_info(cpl_pluginlist *aList)
366 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
367 cpl_plugin *plugin = &recipe->interface;
371 helptext = cpl_sprintf(
"%s%s", muse_scipost_combine_pixtables_help,
372 muse_scipost_combine_pixtables_help_esorex);
374 helptext = cpl_sprintf(
"%s", muse_scipost_combine_pixtables_help);
378 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
379 CPL_PLUGIN_TYPE_RECIPE,
380 "muse_scipost_combine_pixtables",
381 "Combine MUSE pixel tables, either from different IFUs, or from different exposures, or both.",
386 muse_scipost_combine_pixtables_create,
387 muse_scipost_combine_pixtables_exec,
388 muse_scipost_combine_pixtables_destroy);
389 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
Structure to hold the parameters of the muse_scipost_combine_pixtables recipe.
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. (as string)
const char * muse_get_license(void)
Get the pipeline copyright and license.
muse_processing * muse_processing_new(const char *aRecipeName, cpl_recipe *aRecipe)
Create a new processing structure.
int weight
Type of weighting scheme to use when combining multiple exposures.
cpl_frameset * outputFrames
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.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
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.
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.
cpl_frameset * usedFrames