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 OFFSET_LIST calib . 1 List of coordinate offsets (and optional flux scale factors)" 61 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n" 62 "\n Frame tag Level Description" 63 "\n -------------------- -------- ------------" 64 "\n PIXTABLE_COMBINED intermed Combined pixel table";
75 static cpl_recipeconfig *
76 muse_scipost_combine_pixtables_new_recipeconfig(
void)
78 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
80 cpl_recipeconfig_set_tag(recipeconfig,
"PIXTABLE_OBJECT", 1, -1);
81 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"OFFSET_LIST", -1, 1);
82 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_OBJECT",
"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. \"exptime\" just uses the exposure time to weight the exposures, \"fwhm\" uses the DIMM information in the header as well, \"none\" preserves an existing weight column in the input pixel tables without changes.",
222 "muse.muse_scipost_combine_pixtables",
223 (
const char *)
"exptime",
225 (
const char *)
"exptime",
226 (
const char *)
"fwhm",
227 (
const char *)
"none");
228 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"weight");
229 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"weight");
231 cpl_parameterlist_append(recipe->parameters, p);
251 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
252 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
255 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.lambdamin");
256 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
257 aParams->
lambdamin = cpl_parameter_get_double(p);
259 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.lambdamax");
260 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
261 aParams->
lambdamax = cpl_parameter_get_double(p);
263 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_combine_pixtables.weight");
264 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
265 aParams->
weight_s = cpl_parameter_get_string(p);
267 (!strcasecmp(aParams->
weight_s,
"exptime")) ? MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_EXPTIME :
268 (!strcasecmp(aParams->
weight_s,
"fwhm")) ? MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_FWHM :
269 (!strcasecmp(aParams->
weight_s,
"none")) ? MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_NONE :
270 MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_INVALID_VALUE;
271 cpl_ensure_code(aParams->
weight != MUSE_SCIPOST_COMBINE_PIXTABLES_PARAM_WEIGHT_INVALID_VALUE,
272 CPL_ERROR_ILLEGAL_INPUT);
286 muse_scipost_combine_pixtables_exec(cpl_plugin *aPlugin)
288 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
292 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
293 cpl_msg_set_threadid_on();
295 cpl_frameset *usedframes = cpl_frameset_new(),
296 *outframes = cpl_frameset_new();
298 muse_scipost_combine_pixtables_params_fill(¶ms, recipe->parameters);
300 cpl_errorstate prestate = cpl_errorstate_get();
304 int rc = muse_scipost_combine_pixtables_compute(proc, ¶ms);
305 cpl_frameset_join(usedframes, proc->
usedframes);
306 cpl_frameset_join(outframes, proc->
outframes);
309 if (!cpl_errorstate_is_equal(prestate)) {
313 cpl_msg_set_level(CPL_MSG_INFO);
324 cpl_frameset_join(recipe->frames, usedframes);
325 cpl_frameset_join(recipe->frames, outframes);
326 cpl_frameset_delete(usedframes);
327 cpl_frameset_delete(outframes);
340 muse_scipost_combine_pixtables_destroy(cpl_plugin *aPlugin)
344 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
345 recipe = (cpl_recipe *)aPlugin;
351 cpl_parameterlist_delete(recipe->parameters);
368 cpl_plugin_get_info(cpl_pluginlist *aList)
370 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
371 cpl_plugin *plugin = &recipe->interface;
375 helptext = cpl_sprintf(
"%s%s", muse_scipost_combine_pixtables_help,
376 muse_scipost_combine_pixtables_help_esorex);
378 helptext = cpl_sprintf(
"%s", muse_scipost_combine_pixtables_help);
382 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
383 CPL_PLUGIN_TYPE_RECIPE,
384 "muse_scipost_combine_pixtables",
385 "Combine MUSE pixel tables, either from different IFUs, or from different exposures, or both.",
390 muse_scipost_combine_pixtables_create,
391 muse_scipost_combine_pixtables_exec,
392 muse_scipost_combine_pixtables_destroy);
393 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).
cpl_frameset * usedframes
muse_processing * muse_processing_new(const char *aName, cpl_recipe *aRecipe)
Create a new processing structure.
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
const char * muse_get_license(void)
Get the pipeline copyright and license.
int weight
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
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.
void muse_processing_recipeinfo(cpl_plugin *)
Output main pipeline configuration, inputs, and parameters.