35 #include "muse_flat_z.h" 75 static const char *muse_flat_help =
76 "This recipe combines several separate flat-field images into one master flat-field file and traces the location of the slices on the CCD. The master flat contains the combined pixel values of the raw flat exposures, with respect to the image combination method used, normalized to the mean flux. The trace table contains polynomials defining the location of the slices on the CCD. Processing trims the raw data and records the overscan statistics, subtracts the bias (taking account of the overscan, if --overscan is not \"none\"), and optionally, the dark from each raw input image, converts them from adu to count, scales them according to their exposure time, and combines the exposures using input parameters. To trace the position of the slices on the CCD, their edges are located using a threshold method. The edge detection is repeated at given intervals thereby tracing the central position (the mean of both edges) and width of each slit vertically across the CCD. Deviant positions of detections on CCD rows can be detected and excluded before fitting a polynomial to all positions measured for one slice. The polynomial parameters for each slice are saved in the output trace table. Finally, the area between the now known slice edges is searched for dark (and bright) pixels, using statistics in each row of the master flat.";
78 static const char *muse_flat_help_esorex =
79 "\n\nInput frames for raw frame tag \"FLAT\":\n" 80 "\n Frame tag Type Req #Fr Description" 81 "\n -------------------- ---- --- --- ------------" 82 "\n FLAT raw Y >=3 Raw flat" 83 "\n MASTER_BIAS calib Y 1 Master bias" 84 "\n MASTER_DARK calib . 1 Master dark" 85 "\n BADPIX_TABLE calib . Known bad pixels" 86 "\n\nProduct frames for raw frame tag \"FLAT\":\n" 87 "\n Frame tag Level Description" 88 "\n -------------------- -------- ------------" 89 "\n MASTER_FLAT final Master flat" 90 "\n TRACE_TABLE final Trace table" 91 "\n TRACE_SAMPLES final Table containing all tracing sample points, if --samples=true";
102 static cpl_recipeconfig *
103 muse_flat_new_recipeconfig(
void)
105 cpl_recipeconfig *recipeconfig = cpl_recipeconfig_new();
107 cpl_recipeconfig_set_tag(recipeconfig,
"FLAT", 3, -1);
108 cpl_recipeconfig_set_input(recipeconfig,
"FLAT",
"MASTER_BIAS", 1, 1);
109 cpl_recipeconfig_set_input(recipeconfig,
"FLAT",
"MASTER_DARK", -1, 1);
110 cpl_recipeconfig_set_input(recipeconfig,
"FLAT",
"BADPIX_TABLE", -1, -1);
111 cpl_recipeconfig_set_output(recipeconfig,
"FLAT",
"MASTER_FLAT");
112 cpl_recipeconfig_set_output(recipeconfig,
"FLAT",
"TRACE_TABLE");
113 cpl_recipeconfig_set_output(recipeconfig,
"FLAT",
"TRACE_SAMPLES");
129 static cpl_error_code
130 muse_flat_prepare_header(
const char *aFrametag, cpl_propertylist *aHeader)
132 cpl_ensure_code(aFrametag, CPL_ERROR_NULL_INPUT);
133 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
134 if (!strcmp(aFrametag,
"MASTER_FLAT")) {
137 "Median value of raw flat i in input list");
140 "Mean value of raw flat i in input list");
143 "Standard deviation of raw flat i in input list");
146 "Minimum value of raw flat i in input list");
149 "Maximum value of raw flat i in input list");
152 "Number of saturated pixels in raw flat i in input list");
155 "Median value of the master flat before normalization");
158 "Mean value of the master flat before normalization");
161 "Standard deviation of the master flat before normalization");
164 "Minimum value of the master flat before normalization");
167 "Maximum value of the master flat before normalization");
170 "Flux value, integrated over the whole master flat field before normalization");
173 "Number of saturated pixels in output data");
176 "Mean value around the vertical center of slice j before normalization");
179 "Standard deviation around the vertical center of slice j before normalization");
180 }
else if (!strcmp(aFrametag,
"TRACE_TABLE")) {
183 "[pix] Location of midpoint of leftmost slice");
186 "[deg] Tilt of leftmost slice, measured as angle from vertical direction");
189 "[pix] Location of midpoint of rightmost slice");
192 "[deg] Tilt of rightmost slice, measured as angle from vertical direction");
195 "The maximum slope of the derived tracing functions of slice j within the CCD.");
198 "[pix] Width of top left slice in the IFU (10 on CCD)");
201 "[pix] Width of top right slice in the IFU (46 on CCD)");
204 "[pix] Width of bottom left slice in the IFU (3 on CCD)");
207 "[pix] Width of bottom right slice in the IFU (39 on CCD)");
210 "[pix] Median width of slices");
213 "[pix] Mean width of slices");
216 "[pix] Standard deviation of widths of slices");
219 "[pix] Minimum width of slices");
222 "[pix] Maximum width of slices");
225 "[pix] Median of gaps between slices");
228 "[pix] Mean of gaps between slices");
231 "[pix] Standard deviation of gaps between slices");
234 "[pix] Minimum of gap between slices");
237 "[pix] Maximum gap between slices");
238 }
else if (!strcmp(aFrametag,
"TRACE_SAMPLES")) {
240 cpl_msg_warning(__func__,
"Frame tag %s is not defined", aFrametag);
241 return CPL_ERROR_ILLEGAL_INPUT;
243 return CPL_ERROR_NONE;
256 static cpl_frame_level
257 muse_flat_get_frame_level(
const char *aFrametag)
260 return CPL_FRAME_LEVEL_NONE;
262 if (!strcmp(aFrametag,
"MASTER_FLAT")) {
263 return CPL_FRAME_LEVEL_FINAL;
265 if (!strcmp(aFrametag,
"TRACE_TABLE")) {
266 return CPL_FRAME_LEVEL_FINAL;
268 if (!strcmp(aFrametag,
"TRACE_SAMPLES")) {
269 return CPL_FRAME_LEVEL_FINAL;
271 return CPL_FRAME_LEVEL_NONE;
285 muse_flat_get_frame_mode(
const char *aFrametag)
290 if (!strcmp(aFrametag,
"MASTER_FLAT")) {
293 if (!strcmp(aFrametag,
"TRACE_TABLE")) {
296 if (!strcmp(aFrametag,
"TRACE_SAMPLES")) {
314 muse_flat_create(cpl_plugin *aPlugin)
318 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
319 recipe = (cpl_recipe *)aPlugin;
327 muse_flat_new_recipeconfig(),
328 muse_flat_prepare_header,
329 muse_flat_get_frame_level,
330 muse_flat_get_frame_mode);
335 cpl_msg_set_time_on();
339 recipe->parameters = cpl_parameterlist_new();
344 p = cpl_parameter_new_range(
"muse.muse_flat.nifu",
346 "IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in parallel.",
351 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nifu");
352 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nifu");
354 cpl_parameterlist_append(recipe->parameters, p);
357 p = cpl_parameter_new_value(
"muse.muse_flat.overscan",
359 "If this is \"none\", stop when detecting discrepant overscan levels (see ovscsigma), for \"offset\" it assumes that the mean overscan level represents the real offset in the bias levels of the exposures involved, and adjusts the data accordingly; for \"vpoly\", a polynomial is fit to the vertical overscan and subtracted from the whole quadrant.",
361 (
const char *)
"vpoly");
362 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"overscan");
363 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"overscan");
365 cpl_parameterlist_append(recipe->parameters, p);
368 p = cpl_parameter_new_value(
"muse.muse_flat.ovscreject",
370 "This influences how values are rejected when computing overscan statistics. Either no rejection at all (\"none\"), rejection using the DCR algorithm (\"dcr\"), or rejection using an iterative constant fit (\"fit\").",
372 (
const char *)
"dcr");
373 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ovscreject");
374 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ovscreject");
376 cpl_parameterlist_append(recipe->parameters, p);
379 p = cpl_parameter_new_value(
"muse.muse_flat.ovscsigma",
381 "If the deviation of mean overscan levels between a raw input image and the reference image is higher than |ovscsigma x stdev|, stop the processing. If overscan=\"vpoly\", this is used as sigma rejection level for the iterative polynomial fit (the level comparison is then done afterwards with |100 x stdev| to guard against incompatible settings). Has no effect for overscan=\"offset\".",
384 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ovscsigma");
385 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ovscsigma");
387 cpl_parameterlist_append(recipe->parameters, p);
390 p = cpl_parameter_new_value(
"muse.muse_flat.ovscignore",
392 "The number of pixels of the overscan adjacent to the data section of the CCD that are ignored when computing statistics or fits.",
395 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"ovscignore");
396 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ovscignore");
398 cpl_parameterlist_append(recipe->parameters, p);
401 p = cpl_parameter_new_enum(
"muse.muse_flat.combine",
403 "Type of combination to use",
405 (
const char *)
"sigclip",
407 (
const char *)
"average",
408 (
const char *)
"median",
409 (
const char *)
"minmax",
410 (
const char *)
"sigclip");
411 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"combine");
412 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"combine");
414 cpl_parameterlist_append(recipe->parameters, p);
417 p = cpl_parameter_new_value(
"muse.muse_flat.nlow",
419 "Number of minimum pixels to reject with minmax",
422 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nlow");
423 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nlow");
425 cpl_parameterlist_append(recipe->parameters, p);
428 p = cpl_parameter_new_value(
"muse.muse_flat.nhigh",
430 "Number of maximum pixels to reject with minmax",
433 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nhigh");
434 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nhigh");
436 cpl_parameterlist_append(recipe->parameters, p);
439 p = cpl_parameter_new_value(
"muse.muse_flat.nkeep",
441 "Number of pixels to keep with minmax",
444 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nkeep");
445 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nkeep");
447 cpl_parameterlist_append(recipe->parameters, p);
450 p = cpl_parameter_new_value(
"muse.muse_flat.lsigma",
452 "Low sigma for pixel rejection with sigclip",
455 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"lsigma");
456 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"lsigma");
458 cpl_parameterlist_append(recipe->parameters, p);
461 p = cpl_parameter_new_value(
"muse.muse_flat.hsigma",
463 "High sigma for pixel rejection with sigclip",
466 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"hsigma");
467 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"hsigma");
469 cpl_parameterlist_append(recipe->parameters, p);
472 p = cpl_parameter_new_value(
"muse.muse_flat.scale",
474 "Scale the individual images to a common exposure time before combining them.",
477 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"scale");
478 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"scale");
479 if (!getenv(
"MUSE_EXPERT_USER")) {
480 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
483 cpl_parameterlist_append(recipe->parameters, p);
486 p = cpl_parameter_new_value(
"muse.muse_flat.normalize",
488 "Normalize the master flat to the average flux",
491 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"normalize");
492 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"normalize");
493 if (!getenv(
"MUSE_EXPERT_USER")) {
494 cpl_parameter_disable(p, CPL_PARAMETER_MODE_CLI);
497 cpl_parameterlist_append(recipe->parameters, p);
500 p = cpl_parameter_new_value(
"muse.muse_flat.trace",
502 "Trace the position of the slices on the master flat",
505 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"trace");
506 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"trace");
508 cpl_parameterlist_append(recipe->parameters, p);
511 p = cpl_parameter_new_value(
"muse.muse_flat.nsum",
513 "Number of lines over which to average when tracing",
516 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"nsum");
517 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"nsum");
519 cpl_parameterlist_append(recipe->parameters, p);
522 p = cpl_parameter_new_value(
"muse.muse_flat.order",
524 "Order of polynomial fit to the trace",
527 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"order");
528 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"order");
530 cpl_parameterlist_append(recipe->parameters, p);
533 p = cpl_parameter_new_value(
"muse.muse_flat.edgefrac",
535 "Fractional change required to identify edge when tracing",
538 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"edgefrac");
539 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"edgefrac");
541 cpl_parameterlist_append(recipe->parameters, p);
544 p = cpl_parameter_new_value(
"muse.muse_flat.losigmabadpix",
546 "Low sigma to find dark pixels in the master flat",
549 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"losigmabadpix");
550 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"losigmabadpix");
552 cpl_parameterlist_append(recipe->parameters, p);
555 p = cpl_parameter_new_value(
"muse.muse_flat.hisigmabadpix",
557 "High sigma to find bright pixels in the master flat",
560 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"hisigmabadpix");
561 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"hisigmabadpix");
563 cpl_parameterlist_append(recipe->parameters, p);
566 p = cpl_parameter_new_value(
"muse.muse_flat.samples",
568 "Create a table containing all tracing sample points.",
571 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"samples");
572 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"samples");
574 cpl_parameterlist_append(recipe->parameters, p);
577 p = cpl_parameter_new_value(
"muse.muse_flat.merge",
579 "Merge output products from different IFUs into a common file.",
582 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CFG,
"merge");
583 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"merge");
585 cpl_parameterlist_append(recipe->parameters, p);
605 cpl_ensure_code(aParams, CPL_ERROR_NULL_INPUT);
606 cpl_ensure_code(aParameters, CPL_ERROR_NULL_INPUT);
609 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.nifu");
610 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
611 aParams->
nifu = cpl_parameter_get_int(p);
613 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.overscan");
614 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
615 aParams->
overscan = cpl_parameter_get_string(p);
617 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.ovscreject");
618 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
619 aParams->
ovscreject = cpl_parameter_get_string(p);
621 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.ovscsigma");
622 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
623 aParams->
ovscsigma = cpl_parameter_get_double(p);
625 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.ovscignore");
626 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
627 aParams->
ovscignore = cpl_parameter_get_int(p);
629 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.combine");
630 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
631 aParams->
combine_s = cpl_parameter_get_string(p);
633 (!strcasecmp(aParams->
combine_s,
"average")) ? MUSE_FLAT_PARAM_COMBINE_AVERAGE :
634 (!strcasecmp(aParams->
combine_s,
"median")) ? MUSE_FLAT_PARAM_COMBINE_MEDIAN :
635 (!strcasecmp(aParams->
combine_s,
"minmax")) ? MUSE_FLAT_PARAM_COMBINE_MINMAX :
636 (!strcasecmp(aParams->
combine_s,
"sigclip")) ? MUSE_FLAT_PARAM_COMBINE_SIGCLIP :
637 MUSE_FLAT_PARAM_COMBINE_INVALID_VALUE;
638 cpl_ensure_code(aParams->
combine != MUSE_FLAT_PARAM_COMBINE_INVALID_VALUE,
639 CPL_ERROR_ILLEGAL_INPUT);
641 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.nlow");
642 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
643 aParams->
nlow = cpl_parameter_get_int(p);
645 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.nhigh");
646 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
647 aParams->
nhigh = cpl_parameter_get_int(p);
649 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.nkeep");
650 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
651 aParams->
nkeep = cpl_parameter_get_int(p);
653 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.lsigma");
654 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
655 aParams->
lsigma = cpl_parameter_get_double(p);
657 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.hsigma");
658 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
659 aParams->
hsigma = cpl_parameter_get_double(p);
661 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.scale");
662 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
663 aParams->
scale = cpl_parameter_get_bool(p);
665 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.normalize");
666 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
667 aParams->
normalize = cpl_parameter_get_bool(p);
669 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.trace");
670 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
671 aParams->
trace = cpl_parameter_get_bool(p);
673 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.nsum");
674 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
675 aParams->
nsum = cpl_parameter_get_int(p);
677 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.order");
678 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
679 aParams->
order = cpl_parameter_get_int(p);
681 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.edgefrac");
682 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
683 aParams->
edgefrac = cpl_parameter_get_double(p);
685 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.losigmabadpix");
686 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
689 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.hisigmabadpix");
690 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
693 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.samples");
694 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
695 aParams->
samples = cpl_parameter_get_bool(p);
697 p = cpl_parameterlist_find(aParameters,
"muse.muse_flat.merge");
698 cpl_ensure_code(p, CPL_ERROR_DATA_NOT_FOUND);
699 aParams->
merge = cpl_parameter_get_bool(p);
713 muse_flat_exec(cpl_plugin *aPlugin)
715 if (cpl_plugin_get_type(aPlugin) != CPL_PLUGIN_TYPE_RECIPE) {
719 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
720 cpl_msg_set_threadid_on();
722 cpl_frameset *usedframes = cpl_frameset_new(),
723 *outframes = cpl_frameset_new();
725 muse_flat_params_fill(¶ms, recipe->parameters);
727 cpl_errorstate prestate = cpl_errorstate_get();
729 if (params.
nifu < -1 || params.
nifu > kMuseNumIFUs) {
730 cpl_msg_error(__func__,
"Please specify a valid IFU number (between 1 and " 731 "%d), 0 (to process all IFUs consecutively), or -1 (to " 732 "process all IFUs in parallel) using --nifu.", kMuseNumIFUs);
736 cpl_boolean donotmerge = CPL_FALSE;
738 if (params.
nifu > 0) {
741 rc = muse_flat_compute(proc, ¶ms);
742 cpl_frameset_join(usedframes, proc->
usedframes);
743 cpl_frameset_join(outframes, proc->
outframes);
745 donotmerge = CPL_TRUE;
746 }
else if (params.
nifu < 0) {
747 int *rcs = cpl_calloc(kMuseNumIFUs,
sizeof(
int));
749 #pragma omp parallel for default(none) \ 750 shared(outframes, params, rcs, recipe, usedframes) 751 for (nifu = 1; nifu <= kMuseNumIFUs; nifu++) {
757 int *rci = rcs + (nifu - 1);
758 *rci = muse_flat_compute(proc, pars);
759 if (rci && (
int)cpl_error_get_code() == MUSE_ERROR_CHIP_NOT_LIVE) {
763 #pragma omp critical(muse_processing_used_frames) 764 cpl_frameset_join(usedframes, proc->
usedframes);
765 #pragma omp critical(muse_processing_output_frames) 766 cpl_frameset_join(outframes, proc->
outframes);
771 for (nifu = 1; nifu <= kMuseNumIFUs; nifu++) {
772 if (rcs[nifu-1] != 0) {
778 for (params.
nifu = 1; params.
nifu <= kMuseNumIFUs && !rc; params.
nifu++) {
781 rc = muse_flat_compute(proc, ¶ms);
782 if (rc && (
int)cpl_error_get_code() == MUSE_ERROR_CHIP_NOT_LIVE) {
785 cpl_frameset_join(usedframes, proc->
usedframes);
786 cpl_frameset_join(outframes, proc->
outframes);
790 UNUSED_ARGUMENT(donotmerge);
792 if (!cpl_errorstate_is_equal(prestate)) {
796 cpl_msg_set_level(CPL_MSG_INFO);
803 if (params.
merge && !donotmerge) {
812 cpl_frameset_join(recipe->frames, usedframes);
813 cpl_frameset_join(recipe->frames, outframes);
814 cpl_frameset_delete(usedframes);
815 cpl_frameset_delete(outframes);
828 muse_flat_destroy(cpl_plugin *aPlugin)
832 if (cpl_plugin_get_type(aPlugin) == CPL_PLUGIN_TYPE_RECIPE) {
833 recipe = (cpl_recipe *)aPlugin;
839 cpl_parameterlist_delete(recipe->parameters);
856 cpl_plugin_get_info(cpl_pluginlist *aList)
858 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
859 cpl_plugin *plugin = &recipe->interface;
863 helptext = cpl_sprintf(
"%s%s", muse_flat_help,
864 muse_flat_help_esorex);
866 helptext = cpl_sprintf(
"%s", muse_flat_help);
870 cpl_plugin_init(plugin, CPL_PLUGIN_API, MUSE_BINARY_VERSION,
871 CPL_PLUGIN_TYPE_RECIPE,
873 "Combine several separate flat images into one master flat file, trace slice locations, and locate dark pixels.",
875 "Peter Weilbacher (based on Joris Gerssen's draft)",
881 cpl_pluginlist_append(aList, plugin);
int nifu
IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in ...
void muse_processing_delete(muse_processing *aProcessing)
Free the muse_processing structure.
int order
Order of polynomial fit to the trace.
double lsigma
Low sigma for pixel rejection with sigclip.
int scale
Scale the individual images to a common exposure time before combining them.
muse_cplframework_type muse_cplframework(void)
Return the CPL framework the recipe is run under.
double ovscsigma
If the deviation of mean overscan levels between a raw input image and the reference image is higher ...
int normalize
Normalize the master flat to the average flux.
Structure to hold the parameters of the muse_flat recipe.
int combine
Type of combination to use.
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.
int merge
Merge output products from different IFUs into a common file.
int nsum
Number of lines over which to average when tracing.
const char * ovscreject
This influences how values are rejected when computing overscan statistics. Either no rejection at al...
int samples
Create a table containing all tracing sample points.
int nkeep
Number of pixels to keep with minmax.
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.
int nlow
Number of minimum pixels to reject with minmax.
int ovscignore
The number of pixels of the overscan adjacent to the data section of the CCD that are ignored when co...
const char * overscan
If this is "none", stop when detecting discrepant overscan levels (see ovscsigma), for "offset" it assumes that the mean overscan level represents the real offset in the bias levels of the exposures involved, and adjusts the data accordingly; for "vpoly", a polynomial is fit to the vertical overscan and subtracted from the whole quadrant.
cpl_error_code muse_cplframeset_erase_duplicate(cpl_frameset *aFrames)
Erase all duplicate frames from a frameset.
double edgefrac
Fractional change required to identify edge when tracing.
cpl_error_code muse_cplframeset_erase_all(cpl_frameset *aFrames)
Erase all frames in a frameset.
double losigmabadpix
Low sigma to find dark pixels in the master flat.
double hsigma
High sigma for pixel rejection with sigclip.
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 trace
Trace the position of the slices on the master flat.
const char * combine_s
Type of combination to use (as string)
void muse_processing_recipeinfo(cpl_plugin *)
Output main pipeline configuration, inputs, and parameters.
cpl_error_code muse_utils_frameset_merge_frames(cpl_frameset *aFrames, cpl_boolean aDelete)
Merge IFU-specific files from a frameset to create multi-IFU outputs.
int nhigh
Number of maximum pixels to reject with minmax.
double hisigmabadpix
High sigma to find bright pixels in the master flat.
cpl_error_code muse_processing_prepare_property(cpl_propertylist *, const char *, cpl_type, const char *)
Prepare and check the specified property.