35 #include "muse_qi_mask_z.h" 63 static const char *muse_qi_mask_help =
64 "Trace and wavelength calibration tables (24 of them each, one per IFU) are used to build wavelength maps. If the input data is binned, the wavelength maps are binned in the same way (averaging of pixels). The wavelength maps are then thresholded to create masks of the desired wavelength range. Finally, the mask is \"untrimmed\", i.e. empty regions for the pre- and overscans are added (in a simple way, assuming quadrants of equal size, and padding of 32 pixels on all quadrant edges). Note: this recipe is not part of the main MUSE pipeline but to be used in the integration phase to create image masks until the system is fully qualified. It therefore does only minimal error checking.";
66 static const char *muse_qi_mask_help_esorex =
67 "\n\nInput frames for raw frame tag \"BIAS\":\n" 68 "\n Frame tag Type Req #Fr Description" 69 "\n -------------------- ---- --- --- ------------" 70 "\n BIAS raw . 1 Raw bias, should be given, used to determine detector setup for the output mask" 71 "\n TRACE_TABLE calib Y 1 Trace table" 72 "\n WAVECAL_TABLE calib Y 1 Wavelength calibration table" 73 "\n\nProduct frames for raw frame tag \"BIAS\":\n" 74 "\n Frame tag Level Description" 75 "\n -------------------- -------- ------------" 76 "\n MASK_IMAGE final Image masks for quick image reconstruction";
87 static cpl_recipeconfig *
88 muse_qi_mask_new_recipeconfig(
void)
90 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
92 cpl_recipeconfig_set_tag(recipeconfig,
"BIAS", -1, 1);
93 cpl_recipeconfig_set_input(recipeconfig,
"BIAS",
"TRACE_TABLE", 1, 1);
94 cpl_recipeconfig_set_input(recipeconfig,
"BIAS",
"WAVECAL_TABLE", 1, 1);
95 cpl_recipeconfig_set_output(recipeconfig,
"BIAS",
"MASK_IMAGE");
111 static cpl_error_code
112 muse_qi_mask_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
114 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
115 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
116 if (!strcmp(aFrametag,
"MASK_IMAGE")) {
118 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
119 return CPL_ERROR_ILLEGAL_INPUT;
121 return CPL_ERROR_NONE;
134 static cpl_frame_level
135 muse_qi_mask_get_frame_level(
const char *aFrametag)
138 return CPL_FRAME_LEVEL_NONE;
140 if (!strcmp(aFrametag,
"MASK_IMAGE")) {
141 return CPL_FRAME_LEVEL_FINAL;
143 return CPL_FRAME_LEVEL_NONE;
157 muse_qi_mask_get_frame_mode(
const char *aFrametag)
162 if (!strcmp(aFrametag,
"MASK_IMAGE")) {
180 muse_qi_mask_create(cpl_plugin *aPlugin)
184 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
185 recipe = (cpl_recipe *)aPlugin;
193 muse_qi_mask_new_recipeconfig(),
194 muse_qi_mask_prepare_header,
195 muse_qi_mask_get_frame_level,
196 muse_qi_mask_get_frame_mode);
201 cpl_msg_set_time_on();
205 recipe->parameters = cpl_parameterlist_new();
210 p = cpl_parameter_new_range(
"muse.muse_qi_mask.nifu",
212 "IFU to handle. If set to 0, all IFUs are processed serially, which is the recommendation for this recipe, since only then all extensions end up in the same output file.",
217 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nifu");
218 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nifu");
220 cpl_parameterlist_append(recipe->parameters, p);
240 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
241 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
244 p = cpl_parameterlist_find(aParameters,
"muse.muse_qi_mask.nifu");
245 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
246 aParams->
nifu = cpl_parameter_get_int(p);
260 muse_qi_mask_exec(cpl_plugin *aPlugin)
262 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
266 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
267 cpl_msg_set_threadid_on();
269 cpl_frameset *usedframes = cpl_frameset_new(),
270 *outframes = cpl_frameset_new();
272 muse_qi_mask_params_fill(¶ms, recipe->parameters);
274 cpl_errorstate prestate = cpl_errorstate_get();
278 int rc = muse_qi_mask_compute(proc, ¶ms);
279 cpl_frameset_join(usedframes, proc->
usedframes);
280 cpl_frameset_join(outframes, proc->
outframes);
283 if (!cpl_errorstate_is_equal(prestate)) {
287 cpl_msg_set_level(CPL_MSG_INFO);
298 cpl_frameset_join(recipe->frames, usedframes);
299 cpl_frameset_join(recipe->frames, outframes);
300 cpl_frameset_delete(usedframes);
301 cpl_frameset_delete(outframes);
314 muse_qi_mask_destroy(cpl_plugin *aPlugin)
318 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
319 recipe = (cpl_recipe *)aPlugin;
325 cpl_parameterlist_delete(recipe->parameters);
342 cpl_plugin_get_info(cpl_pluginlist *aList)
344 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
345 cpl_plugin *plugin = &recipe->interface;
349 helptext = cpl_sprintf(
"%s%s", muse_qi_mask_help,
350 muse_qi_mask_help_esorex);
352 helptext = cpl_sprintf(
"%s", muse_qi_mask_help);
356 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
357 CPL_PLUGIN_TYPE_RECIPE,
359 "Create image masks for use with the quick image reconstruction.",
366 muse_qi_mask_destroy);
367 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.
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.
Structure to hold the parameters of the muse_qi_mask recipe.
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.
int nifu
IFU to handle. If set to 0, all IFUs are processed serially, which is the recommendation for this rec...