35 #include "muse_scipost_correct_rv_z.h" 49 static const char *muse_scipost_correct_rv_help =
50 "Correct the wavelengths in the pixel table by given radial-velocity correction. This is a task separated from muse_scipost.";
52 static const char *muse_scipost_correct_rv_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 RV correction" 57 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n" 58 "\n Frame tag Level Description" 59 "\n -------------------- -------- ------------" 60 "\n PIXTABLE_REDUCED final RV corrected pixel table";
71 static cpl_recipeconfig *
72 muse_scipost_correct_rv_new_recipeconfig(
void)
74 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
76 cpl_recipeconfig_set_tag(recipeconfig,
"PIXTABLE_OBJECT", 1, -1);
77 cpl_recipeconfig_set_output(recipeconfig,
"PIXTABLE_OBJECT",
"PIXTABLE_REDUCED");
94 muse_scipost_correct_rv_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
96 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
97 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
98 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
100 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
101 return CPL_ERROR_ILLEGAL_INPUT;
103 return CPL_ERROR_NONE;
116 static cpl_frame_level
117 muse_scipost_correct_rv_get_frame_level(
const char *aFrametag)
120 return CPL_FRAME_LEVEL_NONE;
122 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
123 return CPL_FRAME_LEVEL_FINAL;
125 return CPL_FRAME_LEVEL_NONE;
139 muse_scipost_correct_rv_get_frame_mode(
const char *aFrametag)
144 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
162 muse_scipost_correct_rv_create(cpl_plugin *aPlugin)
166 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
167 recipe = (cpl_recipe *)aPlugin;
175 muse_scipost_correct_rv_new_recipeconfig(),
176 muse_scipost_correct_rv_prepare_header,
177 muse_scipost_correct_rv_get_frame_level,
178 muse_scipost_correct_rv_get_frame_mode);
183 cpl_msg_set_time_on();
187 recipe->parameters = cpl_parameterlist_new();
192 p = cpl_parameter_new_value(
"muse.muse_scipost_correct_rv.lambdamin",
194 "Cut off the data below this wavelength after loading the pixel table(s).",
195 "muse.muse_scipost_correct_rv",
197 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
198 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
200 cpl_parameterlist_append(recipe->parameters, p);
203 p = cpl_parameter_new_value(
"muse.muse_scipost_correct_rv.lambdamax",
205 "Cut off the data above this wavelength after loading the pixel table(s).",
206 "muse.muse_scipost_correct_rv",
208 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
209 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
211 cpl_parameterlist_append(recipe->parameters, p);
214 p = cpl_parameter_new_enum(
"muse.muse_scipost_correct_rv.rvcorr",
216 "Correct the radial velocity of the telescope with reference to either the barycenter of the Solar System (bary), the center of the Sun (helio), or to the center of the Earth (geo).",
217 "muse.muse_scipost_correct_rv",
218 (
const char *)
"bary",
220 (
const char *)
"bary",
221 (
const char *)
"helio",
223 (
const char *)
"none");
224 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"rvcorr");
225 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"rvcorr");
227 cpl_parameterlist_append(recipe->parameters, p);
247 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
248 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
251 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_rv.lambdamin");
252 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
253 aParams->
lambdamin = cpl_parameter_get_double(p);
255 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_rv.lambdamax");
256 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
257 aParams->
lambdamax = cpl_parameter_get_double(p);
259 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost_correct_rv.rvcorr");
260 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
261 aParams->
rvcorr_s = cpl_parameter_get_string(p);
263 (!strcasecmp(aParams->
rvcorr_s,
"bary")) ? MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_BARY :
264 (!strcasecmp(aParams->
rvcorr_s,
"helio")) ? MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_HELIO :
265 (!strcasecmp(aParams->
rvcorr_s,
"geo")) ? MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_GEO :
266 (!strcasecmp(aParams->
rvcorr_s,
"none")) ? MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_NONE :
267 MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_INVALID_VALUE;
268 cpl_ensure_code(aParams->
rvcorr != MUSE_SCIPOST_CORRECT_RV_PARAM_RVCORR_INVALID_VALUE,
269 CPL_ERROR_ILLEGAL_INPUT);
283 muse_scipost_correct_rv_exec(cpl_plugin *aPlugin)
285 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
289 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
290 cpl_msg_set_threadid_on();
292 cpl_frameset *usedframes = cpl_frameset_new(),
293 *outframes = cpl_frameset_new();
295 muse_scipost_correct_rv_params_fill(¶ms, recipe->parameters);
297 cpl_errorstate prestate = cpl_errorstate_get();
301 int rc = muse_scipost_correct_rv_compute(proc, ¶ms);
302 cpl_frameset_join(usedframes, proc->
usedframes);
303 cpl_frameset_join(outframes, proc->
outframes);
306 if (!cpl_errorstate_is_equal(prestate)) {
310 cpl_msg_set_level(CPL_MSG_INFO);
321 cpl_frameset_join(recipe->frames, usedframes);
322 cpl_frameset_join(recipe->frames, outframes);
323 cpl_frameset_delete(usedframes);
324 cpl_frameset_delete(outframes);
337 muse_scipost_correct_rv_destroy(cpl_plugin *aPlugin)
341 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
342 recipe = (cpl_recipe *)aPlugin;
348 cpl_parameterlist_delete(recipe->parameters);
365 cpl_plugin_get_info(cpl_pluginlist *aList)
367 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
368 cpl_plugin *plugin = &recipe->interface;
372 helptext = cpl_sprintf(
"%s%s", muse_scipost_correct_rv_help,
373 muse_scipost_correct_rv_help_esorex);
375 helptext = cpl_sprintf(
"%s", muse_scipost_correct_rv_help);
379 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
380 CPL_PLUGIN_TYPE_RECIPE,
381 "muse_scipost_correct_rv",
382 "Apply RV correction for MUSE pixel tables.",
387 muse_scipost_correct_rv_create,
388 muse_scipost_correct_rv_exec,
389 muse_scipost_correct_rv_destroy);
390 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
const char * rvcorr_s
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
Structure to hold the parameters of the muse_scipost_correct_rv recipe.
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
double lambdamax
Cut off the data above this wavelength after loading the pixel table(s).
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.
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.
int rvcorr
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
void muse_processing_recipeinfo(cpl_plugin *)
Output main pipeline configuration, inputs, and parameters.