35 #include "muse_scipost_subtract_sky_z.h" 49 static const char *muse_scipost_subtract_sky_help =
50 "Subtract the sky as defined by the sky lines and continuum from a pixel table. This is a separated task of muse_scipost.";
52 static const char *muse_scipost_subtract_sky_help_esorex =
53 "\n\nInput frames for raw frame tag \"PIXTABLE_REDUCED\":\n" 54 "\n Frame tag Type Req #Fr Description" 55 "\n -------------------- ---- --- --- ------------" 56 "\n PIXTABLE_REDUCED raw Y Flux calibrated input pixel table(s)." 57 "\n SKY_LINES calib Y 1 Sky line list" 58 "\n SKY_CONTINUUM calib Y 1 Sky continuum spectrum" 59 "\n LSF_PROFILE calib Y LSF for each IFU." 60 "\n\nProduct frames for raw frame tag \"PIXTABLE_REDUCED\":\n" 61 "\n Frame tag Level Description" 62 "\n -------------------- -------- ------------" 63 "\n PIXTABLE_REDUCED final Output pixel table(s) for sky subtraction.";
74 static cpl_recipeconfig *
75 muse_scipost_subtract_sky_new_recipeconfig(
void)
77 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
79 cpl_recipeconfig_set_tag(recipeconfig,
"PIXTABLE_REDUCED", 1, -1);
80 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_REDUCED",
"SKY_LINES", 1, 1);
81 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_REDUCED",
"SKY_CONTINUUM", 1, 1);
82 cpl_recipeconfig_set_input(recipeconfig,
"PIXTABLE_REDUCED",
"LSF_PROFILE", 1, -1);
83 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_REDUCED",
"PIXTABLE_REDUCED");
100 muse_scipost_subtract_sky_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_REDUCED")) {
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_subtract_sky_get_frame_level(
const char *aFrametag)
126 return CPL_FRAME_LEVEL_NONE;
128 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
129 return CPL_FRAME_LEVEL_FINAL;
131 return CPL_FRAME_LEVEL_NONE;
145 muse_scipost_subtract_sky_get_frame_mode(
const char *aFrametag)
150 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
168 muse_scipost_subtract_sky_create(cpl_plugin *aPlugin)
172 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
173 recipe = (cpl_recipe *)aPlugin;
181 muse_scipost_subtract_sky_new_recipeconfig(),
182 muse_scipost_subtract_sky_prepare_header,
183 muse_scipost_subtract_sky_get_frame_level,
184 muse_scipost_subtract_sky_get_frame_mode);
189 cpl_msg_set_time_on();
193 recipe->parameters = cpl_parameterlist_new();
198 p = cpl_parameter_new_value(
"muse.muse_scipost_subtract_sky.lambdamin",
200 "Cut off the data below this wavelength after loading the pixel table(s).",
201 "muse.muse_scipost_subtract_sky",
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_subtract_sky.lambdamax",
211 "Cut off the data above this wavelength after loading the pixel table(s).",
212 "muse.muse_scipost_subtract_sky",
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);
221 p = cpl_parameter_new_value(
"muse.muse_scipost_subtract_sky.orig",
223 "If specified, write an additional column containing the original data to the pixel table.",
224 "muse.muse_scipost_subtract_sky",
226 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"orig");
227 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"orig");
229 cpl_parameterlist_append(recipe->parameters, p);
232 p = cpl_parameter_new_value(
"muse.muse_scipost_subtract_sky.flux_sky",
234 "Reference flat field flux, obtained by sky exposure. This parameter is needed to scale the data of each pixel table if more than one pixel table was used to determine the sky. By default, it is taken from the parameter ESO DRS MUSE FLAT FLUX SKY of the first pixel table.",
235 "muse.muse_scipost_subtract_sky",
237 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"flux_sky");
238 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"flux_sky");
240 cpl_parameterlist_append(recipe->parameters, p);
243 p = cpl_parameter_new_value(
"muse.muse_scipost_subtract_sky.flux_lamp",
245 "Reference flat field flux, obtained by lamp exposure. This parameter is needed to scale the data of each pixel table if more than one pixel table was used to determine the sky. By default, it is taken from the parameter ESO DRS MUSE FLAT FLUX LAMP of the first pixel table.",
246 "muse.muse_scipost_subtract_sky",
248 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"flux_lamp");
249 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"flux_lamp");
251 cpl_parameterlist_append(recipe->parameters, p);
271 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
272 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
275 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_subtract_sky.lambdamin");
276 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
277 aParams->
lambdamin = cpl_parameter_get_double(p);
279 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_subtract_sky.lambdamax");
280 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
281 aParams->
lambdamax = cpl_parameter_get_double(p);
283 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_subtract_sky.orig");
284 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
285 aParams->
orig = cpl_parameter_get_string(p);
287 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_subtract_sky.flux_sky");
288 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
289 aParams->
flux_sky = cpl_parameter_get_double(p);
291 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_subtract_sky.flux_lamp");
292 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
293 aParams->
flux_lamp = cpl_parameter_get_double(p);
307 muse_scipost_subtract_sky_exec(cpl_plugin *aPlugin)
309 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
313 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
314 cpl_msg_set_threadid_on();
316 cpl_frameset *usedframes = cpl_frameset_new(),
317 *outframes = cpl_frameset_new();
319 muse_scipost_subtract_sky_params_fill(¶ms, recipe->parameters);
321 cpl_errorstate prestate = cpl_errorstate_get();
325 int rc = muse_scipost_subtract_sky_compute(proc, ¶ms);
326 cpl_frameset_join(usedframes, proc->
usedframes);
327 cpl_frameset_join(outframes, proc->
outframes);
330 if (!cpl_errorstate_is_equal(prestate)) {
334 cpl_msg_set_level(CPL_MSG_INFO);
345 cpl_frameset_join(recipe->frames, usedframes);
346 cpl_frameset_join(recipe->frames, outframes);
347 cpl_frameset_delete(usedframes);
348 cpl_frameset_delete(outframes);
361 muse_scipost_subtract_sky_destroy(cpl_plugin *aPlugin)
365 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
366 recipe = (cpl_recipe *)aPlugin;
372 cpl_parameterlist_delete(recipe->parameters);
389 cpl_plugin_get_info(cpl_pluginlist *aList)
391 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
392 cpl_plugin *plugin = &recipe->interface;
396 helptext = cpl_sprintf(
"%s%s", muse_scipost_subtract_sky_help,
397 muse_scipost_subtract_sky_help_esorex);
399 helptext = cpl_sprintf(
"%s", muse_scipost_subtract_sky_help);
403 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
404 CPL_PLUGIN_TYPE_RECIPE,
405 "muse_scipost_subtract_sky",
406 "Subtract night sky model.",
411 muse_scipost_subtract_sky_create,
412 muse_scipost_subtract_sky_exec,
413 muse_scipost_subtract_sky_destroy);
414 cpl_pluginlist_append(aList, plugin);
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
const char * orig
If specified, write an additional column containing the original data to the pixel table...
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.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
double flux_lamp
Reference flat field flux, obtained by lamp exposure. This parameter is needed to scale the data of e...
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_scipost_subtract_sky recipe.
double flux_sky
Reference flat field flux, obtained by sky exposure. This parameter is needed to scale the data of ea...
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.