35 #include "muse_scipost_correct_dar_z.h"
49 static const char *muse_scipost_correct_dar_help =
50 "Correct the coordinates in the pixel table by differential atmospheric refraction. This is a task separated from muse_scipost.";
52 static const char *muse_scipost_correct_dar_help_esorex =
53 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
54 "\n Frame tag Type Req #Fr Description"
55 "\n -------------------- ---- --- --- ------------"
56 "\n PIXTABLE_OBJECT raw Y Pixel table without DAR correction"
57 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
58 "\n Frame tag Level Description"
59 "\n -------------------- -------- ------------"
60 "\n PIXTABLE_OBJECT final DAR corrected pixel table";
71 static cpl_recipeconfig *
72 muse_scipost_correct_dar_new_recipeconfig(
void)
74 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
77 tag =
"PIXTABLE_OBJECT";
78 cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
79 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_OBJECT");
96 muse_scipost_correct_dar_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
98 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
99 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
100 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
102 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
103 return CPL_ERROR_ILLEGAL_INPUT;
105 return CPL_ERROR_NONE;
118 static cpl_frame_level
119 muse_scipost_correct_dar_get_frame_level(
const char *aFrametag)
122 return CPL_FRAME_LEVEL_NONE;
124 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
125 return CPL_FRAME_LEVEL_FINAL;
127 return CPL_FRAME_LEVEL_NONE;
141 muse_scipost_correct_dar_get_frame_mode(
const char *aFrametag)
146 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
164 muse_scipost_correct_dar_create(cpl_plugin *aPlugin)
168 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
169 recipe = (cpl_recipe *)aPlugin;
177 muse_scipost_correct_dar_new_recipeconfig(),
178 muse_scipost_correct_dar_prepare_header,
179 muse_scipost_correct_dar_get_frame_level,
180 muse_scipost_correct_dar_get_frame_mode);
185 cpl_msg_set_time_on();
189 recipe->parameters = cpl_parameterlist_new();
194 p = cpl_parameter_new_value(
"muse.muse_scipost_correct_dar.lambdamin",
196 "Cut off the data below this wavelength after loading the pixel table(s).",
197 "muse.muse_scipost_correct_dar",
199 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
200 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
202 cpl_parameterlist_append(recipe->parameters, p);
205 p = cpl_parameter_new_value(
"muse.muse_scipost_correct_dar.lambdamax",
207 "Cut off the data above this wavelength after loading the pixel table(s).",
208 "muse.muse_scipost_correct_dar",
210 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
211 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
213 cpl_parameterlist_append(recipe->parameters, p);
216 p = cpl_parameter_new_value(
"muse.muse_scipost_correct_dar.lambdaref",
218 "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.",
219 "muse.muse_scipost_correct_dar",
221 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdaref");
222 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdaref");
224 cpl_parameterlist_append(recipe->parameters, p);
227 p = cpl_parameter_new_enum(
"muse.muse_scipost_correct_dar.darcheck",
229 "Carry out a check of the theoretical DAR correction using source centroiding. If \"correct\" it will also apply an empirical correction.",
230 "muse.muse_scipost_correct_dar",
231 (
const char *)
"none",
233 (
const char *)
"none",
234 (
const char *)
"check",
235 (
const char *)
"correct");
236 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"darcheck");
237 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"darcheck");
239 cpl_parameterlist_append(recipe->parameters, p);
259 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
260 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
263 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_dar.lambdamin");
264 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
265 aParams->
lambdamin = cpl_parameter_get_double(p);
267 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_dar.lambdamax");
268 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
269 aParams->
lambdamax = cpl_parameter_get_double(p);
271 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_dar.lambdaref");
272 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
273 aParams->
lambdaref = cpl_parameter_get_double(p);
275 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_dar.darcheck");
276 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
277 aParams->
darcheck_s = cpl_parameter_get_string(p);
279 (!strcasecmp(aParams->
darcheck_s,
"none")) ? MUSE_SCIPOST_CORRECT_DAR_PARAM_DARCHECK_NONE :
280 (!strcasecmp(aParams->
darcheck_s,
"check")) ? MUSE_SCIPOST_CORRECT_DAR_PARAM_DARCHECK_CHECK :
281 (!strcasecmp(aParams->
darcheck_s,
"correct")) ? MUSE_SCIPOST_CORRECT_DAR_PARAM_DARCHECK_CORRECT :
282 MUSE_SCIPOST_CORRECT_DAR_PARAM_DARCHECK_INVALID_VALUE;
283 cpl_ensure_code(aParams->
darcheck != MUSE_SCIPOST_CORRECT_DAR_PARAM_DARCHECK_INVALID_VALUE,
284 CPL_ERROR_ILLEGAL_INPUT);
298 muse_scipost_correct_dar_exec(cpl_plugin *aPlugin)
300 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
303 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
304 cpl_msg_set_threadid_on();
306 cpl_frameset *usedframes = cpl_frameset_new(),
307 *outframes = cpl_frameset_new();
309 muse_scipost_correct_dar_params_fill(¶ms, recipe->parameters);
311 cpl_errorstate prestate = cpl_errorstate_get();
315 int rc = muse_scipost_correct_dar_compute(proc, ¶ms);
316 cpl_frameset_join(usedframes, proc->
usedframes);
317 cpl_frameset_join(outframes, proc->
outframes);
320 if (!cpl_errorstate_is_equal(prestate)) {
324 cpl_msg_set_level(CPL_MSG_INFO);
335 cpl_frameset_join(recipe->frames, usedframes);
336 cpl_frameset_join(recipe->frames, outframes);
337 cpl_frameset_delete(usedframes);
338 cpl_frameset_delete(outframes);
351 muse_scipost_correct_dar_destroy(cpl_plugin *aPlugin)
355 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
356 recipe = (cpl_recipe *)aPlugin;
362 cpl_parameterlist_delete(recipe->parameters);
379 cpl_plugin_get_info(cpl_pluginlist *aList)
381 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
382 cpl_plugin *plugin = &recipe->interface;
386 helptext = cpl_sprintf(
"%s%s", muse_scipost_correct_dar_help,
387 muse_scipost_correct_dar_help_esorex);
389 helptext = cpl_sprintf(
"%s", muse_scipost_correct_dar_help);
393 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
394 CPL_PLUGIN_TYPE_RECIPE,
395 "muse_scipost_correct_dar",
396 "Apply DAR correction for MUSE pixel tables.",
401 muse_scipost_correct_dar_create,
402 muse_scipost_correct_dar_exec,
403 muse_scipost_correct_dar_destroy);
404 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.
double lambdaref
Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wav...
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_correct_dar 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.
int darcheck
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
const char * darcheck_s
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
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.
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).