35 #include "muse_scipost_raman_z.h" 52 static const char *muse_scipost_raman_help =
53 "This recipe removes the Raman scattered light of the 4GLSF system from the exposure. It must be before the normal sky subtraction.";
55 static const char *muse_scipost_raman_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 1 Input pixel table" 60 "\n RAMAN_LINES calib Y 1 List of Raman emission lines" 61 "\n LSF_PROFILE calib Y Slice specific LSF parameters cubes" 62 "\n SKY_MASK calib Y 1 Sky mask to use" 63 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n" 64 "\n Frame tag Level Description" 65 "\n -------------------- -------- ------------" 66 "\n RAMAN_IMAGES intermed Images for Raman correction diagnostics (if an input RAMAN_LINES was given, the instrument used AO and --save contains \"raman\"). Extensions are: DATA: model of the Raman light distribution in the field of view (arbitrary units), RAMAN_IMAGE_O2: reconstructed image in the O2 band, SKY_MASK_O2: sky mask used for the O2 band, RAMAN_IMAGE_N2: reconstructed image in the N2 band, SKY_MASK_N2: sky mask used for the N2 band, RAMAN_FIT_O2: model of Raman flux distribution in the O2 band, RAMAN_FIT_N2: model of Raman flux distribution in the N2 band." 67 "\n PIXTABLE_REDUCED final Output pixel table for raman subtraction.";
78 static cpl_recipeconfig *
79 muse_scipost_raman_new_recipeconfig(
void)
81 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
83 cpl_recipeconfig_set_tag(recipeconfig,
"PIXTABLE_OBJECT", 1, 1);
84 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"RAMAN_LINES", 1, 1);
85 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"LSF_PROFILE", 1, -1);
86 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_OBJECT",
"SKY_MASK", 1, 1);
87 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_OBJECT",
"RAMAN_IMAGES");
88 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_OBJECT",
"PIXTABLE_REDUCED");
104 static cpl_error_code
105 muse_scipost_raman_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
107 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
108 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
109 if (!strcmp(aFrametag,
"RAMAN_IMAGES")) {
112 "2D Polynomial x^2 coefficient");
115 "2D Polynomial xy coefficient");
118 "2D Polynomial y^2 coefficient");
121 "2D Polynomial x coefficient");
124 "2D Polynomial y coefficient");
127 "[erg/(s cm2 arcsec2)] Computed average Raman scattered flux in the O2 band (around 6484 Angstrom)");
130 "[erg/(s cm2 arcsec2)] Computed average Raman scattered flux in the N2 band (around 6827 Angstrom)");
131 }
else if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
133 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
134 return CPL_ERROR_ILLEGAL_INPUT;
136 return CPL_ERROR_NONE;
149 static cpl_frame_level
150 muse_scipost_raman_get_frame_level(
const char *aFrametag)
153 return CPL_FRAME_LEVEL_NONE;
155 if (!strcmp(aFrametag,
"RAMAN_IMAGES")) {
156 return CPL_FRAME_LEVEL_INTERMEDIATE;
158 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
159 return CPL_FRAME_LEVEL_FINAL;
161 return CPL_FRAME_LEVEL_NONE;
175 muse_scipost_raman_get_frame_mode(
const char *aFrametag)
180 if (!strcmp(aFrametag,
"RAMAN_IMAGES")) {
183 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
201 muse_scipost_raman_create(cpl_plugin *aPlugin)
205 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
206 recipe = (cpl_recipe *)aPlugin;
214 muse_scipost_raman_new_recipeconfig(),
215 muse_scipost_raman_prepare_header,
216 muse_scipost_raman_get_frame_level,
217 muse_scipost_raman_get_frame_mode);
222 cpl_msg_set_time_on();
226 recipe->parameters = cpl_parameterlist_new();
231 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.lambdamin",
233 "Cut off the data below this wavelength after loading the pixel table(s).",
234 "muse.muse_scipost_raman",
236 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
237 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
239 cpl_parameterlist_append(recipe->parameters, p);
242 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.lambdamax",
244 "Cut off the data above this wavelength after loading the pixel table(s).",
245 "muse.muse_scipost_raman",
247 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
248 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
250 cpl_parameterlist_append(recipe->parameters, p);
253 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.lambdaref",
255 "Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wavelength ~7000 Angstrom) that is usually used for guiding, is close to the central wavelength of MUSE, so a value of 7000.0 Angstrom should be used if nothing else is known. A value less than zero switches DAR correction off.",
256 "muse.muse_scipost_raman",
258 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdaref");
259 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdaref");
261 cpl_parameterlist_append(recipe->parameters, p);
264 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.width",
266 "Wavelength range around Raman lines [Angstrom].",
267 "muse.muse_scipost_raman",
269 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"width");
270 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"width");
271 if (!getenv(
"MUSE_EXPERT_USER")) {
272 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
275 cpl_parameterlist_append(recipe->parameters, p);
278 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.crsigma",
280 "Sigma level clipping for cube-based CR rejection (using \"median\", see muse_scipost). It can be switched off, by passing zero or a negative value.",
281 "muse.muse_scipost_raman",
283 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"crsigma");
284 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"crsigma");
285 if (!getenv(
"MUSE_EXPERT_USER")) {
286 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
289 cpl_parameterlist_append(recipe->parameters, p);
292 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.fraction",
294 "Fraction of the image (without the ignored part) to be considered as sky. If an input sky mask is provided, the fraction is applied to the regions within the mask. If the whole sky mask should be used, set this parameter to 1.",
295 "muse.muse_scipost_raman",
297 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"fraction");
298 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"fraction");
300 cpl_parameterlist_append(recipe->parameters, p);
303 p = cpl_parameter_new_value(
"muse.muse_scipost_raman.ignore",
305 "Lowest fraction of the image to be ignored. If an input sky mask is provided, the fraction is applied to the regions within the mask. If the whole sky mask should be used, set this parameter to 0.",
306 "muse.muse_scipost_raman",
308 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ignore");
309 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ignore");
311 cpl_parameterlist_append(recipe->parameters, p);
331 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
332 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
335 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.lambdamin");
336 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
337 aParams->
lambdamin = cpl_parameter_get_double(p);
339 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.lambdamax");
340 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
341 aParams->
lambdamax = cpl_parameter_get_double(p);
343 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.lambdaref");
344 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
345 aParams->
lambdaref = cpl_parameter_get_double(p);
347 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.width");
348 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
349 aParams->
width = cpl_parameter_get_double(p);
351 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.crsigma");
352 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
353 aParams->
crsigma = cpl_parameter_get_double(p);
355 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.fraction");
356 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
357 aParams->
fraction = cpl_parameter_get_double(p);
359 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_raman.ignore");
360 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
361 aParams->
ignore = cpl_parameter_get_double(p);
375 muse_scipost_raman_exec(cpl_plugin *aPlugin)
377 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
381 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
382 cpl_msg_set_threadid_on();
384 cpl_frameset *usedframes = cpl_frameset_new(),
385 *outframes = cpl_frameset_new();
387 muse_scipost_raman_params_fill(¶ms, recipe->parameters);
389 cpl_errorstate prestate = cpl_errorstate_get();
393 int rc = muse_scipost_raman_compute(proc, ¶ms);
394 cpl_frameset_join(usedframes, proc->
usedframes);
395 cpl_frameset_join(outframes, proc->
outframes);
398 if (!cpl_errorstate_is_equal(prestate)) {
402 cpl_msg_set_level(CPL_MSG_INFO);
413 cpl_frameset_join(recipe->frames, usedframes);
414 cpl_frameset_join(recipe->frames, outframes);
415 cpl_frameset_delete(usedframes);
416 cpl_frameset_delete(outframes);
429 muse_scipost_raman_destroy(cpl_plugin *aPlugin)
433 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
434 recipe = (cpl_recipe *)aPlugin;
440 cpl_parameterlist_delete(recipe->parameters);
457 cpl_plugin_get_info(cpl_pluginlist *aList)
459 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
460 cpl_plugin *plugin = &recipe->interface;
464 helptext = cpl_sprintf(
"%s%s", muse_scipost_raman_help,
465 muse_scipost_raman_help_esorex);
467 helptext = cpl_sprintf(
"%s", muse_scipost_raman_help);
471 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
472 CPL_PLUGIN_TYPE_RECIPE,
473 "muse_scipost_raman",
474 "Remove of 4GLSF Raman emission.",
479 muse_scipost_raman_create,
480 muse_scipost_raman_exec,
481 muse_scipost_raman_destroy);
482 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
double width
Wavelength range around Raman lines [Angstrom].
double lambdaref
Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wav...
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
double crsigma
Sigma level clipping for cube-based CR rejection (using "median", see muse_scipost). It can be switched off, by passing zero or a negative value.
double fraction
Fraction of the image (without the ignored part) to be considered as sky. If an input sky mask is pro...
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.
double ignore
Lowest fraction of the image to be ignored. If an input sky mask is provided, the fraction is applied...
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 lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
Structure to hold the parameters of the muse_scipost_raman 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.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
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.
cpl_error_code muse_processing_prepare_property(cpl_propertylist *, const char *, cpl_type, const char *)
Prepare and check the specified property.