35 #include "muse_scipost_apply_astrometry_z.h"
49 static const char *muse_scipost_apply_astrometry_help =
50 "Apply an astrometric calibration to the pixel table spatial coordinates. This is a task separated from muse_scipost.";
52 static const char *muse_scipost_apply_astrometry_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 astrometric calibration"
57 "\n ASTROMETRY_WCS calib . 1 Astrometric solution derived from astrometric science frame"
58 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
59 "\n Frame tag Level Description"
60 "\n -------------------- -------- ------------"
61 "\n PIXTABLE_OBJECT final Pixel table with astrometric calibration";
72 static cpl_recipeconfig *
73 muse_scipost_apply_astrometry_new_recipeconfig(
void)
75 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
78 tag =
"PIXTABLE_OBJECT";
79 cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
80 cpl_recipeconfig_set_input(recipeconfig, tag,
"ASTROMETRY_WCS", -1, 1);
81 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_OBJECT");
98 muse_scipost_apply_astrometry_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
100 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
101 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
102 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
104 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
105 return CPL_ERROR_ILLEGAL_INPUT;
107 return CPL_ERROR_NONE;
120 static cpl_frame_level
121 muse_scipost_apply_astrometry_get_frame_level(
const char *aFrametag)
124 return CPL_FRAME_LEVEL_NONE;
126 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
127 return CPL_FRAME_LEVEL_FINAL;
129 return CPL_FRAME_LEVEL_NONE;
143 muse_scipost_apply_astrometry_get_frame_mode(
const char *aFrametag)
148 if (!strcmp(aFrametag,
"PIXTABLE_OBJECT")) {
166 muse_scipost_apply_astrometry_create(cpl_plugin *aPlugin)
170 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
171 recipe = (cpl_recipe *)aPlugin;
179 muse_scipost_apply_astrometry_new_recipeconfig(),
180 muse_scipost_apply_astrometry_prepare_header,
181 muse_scipost_apply_astrometry_get_frame_level,
182 muse_scipost_apply_astrometry_get_frame_mode);
187 cpl_msg_set_time_on();
191 recipe->parameters = cpl_parameterlist_new();
196 p = cpl_parameter_new_value(
"muse.muse_scipost_apply_astrometry.lambdamin",
198 "Cut off the data below this wavelength after loading the pixel table(s).",
199 "muse.muse_scipost_apply_astrometry",
201 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
202 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
204 cpl_parameterlist_append(recipe->parameters, p);
207 p = cpl_parameter_new_value(
"muse.muse_scipost_apply_astrometry.lambdamax",
209 "Cut off the data above this wavelength after loading the pixel table(s).",
210 "muse.muse_scipost_apply_astrometry",
212 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
213 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
215 cpl_parameterlist_append(recipe->parameters, p);
235 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
236 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
239 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_apply_astrometry.lambdamin");
240 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
241 aParams->
lambdamin = cpl_parameter_get_double(p);
243 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_apply_astrometry.lambdamax");
244 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
245 aParams->
lambdamax = cpl_parameter_get_double(p);
259 muse_scipost_apply_astrometry_exec(cpl_plugin *aPlugin)
261 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
264 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
265 cpl_msg_set_threadid_on();
267 cpl_frameset *usedframes = cpl_frameset_new(),
268 *outframes = cpl_frameset_new();
270 muse_scipost_apply_astrometry_params_fill(¶ms, recipe->parameters);
272 cpl_errorstate prestate = cpl_errorstate_get();
276 int rc = muse_scipost_apply_astrometry_compute(proc, ¶ms);
277 cpl_frameset_join(usedframes, proc->
usedframes);
278 cpl_frameset_join(outframes, proc->
outframes);
281 if (!cpl_errorstate_is_equal(prestate)) {
285 cpl_msg_set_level(CPL_MSG_INFO);
296 cpl_frameset_join(recipe->frames, usedframes);
297 cpl_frameset_join(recipe->frames, outframes);
298 cpl_frameset_delete(usedframes);
299 cpl_frameset_delete(outframes);
312 muse_scipost_apply_astrometry_destroy(cpl_plugin *aPlugin)
316 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
317 recipe = (cpl_recipe *)aPlugin;
323 cpl_parameterlist_delete(recipe->parameters);
340 cpl_plugin_get_info(cpl_pluginlist *aList)
342 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
343 cpl_plugin *plugin = &recipe->interface;
347 helptext = cpl_sprintf(
"%s%s", muse_scipost_apply_astrometry_help,
348 muse_scipost_apply_astrometry_help_esorex);
350 helptext = cpl_sprintf(
"%s", muse_scipost_apply_astrometry_help);
354 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
355 CPL_PLUGIN_TYPE_RECIPE,
356 "muse_scipost_apply_astrometry",
357 "Calibrate astrometry for MUSE pixel tables.",
362 muse_scipost_apply_astrometry_create,
363 muse_scipost_apply_astrometry_exec,
364 muse_scipost_apply_astrometry_destroy);
365 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_apply_astrometry recipe.
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
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.
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.