35 #include "muse_scipost_z.h"
52 static const char *muse_scipost_help =
53 "Merge pixel tables from all IFUs, apply on-sky calibrations, and resample the data from all exposures into the final datacube.";
55 static const char *muse_scipost_help_esorex =
56 "\n\nInput frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
57 "\n Frame tag Type Req #Fr Description"
58 "\n -------------------- ---- --- --- ------------"
59 "\n PIXTABLE_OBJECT raw Y Pixel table of a science object"
60 "\n EXTINCT_TABLE calib Y 1 Atmospheric extinction table"
61 "\n STD_RESPONSE calib Y 1 Response curve as derived from standard star(s)"
62 "\n STD_TELLURIC calib . 1 Telluric absorption as derived from standard star(s)"
63 "\n ASTROMETRY_WCS calib . 1 Astrometric solution derived from astrometric science frame"
64 "\n FILTER_LIST calib . 1 File to be used to create field-of-view images."
65 "\n OUTPUT_WCS calib . 1 WCS to override output cube location / dimensions"
66 "\n SKY_LINES calib . 1 List of OH transitions and other sky lines"
67 "\n SKY_CONTINUUM calib . 1 Sky continuum to use"
68 "\n LSF_TABLE calib . Slice specific LSF parameters."
69 "\n SKY_MASK calib . 1 Sky mask to use"
70 "\n\nProduct frames for raw frame tag \"PIXTABLE_OBJECT\":\n"
71 "\n Frame tag Level Description"
72 "\n -------------------- -------- ------------"
73 "\n DATACUBE_FINAL final Output datacube"
74 "\n IMAGE_FOV final Field-of-view images corresponding to the \"filter\" parameter."
75 "\n OBJECT_RESAMPLED final Stacked image (if --stacked=true)"
76 "\n PIXTABLE_REDUCED intermed Fully reduced pixel tables for each exposure (if --save_individual=true)"
77 "\n PIXTABLE_POSITIONED intermed Fully reduced and positioned pixel table for each individual exposure (if --save_positioned=true)"
78 "\n PIXTABLE_COMBINED intermed Fully reduced and combined pixel table for the full set of exposures (if --save_combined=true)"
79 "\n SKY_MASK intermed Created sky mask"
80 "\n SKY_SPECTRUM intermed Sky spectrum within the sky mask";
91 static cpl_recipeconfig *
92 muse_scipost_new_recipeconfig(
void)
94 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
97 tag =
"PIXTABLE_OBJECT";
98 cpl_recipeconfig_set_tag(recipeconfig, tag, 1, -1);
99 cpl_recipeconfig_set_input(recipeconfig, tag,
"EXTINCT_TABLE", 1, 1);
100 cpl_recipeconfig_set_input(recipeconfig, tag,
"STD_RESPONSE", 1, 1);
101 cpl_recipeconfig_set_input(recipeconfig, tag,
"STD_TELLURIC", -1, 1);
102 cpl_recipeconfig_set_input(recipeconfig, tag,
"ASTROMETRY_WCS", -1, 1);
103 cpl_recipeconfig_set_input(recipeconfig, tag,
"FILTER_LIST", -1, 1);
104 cpl_recipeconfig_set_input(recipeconfig, tag,
"OUTPUT_WCS", -1, 1);
105 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_LINES", 0, 1);
106 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_CONTINUUM", 0, 1);
107 cpl_recipeconfig_set_input(recipeconfig, tag,
"LSF_TABLE", 0, -1);
108 cpl_recipeconfig_set_input(recipeconfig, tag,
"SKY_MASK", 0, 1);
109 cpl_recipeconfig_set_output(recipeconfig, tag,
"DATACUBE_FINAL");
110 cpl_recipeconfig_set_output(recipeconfig, tag,
"IMAGE_FOV");
111 cpl_recipeconfig_set_output(recipeconfig, tag,
"OBJECT_RESAMPLED");
112 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_REDUCED");
113 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_POSITIONED");
114 cpl_recipeconfig_set_output(recipeconfig, tag,
"PIXTABLE_COMBINED");
115 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_MASK");
116 cpl_recipeconfig_set_output(recipeconfig, tag,
"SKY_SPECTRUM");
132 static cpl_error_code
133 muse_scipost_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
135 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
136 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
137 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
140 "[pix] Position of source k in x-direction in combined frame");
143 "[pix] Position of source k in y-direction in combined frame");
146 "[arcsec] FWHM of source k in x-direction in combined frame");
149 "[arcsec] FWHM of source k in y-direction in combined frame");
150 }
else if (!strcmp(aFrametag,
"IMAGE_FOV")) {
153 "[pix] Position of source k in x-direction in combined frame");
156 "[pix] Position of source k in y-direction in combined frame");
159 "[arcsec] FWHM of source k in x-direction in combined frame");
162 "[arcsec] FWHM of source k in y-direction in combined frame");
163 }
else if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
164 }
else if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
165 }
else if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
166 }
else if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
167 }
else if (!strcmp(aFrametag,
"SKY_MASK")) {
170 "Threshold in the white light considered as sky, used to create this mask");
171 }
else if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
173 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
174 return CPL_ERROR_ILLEGAL_INPUT;
176 return CPL_ERROR_NONE;
189 static cpl_frame_level
190 muse_scipost_get_frame_level(
const char *aFrametag)
193 return CPL_FRAME_LEVEL_NONE;
195 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
196 return CPL_FRAME_LEVEL_FINAL;
198 if (!strcmp(aFrametag,
"IMAGE_FOV")) {
199 return CPL_FRAME_LEVEL_FINAL;
201 if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
202 return CPL_FRAME_LEVEL_FINAL;
204 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
205 return CPL_FRAME_LEVEL_INTERMEDIATE;
207 if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
208 return CPL_FRAME_LEVEL_INTERMEDIATE;
210 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
211 return CPL_FRAME_LEVEL_INTERMEDIATE;
213 if (!strcmp(aFrametag,
"SKY_MASK")) {
214 return CPL_FRAME_LEVEL_INTERMEDIATE;
216 if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
217 return CPL_FRAME_LEVEL_INTERMEDIATE;
219 return CPL_FRAME_LEVEL_NONE;
233 muse_scipost_get_frame_mode(
const char *aFrametag)
238 if (!strcmp(aFrametag,
"DATACUBE_FINAL")) {
241 if (!strcmp(aFrametag,
"IMAGE_FOV")) {
244 if (!strcmp(aFrametag,
"OBJECT_RESAMPLED")) {
247 if (!strcmp(aFrametag,
"PIXTABLE_REDUCED")) {
250 if (!strcmp(aFrametag,
"PIXTABLE_POSITIONED")) {
253 if (!strcmp(aFrametag,
"PIXTABLE_COMBINED")) {
256 if (!strcmp(aFrametag,
"SKY_MASK")) {
259 if (!strcmp(aFrametag,
"SKY_SPECTRUM")) {
277 muse_scipost_create(cpl_plugin *aPlugin)
281 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
282 recipe = (cpl_recipe *)aPlugin;
290 muse_scipost_new_recipeconfig(),
291 muse_scipost_prepare_header,
292 muse_scipost_get_frame_level,
293 muse_scipost_get_frame_mode);
298 cpl_msg_set_time_on();
302 recipe->parameters = cpl_parameterlist_new();
307 p = cpl_parameter_new_enum(
"muse.muse_scipost.resample",
309 "The resampling technique to use for the final output cube.",
311 (
const char *)
"drizzle",
313 (
const char *)
"nearest",
314 (
const char *)
"linear",
315 (
const char *)
"quadratic",
316 (
const char *)
"renka",
317 (
const char *)
"drizzle",
318 (
const char *)
"lanczos");
319 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"resample");
320 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"resample");
322 cpl_parameterlist_append(recipe->parameters, p);
325 p = cpl_parameter_new_value(
"muse.muse_scipost.dx",
327 "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.",
330 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dx");
331 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dx");
333 cpl_parameterlist_append(recipe->parameters, p);
336 p = cpl_parameter_new_value(
"muse.muse_scipost.dy",
338 "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.",
341 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dy");
342 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dy");
344 cpl_parameterlist_append(recipe->parameters, p);
347 p = cpl_parameter_new_value(
"muse.muse_scipost.dlambda",
349 "Wavelength step size (in Angstrom). Natural instrument sampling is used, if this is 0.0",
352 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"dlambda");
353 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"dlambda");
355 cpl_parameterlist_append(recipe->parameters, p);
358 p = cpl_parameter_new_enum(
"muse.muse_scipost.crtype",
360 "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 median deviation statistics.",
362 (
const char *)
"median",
364 (
const char *)
"iraf",
365 (
const char *)
"mean",
366 (
const char *)
"median");
367 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"crtype");
368 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"crtype");
370 cpl_parameterlist_append(recipe->parameters, p);
373 p = cpl_parameter_new_value(
"muse.muse_scipost.crsigma",
375 "Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative value switches cosmic ray rejection off.",
378 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"crsigma");
379 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"crsigma");
381 cpl_parameterlist_append(recipe->parameters, p);
384 p = cpl_parameter_new_value(
"muse.muse_scipost.rc",
386 "Critical radius for the \"renka\" resampling method.",
389 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"rc");
390 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"rc");
392 cpl_parameterlist_append(recipe->parameters, p);
395 p = cpl_parameter_new_value(
"muse.muse_scipost.pixfrac",
397 "Pixel down-scaling factor for the \"drizzle\" resampling method.",
400 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"pixfrac");
401 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"pixfrac");
403 cpl_parameterlist_append(recipe->parameters, p);
406 p = cpl_parameter_new_value(
"muse.muse_scipost.ld",
408 "Number of adjacent pixels to take into account during resampling in all three directions (loop distance); this affects all resampling methods except \"nearest\".",
411 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ld");
412 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ld");
414 cpl_parameterlist_append(recipe->parameters, p);
417 p = cpl_parameter_new_enum(
"muse.muse_scipost.format",
419 "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.",
421 (
const char *)
"Cube",
423 (
const char *)
"Cube",
424 (
const char *)
"Euro3D",
425 (
const char *)
"xCube",
426 (
const char *)
"xEuro3D");
427 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"format");
428 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"format");
430 cpl_parameterlist_append(recipe->parameters, p);
433 p = cpl_parameter_new_enum(
"muse.muse_scipost.weight",
435 "Type of weighting scheme to use when combining multiple exposures.",
437 (
const char *)
"exptime",
439 (
const char *)
"exptime",
440 (
const char *)
"fwhm");
441 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"weight");
442 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"weight");
444 cpl_parameterlist_append(recipe->parameters, p);
447 p = cpl_parameter_new_value(
"muse.muse_scipost.filter",
449 "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.",
451 (
const char *)
"white");
452 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"filter");
453 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"filter");
455 cpl_parameterlist_append(recipe->parameters, p);
458 p = cpl_parameter_new_enum(
"muse.muse_scipost.skymethod",
460 "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; \"row-by-row\" works on the basis of single slices and needs sufficient sky in each slice. If \"model\" is selected, calibration frames for SKY_LINES and LSF_TABLE must be set; SKY_CONTINUUM and SKY_MASK are optional. If \"subtract-model\" is selected, precalculated sky lines may be subtracted if specified by SKY_LINES, SKY_CONTINUUM, and LSF_TABLE.",
462 (
const char *)
"model",
464 (
const char *)
"none",
465 (
const char *)
"subtract-model",
466 (
const char *)
"model",
467 (
const char *)
"row-by-row");
468 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymethod");
469 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymethod");
471 cpl_parameterlist_append(recipe->parameters, p);
474 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdamin",
476 "Cut off the data below this wavelength after loading the pixel table(s).",
479 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamin");
480 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamin");
482 cpl_parameterlist_append(recipe->parameters, p);
485 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdamax",
487 "Cut off the data above this wavelength after loading the pixel table(s).",
490 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdamax");
491 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdamax");
493 cpl_parameterlist_append(recipe->parameters, p);
496 p = cpl_parameter_new_value(
"muse.muse_scipost.lambdaref",
498 "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.",
501 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lambdaref");
502 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lambdaref");
504 cpl_parameterlist_append(recipe->parameters, p);
507 p = cpl_parameter_new_enum(
"muse.muse_scipost.darcheck",
509 "Carry out a check of the theoretical DAR correction using source centroiding. If \"correct\" it will also apply an empirical correction.",
511 (
const char *)
"none",
513 (
const char *)
"none",
514 (
const char *)
"check",
515 (
const char *)
"correct");
516 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"darcheck");
517 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"darcheck");
519 cpl_parameterlist_append(recipe->parameters, p);
522 p = cpl_parameter_new_value(
"muse.muse_scipost.save_individual",
524 "If true, save fully reduced pixel table for each individual exposure as output product.",
527 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"save_individual");
528 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"save_individual");
530 cpl_parameterlist_append(recipe->parameters, p);
533 p = cpl_parameter_new_value(
"muse.muse_scipost.save_positioned",
535 "If true, save fully reduced and positioned pixel table for each individual exposure as output product. The difference to save_individual is that here, the output pixel tables have coordinates in RA and DEC. This is useful, if both the relative exposure weighting and the final resampling are to be done externally.",
538 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"save_positioned");
539 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"save_positioned");
541 cpl_parameterlist_append(recipe->parameters, p);
544 p = cpl_parameter_new_value(
"muse.muse_scipost.save_combined",
546 "If true, save the fully reduced and combined pixel table for the full set of exposures. The difference to save_positioned is that here 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.",
549 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"save_combined");
550 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"save_combined");
552 cpl_parameterlist_append(recipe->parameters, p);
555 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_fraction",
557 "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.",
560 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_fraction");
561 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_fraction");
563 cpl_parameterlist_append(recipe->parameters, p);
566 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_sampling",
568 "Spectral sampling of the sky spectrum [Angstrom].",
571 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_sampling");
572 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_sampling");
574 cpl_parameterlist_append(recipe->parameters, p);
577 p = cpl_parameter_new_value(
"muse.muse_scipost.skymodel_csampling",
579 "Spectral sampling of the continuum spectrum [Angstrom].",
582 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"skymodel_csampling");
583 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"skymodel_csampling");
585 cpl_parameterlist_append(recipe->parameters, p);
588 p = cpl_parameter_new_value(
"muse.muse_scipost.astrometry",
590 "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.",
593 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"astrometry");
594 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"astrometry");
596 cpl_parameterlist_append(recipe->parameters, p);
599 p = cpl_parameter_new_value(
"muse.muse_scipost.stacked",
601 "If true, write an additional output file in form of a 2D stacked image (x direction is pseudo-spatial, y direction is wavelength).",
604 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"stacked");
605 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"stacked");
607 cpl_parameterlist_append(recipe->parameters, p);
627 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
628 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
631 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.resample");
632 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
633 aParams->
resample_s = cpl_parameter_get_string(p);
635 (!strcasecmp(aParams->
resample_s,
"nearest")) ? MUSE_SCIPOST_PARAM_RESAMPLE_NEAREST :
636 (!strcasecmp(aParams->
resample_s,
"linear")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LINEAR :
637 (!strcasecmp(aParams->
resample_s,
"quadratic")) ? MUSE_SCIPOST_PARAM_RESAMPLE_QUADRATIC :
638 (!strcasecmp(aParams->
resample_s,
"renka")) ? MUSE_SCIPOST_PARAM_RESAMPLE_RENKA :
639 (!strcasecmp(aParams->
resample_s,
"drizzle")) ? MUSE_SCIPOST_PARAM_RESAMPLE_DRIZZLE :
640 (!strcasecmp(aParams->
resample_s,
"lanczos")) ? MUSE_SCIPOST_PARAM_RESAMPLE_LANCZOS :
641 MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE;
642 cpl_ensure_code(aParams->
resample != MUSE_SCIPOST_PARAM_RESAMPLE_INVALID_VALUE,
643 CPL_ERROR_ILLEGAL_INPUT);
645 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dx");
646 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
647 aParams->
dx = cpl_parameter_get_double(p);
649 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dy");
650 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
651 aParams->
dy = cpl_parameter_get_double(p);
653 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.dlambda");
654 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
655 aParams->
dlambda = cpl_parameter_get_double(p);
657 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.crtype");
658 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
659 aParams->
crtype_s = cpl_parameter_get_string(p);
661 (!strcasecmp(aParams->
crtype_s,
"iraf")) ? MUSE_SCIPOST_PARAM_CRTYPE_IRAF :
662 (!strcasecmp(aParams->
crtype_s,
"mean")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEAN :
663 (!strcasecmp(aParams->
crtype_s,
"median")) ? MUSE_SCIPOST_PARAM_CRTYPE_MEDIAN :
664 MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE;
665 cpl_ensure_code(aParams->
crtype != MUSE_SCIPOST_PARAM_CRTYPE_INVALID_VALUE,
666 CPL_ERROR_ILLEGAL_INPUT);
668 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.crsigma");
669 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
670 aParams->
crsigma = cpl_parameter_get_double(p);
672 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.rc");
673 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
674 aParams->
rc = cpl_parameter_get_double(p);
676 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.pixfrac");
677 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
678 aParams->
pixfrac = cpl_parameter_get_double(p);
680 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.ld");
681 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
682 aParams->
ld = cpl_parameter_get_int(p);
684 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.format");
685 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
686 aParams->
format_s = cpl_parameter_get_string(p);
688 (!strcasecmp(aParams->
format_s,
"Cube")) ? MUSE_SCIPOST_PARAM_FORMAT_CUBE :
689 (!strcasecmp(aParams->
format_s,
"Euro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_EURO3D :
690 (!strcasecmp(aParams->
format_s,
"xCube")) ? MUSE_SCIPOST_PARAM_FORMAT_XCUBE :
691 (!strcasecmp(aParams->
format_s,
"xEuro3D")) ? MUSE_SCIPOST_PARAM_FORMAT_XEURO3D :
692 MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE;
693 cpl_ensure_code(aParams->
format != MUSE_SCIPOST_PARAM_FORMAT_INVALID_VALUE,
694 CPL_ERROR_ILLEGAL_INPUT);
696 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.weight");
697 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
698 aParams->
weight_s = cpl_parameter_get_string(p);
700 (!strcasecmp(aParams->
weight_s,
"exptime")) ? MUSE_SCIPOST_PARAM_WEIGHT_EXPTIME :
701 (!strcasecmp(aParams->
weight_s,
"fwhm")) ? MUSE_SCIPOST_PARAM_WEIGHT_FWHM :
702 MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE;
703 cpl_ensure_code(aParams->
weight != MUSE_SCIPOST_PARAM_WEIGHT_INVALID_VALUE,
704 CPL_ERROR_ILLEGAL_INPUT);
706 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.filter");
707 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
708 aParams->
filter = cpl_parameter_get_string(p);
710 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymethod");
711 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
712 aParams->
skymethod_s = cpl_parameter_get_string(p);
714 (!strcasecmp(aParams->
skymethod_s,
"none")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_NONE :
715 (!strcasecmp(aParams->
skymethod_s,
"subtract-model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_SUBTRACT_MODEL :
716 (!strcasecmp(aParams->
skymethod_s,
"model")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_MODEL :
717 (!strcasecmp(aParams->
skymethod_s,
"row-by-row")) ? MUSE_SCIPOST_PARAM_SKYMETHOD_ROW_BY_ROW :
718 MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE;
719 cpl_ensure_code(aParams->
skymethod != MUSE_SCIPOST_PARAM_SKYMETHOD_INVALID_VALUE,
720 CPL_ERROR_ILLEGAL_INPUT);
722 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdamin");
723 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
724 aParams->
lambdamin = cpl_parameter_get_double(p);
726 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdamax");
727 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
728 aParams->
lambdamax = cpl_parameter_get_double(p);
730 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.lambdaref");
731 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
732 aParams->
lambdaref = cpl_parameter_get_double(p);
734 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.darcheck");
735 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
736 aParams->
darcheck_s = cpl_parameter_get_string(p);
738 (!strcasecmp(aParams->
darcheck_s,
"none")) ? MUSE_SCIPOST_PARAM_DARCHECK_NONE :
739 (!strcasecmp(aParams->
darcheck_s,
"check")) ? MUSE_SCIPOST_PARAM_DARCHECK_CHECK :
740 (!strcasecmp(aParams->
darcheck_s,
"correct")) ? MUSE_SCIPOST_PARAM_DARCHECK_CORRECT :
741 MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE;
742 cpl_ensure_code(aParams->
darcheck != MUSE_SCIPOST_PARAM_DARCHECK_INVALID_VALUE,
743 CPL_ERROR_ILLEGAL_INPUT);
745 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.save_individual");
746 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
749 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.save_positioned");
750 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
753 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.save_combined");
754 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
757 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_fraction");
758 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
761 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_sampling");
762 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
765 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.skymodel_csampling");
766 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
769 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.astrometry");
770 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
771 aParams->
astrometry = cpl_parameter_get_bool(p);
773 p = cpl_parameterlist_find(aParameters,
"muse.muse_scipost.stacked");
774 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
775 aParams->
stacked = cpl_parameter_get_bool(p);
789 muse_scipost_exec(cpl_plugin *aPlugin)
791 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
794 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
795 cpl_msg_set_threadid_on();
797 cpl_frameset *usedframes = cpl_frameset_new(),
798 *outframes = cpl_frameset_new();
800 muse_scipost_params_fill(¶ms, recipe->parameters);
802 cpl_errorstate prestate = cpl_errorstate_get();
806 int rc = muse_scipost_compute(proc, ¶ms);
807 cpl_frameset_join(usedframes, proc->
usedFrames);
811 if (!cpl_errorstate_is_equal(prestate)) {
815 cpl_msg_set_level(CPL_MSG_INFO);
825 cpl_frameset_join(recipe->frames, usedframes);
826 cpl_frameset_join(recipe->frames, outframes);
827 cpl_frameset_delete(usedframes);
828 cpl_frameset_delete(outframes);
841 muse_scipost_destroy(cpl_plugin *aPlugin)
845 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
846 recipe = (cpl_recipe *)aPlugin;
852 cpl_parameterlist_delete(recipe->parameters);
869 cpl_plugin_get_info(cpl_pluginlist *aList)
871 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
872 cpl_plugin *plugin = &recipe->interface;
876 helptext = cpl_sprintf(
"%s%s", muse_scipost_help,
877 muse_scipost_help_esorex);
879 helptext = cpl_sprintf(
"%s", muse_scipost_help);
883 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
884 CPL_PLUGIN_TYPE_RECIPE,
886 "Prepare reduced and combined science products.",
893 muse_scipost_destroy);
894 cpl_pluginlist_append(aList, plugin);
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
double lambdamin
Cut off the data below this wavelength after loading the pixel table(s).
int save_combined
If true, save the fully reduced and combined pixel table for the full set of exposures. The difference to save_positioned is that here 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.
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 * filter
The filter name(s) to be used for the output field-of-view image. Each name has to correspond to an E...
const char * weight_s
Type of weighting scheme to use when combining multiple exposures. (as string)
const char * muse_get_license(void)
Get the pipeline copyright and license.
muse_processing * muse_processing_new(const char *aRecipeName, cpl_recipe *aRecipe)
Create a new processing structure.
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.
cpl_frameset * outputFrames
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.
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.
cpl_frameset * usedFrames
int save_individual
If true, save fully reduced pixel table for each individual exposure as output product.
int save_positioned
If true, save fully reduced and positioned pixel table for each individual exposure as output product...
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 ...
int stacked
If true, write an additional output file in form of a 2D stacked image (x direction is pseudo-spatial...
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.