35 #include "muse_scipost_z.h"
86 static const char *muse_scipost_help =
87 "Sort input pixel tables into lists of files per exposure, merge pixel tables from all IFUs of each exposure. Correct each exposure for differential atmopheric refraction (unless --lambdaraf is far outside the MUSE wavelength range). Then the flux calibration is carried out, if a respnse curve was given in the input; it includes a correction of telluric absorption, if a telluric absorptin correction file was given. Then the sky subtraction is carried out(unless --skymethod=&none&), either directly subtracting an input sky continuum and an input sky emission lines (for --skymethod=&subtract-model&), or (--skymethod=&model&) create a sky spectrum from the darkest fraction (--skymodel_fraction) of the field of view, then fitting and subtracting sky emission lines using an initial estimate of the input sky lines; then the continuum (residuals after subtracting the sky lines from the sky spectrum) is subtracted as well. If --save contains &skymodel&, all sky-related products are saved for each exposure. Afterwards the data is corrected for the radial velocity of the observer (--rvcorr), before the input (or a default) astrometric solution is applied. Now each individual exposure is fully reduced; the pixel tables at this stage can be saved by setting &individual& in --save. If multiple exposures were given, they are then combined. If --save contains &combined&, this final merged pixel table is saved. Finally (if --save contains &cube&), the data is resampled into a datacube, using all parameters given to the recipe. The extent and orientation of the cube is normally computed from the data itself, but this can be overridden by passing a file with the output world coordinate system (OUTPUT_WCS), for example a MUSE cube. This can also be used to sample the wavelength axis logorithmically (in that file set &CTYPE3='AWAV-LOG'&). As a last step, the computed cube is integrated over all filter functions given (--filter) that are also present in the input filter list table.";
89 static const char *muse_scipost_help_esorex =
90 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
91 "\n Frame tag Type Req #Fr Description"
92 "\n -------------------- ---- --- --- ------------"
93 "\n PIXTABLE_OBJECT raw Y Pixel table of a science object"
94 "\n EXTINCT_TABLE calib Y 1 Atmospheric extinction table"
95 "\n STD_RESPONSE calib Y 1 Response curve as derived from standard star(s)"
96 "\n STD_TELLURIC calib . 1 Telluric absorption correction as derived from standard star(s)"
97 "\n ASTROMETRY_WCS calib . 1 Astrometric solution derived from astrometric science frame"
98 "\n FILTER_LIST calib . 1 File to be used to create field-of-view images."
99 "\n OUTPUT_WCS calib . 1 WCS to override output cube location / dimensions"
100 "\n SKY_LINES calib . 1 List of OH transitions and other sky lines"
101 "\n SKY_CONTINUUM calib . 1 Sky continuum to use"
102 "\n LSF_PROFILE calib . Slice specific LSF parameters"
103 "\n SKY_MASK calib . 1 Sky mask to use"
104 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
105 "\n Frame tag Level Description"
106 "\n -------------------- -------- ------------"
107 "\n DATACUBE_FINAL final Output datacube"
108 "\n IMAGE_FOV final Field-of-view images corresponding to the \"filter\" parameter."
109 "\n OBJECT_RESAMPLED final Stacked image (if --save contains \"stacked\")"
110 "\n PIXTABLE_REDUCED intermed Fully reduced pixel tables for each exposure (if --save contains \"ptindividual\")"
111 "\n PIXTABLE_POSITIONED intermed Fully reduced and positioned pixel table for each individual exposure (if --save contains \"ptpositioned\")"
112 "\n PIXTABLE_COMBINED intermed Fully reduced and combined pixel table for the full set of exposures (if --save contains \"ptcombined\")"
113 "\n SKY_MASK intermed Created sky mask (if --skymethod=model and --save contains \"skymodel\")"
114 "\n SKY_SPECTRUM intermed Sky spectrum within the sky mask (if --skymethod=model and --save contains \"skymodel\")"
115 "\n SKY_LINES final Estimated sky line flux table (if --skymethod=model and --save contains \"skymodel\")"
116 "\n SKY_CONTINUUM final Estimated continuum flux spectrum (if --skymethod=model and --save contains \"skymodel\")";
127 static cpl_recipeconfig *
128 muse_scipost_new_recipeconfig(
void)
130 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
133 tag =
"PIXTABLE_OBJECT";
134 cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
135 cpl_recipeconfig_set_input(recipeconfig, tag,
"EXTINCT_TABLE", 1, 1);
136 cpl_recipeconfig_set_input(recipeconfig, tag,
"STD_RESPONSE", 1, 1);
137 cpl_recipeconfig_set_input(recipeconfig, tag,
"STD_TELLURIC", -1, 1);
138 cpl_recipeconfig_set_input(recipeconfig, tag,
"ASTROMETRY_WCS", -1, 1);
139 cpl_recipeconfig_set_input(recipeconfig, tag,
"FILTER_LIST", -1, 1);
140 cpl_recipeconfig_set_input(recipeconfig, tag,
"OUTPUT_WCS", -1, 1);
141 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_LINES", 0, 1);
142 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_CONTINUUM", 0, 1);
143 cpl_recipeconfig_set_input(recipeconfig, tag,
"LSF_PROFILE", 0, -1);
144 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_MASK", 0, 1);
145 cpl_recipeconfig_set_output(recipeconfig, tag,
"DATACUBE_FINAL");
146 cpl_recipeconfig_set_output(recipeconfig, tag,
"IMAGE_FOV");
147 cpl_recipeconfig_set_output(recipeconfig, tag,
"OBJECT_RESAMPLED");
148 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_REDUCED");
149 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_POSITIONED");
150 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_COMBINED");
151 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_MASK");
152 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_SPECTRUM");
153 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_LINES");
154 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_CONTINUUM");
170 static cpl_error_code
171 muse_scipost_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
173 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
174 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
175 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
178 "[pix] Position of source k in x-direction in combined frame");
181 "[pix] Position of source k in y-direction in combined frame");
184 "[arcsec] FWHM of source k in x-direction in combined frame");
187 "[arcsec] FWHM of source k in y-direction in combined frame");
188 }
else if (!strcmp(aFrametag,
"IMAGE_FOV")) {
191 "[pix] Position of source k in x-direction in combined frame");
194 "[pix] Position of source k in y-direction in combined frame");
197 "[arcsec] FWHM of source k in x-direction in combined frame");
200 "[arcsec] FWHM of source k in y-direction in combined frame");
201 }
else if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
202 }
else if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
203 }
else if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
204 }
else if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
205 }
else if (!strcmp(aFrametag,
"SKY_MASK")) {
208 "Threshold in the white light considered as sky, used to create this mask");
209 }
else if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
210 }
else if (!strcmp(aFrametag,
"SKY_LINES")) {
213 "Name of the strongest line in group l");
216 "[Angstrom] Wavelength (air) of the strongest line of group l");
219 "[erg/(s cm2 arcsec2)] Flux of the strongest line of group l");
220 }
else if (!strcmp(aFrametag,
"SKY_CONTINUUM")) {
223 "[erg/(s cm2 arcsec2)] Total flux of the continuum");
226 "[erg/(s cm2 arcsec2 Angstrom)] Maximum (absolute value) of the derivative of the continuum spectrum");
228 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
229 return CPL_ERROR_ILLEGAL_INPUT;
231 return CPL_ERROR_NONE;
244 static cpl_frame_level
245 muse_scipost_get_frame_level(
const char *aFrametag)
248 return CPL_FRAME_LEVEL_NONE;
250 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
251 return CPL_FRAME_LEVEL_FINAL;
253 if (!strcmp(aFrametag,
"IMAGE_FOV")) {
254 return CPL_FRAME_LEVEL_FINAL;
256 if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
257 return CPL_FRAME_LEVEL_FINAL;
259 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
260 return CPL_FRAME_LEVEL_INTERMEDIATE;
262 if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
263 return CPL_FRAME_LEVEL_INTERMEDIATE;
265 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
266 return CPL_FRAME_LEVEL_INTERMEDIATE;
268 if (!strcmp(aFrametag,
"SKY_MASK")) {
269 return CPL_FRAME_LEVEL_INTERMEDIATE;
271 if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
272 return CPL_FRAME_LEVEL_INTERMEDIATE;
274 if (!strcmp(aFrametag,
"SKY_LINES")) {
275 return CPL_FRAME_LEVEL_FINAL;
277 if (!strcmp(aFrametag,
"SKY_CONTINUUM")) {
278 return CPL_FRAME_LEVEL_FINAL;
280 return CPL_FRAME_LEVEL_NONE;
294 muse_scipost_get_frame_mode(
const char *aFrametag)
299 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
302 if (!strcmp(aFrametag,
"IMAGE_FOV")) {
305 if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
308 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
311 if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
314 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
317 if (!strcmp(aFrametag,
"SKY_MASK")) {
320 if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
323 if (!strcmp(aFrametag,
"SKY_LINES")) {
326 if (!strcmp(aFrametag,
"SKY_CONTINUUM")) {
344 muse_scipost_create(cpl_plugin *aPlugin)
348 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
349 recipe = (cpl_recipe *)aPlugin;
357 muse_scipost_new_recipeconfig(),
358 muse_scipost_prepare_header,
359 muse_scipost_get_frame_level,
360 muse_scipost_get_frame_mode);
365 cpl_msg_set_time_on();
369 recipe->parameters = cpl_parameterlist_new();
381 p = cpl_parameter_new_value(
"muse.muse_scipost.save",
383 "Select output product(s) to save. Can contain one or more of \"cube\", \"skymodel\", \"individual\", \"positioned\", \"combined\", and \"stacked\". If several options are given, they have to be comma-separated. (\"cube\": output cube and associated images, if this is not given, no final resampling is done at all -- \"skymodel\": up to four additional output products about the effectively used sky that was subtracted with the \"model\" method -- \"individual\": fully reduced pixel table for each individual exposure -- \"positioned\": fully reduced and positioned pixel table for each individual exposure, the difference to \"individual\" is that here, the output pixel tables have coordinates in RA and DEC; this is only useful, if both the relative exposure weighting and the final resampling are to be done externally -- \"combined\": fully reduced and combined pixel table for the full set of exposures, the difference to \"positioned\" is that all pixel tables are combined into one, with an added weight column; this is useful, if only the final resampling step is to be done separately -- \"stacked\": an additional output file in form of a 2D column-stacked image, i.e. x direction is pseudo-spatial, y direction is wavelength.)",
385 (
const char *)
"cube,skymodel");
386 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"save");
387 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"save");
389 cpl_parameterlist_append(recipe->parameters, p);
392 p = cpl_parameter_new_enum(
"muse.muse_scipost.resample",
394 "The resampling technique to use for the final output cube.",
396 (
const char *)
"drizzle",
398 (
const char *)
"nearest",
399 (
const char *)
"linear",
400 (
const char *)
"quadratic",
401 (
const char *)
"renka",
402 (
const char *)
"drizzle",
403 (
const char *)
"lanczos");
404 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"resample");
405 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"resample");
407 cpl_parameterlist_append(recipe->parameters, p);
410 p = cpl_parameter_new_value(
"muse.muse_scipost.dx",
412 "Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units.",
415 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dx");
416 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dx");
418 cpl_parameterlist_append(recipe->parameters, p);
421 p = cpl_parameter_new_value(
"muse.muse_scipost.dy",
423 "Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this value is set to 0.0: 0.2'' for WFM, 0.075'' for NFM, 1.0 if data is in pixel units.",
426 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dy");
427 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dy");
429 cpl_parameterlist_append(recipe->parameters, p);
432 p = cpl_parameter_new_value(
"muse.muse_scipost.dlambda",
434 "Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0.0",
437 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dlambda");
438 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dlambda");
440 cpl_parameterlist_append(recipe->parameters, p);
443 p = cpl_parameter_new_enum(
"muse.muse_scipost.crtype",
445 "Type of statistics used for detection of cosmic rays during final resampling. \"iraf\" uses the variance information, \"mean\" uses standard (mean/stdev) statistics, \"median\" uses median and the median median of the absolute median deviation.",
447 (
const char *)
"median",
449 (
const char *)
"iraf",
450 (
const char *)
"mean",
451 (
const char *)
"median");
452 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"crtype");
453 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"crtype");
455 cpl_parameterlist_append(recipe->parameters, p);
458 p = cpl_parameter_new_value(
"muse.muse_scipost.crsigma",
460 "Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative value switches cosmic ray rejection off.",
463 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"crsigma");
464 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"crsigma");
466 cpl_parameterlist_append(recipe->parameters, p);
469 p = cpl_parameter_new_value(
"muse.muse_scipost.rc",
471 "Critical radius for the \"renka\" resampling method.",
474 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"rc");
475 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"rc");
477 cpl_parameterlist_append(recipe->parameters, p);
480 p = cpl_parameter_new_value(
"muse.muse_scipost.pixfrac",
482 "Pixel down-scaling factor for the \"drizzle\" resampling method.",
485 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"pixfrac");
486 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"pixfrac");
488 cpl_parameterlist_append(recipe->parameters, p);
491 p = cpl_parameter_new_value(
"muse.muse_scipost.ld",
493 "Number of adjacent pixels to take into account during resampling in all three directions (loop distance); this affects all resampling methods except \"nearest\".",
496 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ld");
497 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ld");
499 cpl_parameterlist_append(recipe->parameters, p);
502 p = cpl_parameter_new_enum(
"muse.muse_scipost.format",
504 "Type of output file format, \"Cube\" is a standard FITS cube with NAXIS=3 and multiple extensions (for data and variance). The extended \"x\" formats include the reconstructed image(s) in FITS image extensions within the same file.",
506 (
const char *)
"Cube",
508 (
const char *)
"Cube",
509 (
const char *)
"Euro3D",
510 (
const char *)
"xCube",
511 (
const char *)
"xEuro3D");
512 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"format");
513 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"format");
515 cpl_parameterlist_append(recipe->parameters, p);
518 p = cpl_parameter_new_enum(
"muse.muse_scipost.weight",
520 "Type of weighting scheme to use when combining multiple exposures. \"exptime\" just uses the exposure time to weight the exposures, \"fwhm\" uses the DIMM information in the header as well, \"none\" preserves an existing weight column in the input pixel tables without changes.",
522 (
const char *)
"exptime",
524 (
const char *)
"exptime",
525 (
const char *)
"fwhm",
526 (
const char *)
"none");
527 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"weight");
528 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"weight");
530 cpl_parameterlist_append(recipe->parameters, p);
533 p = cpl_parameter_new_value(
"muse.muse_scipost.filter",
535 "The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an EXTNAME in an extension of the FILTER_LIST file. If an unsupported filter name is given, creation of the respective image is omitted. If multiple filter names are given, they have to be comma separated.",
537 (
const char *)
"white");
538 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"filter");
539 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"filter");
541 cpl_parameterlist_append(recipe->parameters, p);
544 p = cpl_parameter_new_enum(
"muse.muse_scipost.skymethod",
546 "The method used to subtract the sky background. \"model\" should work in all cases, it uses a global sky spectrum model with a local LSF. If \"model\" is selected, calibration frames for SKY_LINES and LSF_PROFILE must be set; SKY_CONTINUUM and SKY_MASK are optional. If \"subtract-model\" is selected, precalculated sky lines and continuum are subtracted if specified by SKY_LINES and SKY_CONTINUUM. An LSF_PROFILE is necessary for the two model-based methods.",
548 (
const char *)
"model",
550 (
const char *)
"none",
551 (
const char *)
"subtract-model",
552 (
const char *)
"model");
553 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymethod");
554 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymethod");
556 cpl_parameterlist_append(recipe->parameters, p);
559 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdamin",
561 "Cut off the data below this wavelength after loading the pixel table(s).",
564 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
565 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
567 cpl_parameterlist_append(recipe->parameters, p);
570 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdamax",
572 "Cut off the data above this wavelength after loading the pixel table(s).",
575 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
576 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
578 cpl_parameterlist_append(recipe->parameters, p);
581 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdaref",
583 "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.",
586 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdaref");
587 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdaref");
589 cpl_parameterlist_append(recipe->parameters, p);
592 p = cpl_parameter_new_enum(
"muse.muse_scipost.darcheck",
594 "Carry out a check of the theoretical DAR correction using source centroiding. If \"correct\" it will also apply an empirical correction.",
596 (
const char *)
"none",
598 (
const char *)
"none",
599 (
const char *)
"check",
600 (
const char *)
"correct");
601 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"darcheck");
602 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"darcheck");
604 cpl_parameterlist_append(recipe->parameters, p);
607 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_fraction",
609 "Fraction of the image 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.",
612 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_fraction");
613 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_fraction");
615 cpl_parameterlist_append(recipe->parameters, p);
618 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_sampling",
620 "Spectral sampling of the sky spectrum [Angstrom].",
623 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_sampling");
624 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_sampling");
626 cpl_parameterlist_append(recipe->parameters, p);
629 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_csampling",
631 "Spectral sampling of the continuum spectrum [Angstrom].",
634 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_csampling");
635 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_csampling");
637 cpl_parameterlist_append(recipe->parameters, p);
640 p = cpl_parameter_new_enum(
"muse.muse_scipost.rvcorr",
642 "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).",
644 (
const char *)
"bary",
646 (
const char *)
"bary",
647 (
const char *)
"helio",
649 (
const char *)
"none");
650 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"rvcorr");
651 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"rvcorr");
653 cpl_parameterlist_append(recipe->parameters, p);
656 p = cpl_parameter_new_value(
"muse.muse_scipost.astrometry",
658 "If false, skip any astrometric calibration, even if one was passed in the input set of files. This causes creation of an output cube with a linear WCS and may result in errors. If you want to use a sensible default, leave this true but do not pass an ASTROMETRY_WCS.",
661 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"astrometry");
662 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"astrometry");
664 cpl_parameterlist_append(recipe->parameters, p);
684 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
685 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
688 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.save");
689 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
690 aParams->
save = cpl_parameter_get_string(p);
692 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.resample");
693 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
694 aParams->
resample_s = cpl_parameter_get_string(p);
696 (!strcasecmp(aParams->
resample_s,
"nearest")) ? MUSE_SCIPOST_PARAM_RESAMPLE_NEAREST :
697 (!strcasecmp(aParams->
resample_s,
"linear")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LINEAR :
698 (!strcasecmp(aParams->
resample_s,
"quadratic")) ? MUSE_SCIPOST_PARAM_RESAMPLE_QUADRATIC :
699 (!strcasecmp(aParams->
resample_s,
"renka")) ? MUSE_SCIPOST_PARAM_RESAMPLE_RENKA :
700 (!strcasecmp(aParams->
resample_s,
"drizzle")) ? MUSE_SCIPOST_PARAM_RESAMPLE_DRIZZLE :
701 (!strcasecmp(aParams->
resample_s,
"lanczos")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LANCZOS :
702 MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE;
703 cpl_ensure_code(aParams->
resample != MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE,
704 CPL_ERROR_ILLEGAL_INPUT);
706 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dx");
707 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
708 aParams->
dx = cpl_parameter_get_double(p);
710 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dy");
711 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
712 aParams->
dy = cpl_parameter_get_double(p);
714 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dlambda");
715 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
716 aParams->
dlambda = cpl_parameter_get_double(p);
718 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.crtype");
719 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
720 aParams->
crtype_s = cpl_parameter_get_string(p);
722 (!strcasecmp(aParams->
crtype_s,
"iraf")) ? MUSE_SCIPOST_PARAM_CRTYPE_IRAF :
723 (!strcasecmp(aParams->
crtype_s,
"mean")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEAN :
724 (!strcasecmp(aParams->
crtype_s,
"median")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEDIAN :
725 MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE;
726 cpl_ensure_code(aParams->
crtype != MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE,
727 CPL_ERROR_ILLEGAL_INPUT);
729 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.crsigma");
730 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
731 aParams->
crsigma = cpl_parameter_get_double(p);
733 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.rc");
734 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
735 aParams->
rc = cpl_parameter_get_double(p);
737 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.pixfrac");
738 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
739 aParams->
pixfrac = cpl_parameter_get_double(p);
741 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.ld");
742 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
743 aParams->
ld = cpl_parameter_get_int(p);
745 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.format");
746 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
747 aParams->
format_s = cpl_parameter_get_string(p);
749 (!strcasecmp(aParams->
format_s,
"Cube")) ? MUSE_SCIPOST_PARAM_FORMAT_CUBE :
750 (!strcasecmp(aParams->
format_s,
"Euro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_EURO3D :
751 (!strcasecmp(aParams->
format_s,
"xCube")) ? MUSE_SCIPOST_PARAM_FORMAT_XCUBE :
752 (!strcasecmp(aParams->
format_s,
"xEuro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_XEURO3D :
753 MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE;
754 cpl_ensure_code(aParams->
format != MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE,
755 CPL_ERROR_ILLEGAL_INPUT);
757 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.weight");
758 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
759 aParams->
weight_s = cpl_parameter_get_string(p);
761 (!strcasecmp(aParams->
weight_s,
"exptime")) ? MUSE_SCIPOST_PARAM_WEIGHT_EXPTIME :
762 (!strcasecmp(aParams->
weight_s,
"fwhm")) ? MUSE_SCIPOST_PARAM_WEIGHT_FWHM :
763 (!strcasecmp(aParams->
weight_s,
"none")) ? MUSE_SCIPOST_PARAM_WEIGHT_NONE :
764 MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE;
765 cpl_ensure_code(aParams->
weight != MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE,
766 CPL_ERROR_ILLEGAL_INPUT);
768 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.filter");
769 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
770 aParams->
filter = cpl_parameter_get_string(p);
772 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymethod");
773 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
774 aParams->
skymethod_s = cpl_parameter_get_string(p);
776 (!strcasecmp(aParams->
skymethod_s,
"none")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_NONE :
777 (!strcasecmp(aParams->
skymethod_s,
"subtract-model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL :
778 (!strcasecmp(aParams->
skymethod_s,
"model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL :
779 MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE;
780 cpl_ensure_code(aParams->
skymethod != MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE,
781 CPL_ERROR_ILLEGAL_INPUT);
783 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdamin");
784 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
785 aParams->
lambdamin = cpl_parameter_get_double(p);
787 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdamax");
788 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
789 aParams->
lambdamax = cpl_parameter_get_double(p);
791 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdaref");
792 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
793 aParams->
lambdaref = cpl_parameter_get_double(p);
795 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.darcheck");
796 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
797 aParams->
darcheck_s = cpl_parameter_get_string(p);
799 (!strcasecmp(aParams->
darcheck_s,
"none")) ? MUSE_SCIPOST_PARAM_DARCHECK_NONE :
800 (!strcasecmp(aParams->
darcheck_s,
"check")) ? MUSE_SCIPOST_PARAM_DARCHECK_CHECK :
801 (!strcasecmp(aParams->
darcheck_s,
"correct")) ? MUSE_SCIPOST_PARAM_DARCHECK_CORRECT :
802 MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE;
803 cpl_ensure_code(aParams->
darcheck != MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE,
804 CPL_ERROR_ILLEGAL_INPUT);
806 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_fraction");
807 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
810 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_sampling");
811 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
814 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_csampling");
815 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
818 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.rvcorr");
819 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
820 aParams->
rvcorr_s = cpl_parameter_get_string(p);
822 (!strcasecmp(aParams->
rvcorr_s,
"bary")) ? MUSE_SCIPOST_PARAM_RVCORR_BARY :
823 (!strcasecmp(aParams->
rvcorr_s,
"helio")) ? MUSE_SCIPOST_PARAM_RVCORR_HELIO :
824 (!strcasecmp(aParams->
rvcorr_s,
"geo")) ? MUSE_SCIPOST_PARAM_RVCORR_GEO :
825 (!strcasecmp(aParams->
rvcorr_s,
"none")) ? MUSE_SCIPOST_PARAM_RVCORR_NONE :
826 MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE;
827 cpl_ensure_code(aParams->
rvcorr != MUSE_SCIPOST_PARAM_RVCORR_INVALID_VALUE,
828 CPL_ERROR_ILLEGAL_INPUT);
830 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.astrometry");
831 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
832 aParams->
astrometry = cpl_parameter_get_bool(p);
846 muse_scipost_exec(cpl_plugin *aPlugin)
848 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
851 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
852 cpl_msg_set_threadid_on();
854 cpl_frameset *usedframes = cpl_frameset_new(),
855 *outframes = cpl_frameset_new();
857 muse_scipost_params_fill(¶ms, recipe->parameters);
859 cpl_errorstate prestate = cpl_errorstate_get();
863 int rc = muse_scipost_compute(proc, ¶ms);
864 cpl_frameset_join(usedframes, proc->
usedframes);
865 cpl_frameset_join(outframes, proc->
outframes);
868 if (!cpl_errorstate_is_equal(prestate)) {
872 cpl_msg_set_level(CPL_MSG_INFO);
883 cpl_frameset_join(recipe->frames, usedframes);
884 cpl_frameset_join(recipe->frames, outframes);
885 cpl_frameset_delete(usedframes);
886 cpl_frameset_delete(outframes);
899 muse_scipost_destroy(cpl_plugin *aPlugin)
903 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
904 recipe = (cpl_recipe *)aPlugin;
910 cpl_parameterlist_delete(recipe->parameters);
927 cpl_plugin_get_info(cpl_pluginlist *aList)
929 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
930 cpl_plugin *plugin = &recipe->interface;
934 helptext = cpl_sprintf(
"%s%s", muse_scipost_help,
935 muse_scipost_help_esorex);
937 helptext = cpl_sprintf(
"%s", muse_scipost_help);
941 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
942 CPL_PLUGIN_TYPE_RECIPE,
944 "Prepare reduced and combined science products.",
951 muse_scipost_destroy);
952 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
int rvcorr
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
const char * skymethod_s
The method used to subtract the sky background. "model" should work in all cases, it uses a global sk...
const char * darcheck_s
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
int ld
Number of adjacent pixels to take into account during resampling in all three directions (loop distan...
const char * rvcorr_s
Correct the radial velocity of the telescope with reference to either the barycenter of the Solar Sys...
const char * filter
The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an E...
cpl_frameset * usedframes
muse_processing * muse_processing_new(const char *aName, cpl_recipe *aRecipe)
Create a new processing structure.
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
const char * muse_get_license(void)
Get the pipeline copyright and license.
double dy
Vertical step size for resampling (in arcsec or pixel). The following defaults are taken when this va...
double pixfrac
Pixel down-scaling factor for the "drizzle" resampling method.
double lambdaref
Reference wavelength used for correction of differential atmospheric refraction. The R-band (peak wav...
double rc
Critical radius for the "renka" resampling method.
double skymodel_fraction
Fraction of the image to be considered as sky. If an input sky mask is provided, the fraction is appl...
void muse_cplerrorstate_dump_some(unsigned aCurrent, unsigned aFirst, unsigned aLast)
Dump some CPL errors.
const char * crtype_s
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
void muse_processinginfo_delete(cpl_recipe *)
Clear all information from the processing info and from the recipe config.
int darcheck
Carry out a check of the theoretical DAR correction using source centroiding. If "correct" it will al...
double skymodel_sampling
Spectral sampling of the sky spectrum [Angstrom].
int astrometry
If false, skip any astrometric calibration, even if one was passed in the input set of files...
double skymodel_csampling
Spectral sampling of the continuum spectrum [Angstrom].
int weight
Type of weighting scheme to use when combining multiple exposures. "exptime" just uses the exposure t...
const char * format_s
Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for ...
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.
double dx
Horizontal step size for resampling (in arcsec or pixel). The following defaults are taken when this ...
cpl_error_code muse_cplframeset_erase_all(cpl_frameset *aFrames)
Erase all frames in a frameset.
int skymethod
The method used to subtract the sky background. "model" should work in all cases, it uses a global sk...
Structure to hold the parameters of the muse_scipost recipe.
double crsigma
Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative va...
int resample
The resampling technique to use for the final output cube.
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 dlambda
Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0...
int format
Type of output file format, "Cube" is a standard FITS cube with NAXIS=3 and multiple extensions (for ...
const char * resample_s
The resampling technique to use for the final output cube. (as string)
int crtype
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
cpl_error_code muse_processing_prepare_property(cpl_propertylist *, const char *, cpl_type, const char *)
Prepare and check the specified property.
const char * save
Select output product(s) to save. Can contain one or more of "cube", "skymodel", "individual", "positioned", "combined", and "stacked". If several options are given, they have to be comma-separated. ("cube": output cube and associated images, if this is not given, no final resampling is done at all – "skymodel": up to four additional output products about the effectively used sky that was subtracted with the "model" method – "individual": fully reduced pixel table for each individual exposure – "positioned": fully reduced and positioned pixel table for each individual exposure, the difference to "individual" is that here, the output pixel tables have coordinates in RA and DEC; this is only useful, if both the relative exposure weighting and the final resampling are to be done externally – "combined": fully reduced and combined pixel table for the full set of exposures, the difference to "positioned" is that all pixel tables are combined into one, with an added weight column; this is useful, if only the final resampling step is to be done separately – "stacked": an additional output file in form of a 2D column-stacked image, i.e. x direction is pseudo-spatial, y direction is wavelength.)