45 #include <uves_parameters.h>
46 #include <uves_utils.h>
47 #include <uves_utils_wrappers.h>
49 #include <uves_recipe.h>
50 #include <uves_error.h>
59 static const bool flames =
false;
64 static bool frame_is_needed(
bool blue,
const cpl_frame *f);
65 static cpl_error_code execute_recipe(
const char *recipe_id,
66 cpl_frameset *frames,
const cpl_parameterlist *parameters,
67 const char *products[],
int n_products,
bool reclassify);
68 static bool is_missing(
const cpl_frameset *frames,
const char *frame1,
const char *frame2);
69 static void remove_input_frame(cpl_frameset *frames,
const char *tag);
71 static int uves_redchain_define_parameters(cpl_parameterlist *parameters);
76 #define cpl_plugin_get_info uves_redchain_get_info
78 UVES_REDCHAIN_ID, UVES_REDCHAIN_DOM, uves_redchain_define_parameters,
79 "Jonas M. Larsen",
"cpl@eso.org",
80 "Runs the full UVES reduction chain",
81 "This recipe does a complete science reduction. It runs all necessary\n"
82 "calibration recipes depending on the availability of raw/processed\n"
83 "calibration frames.\n"
84 "Input frames are all UVES raw and reference frames:\n"
85 "formatchecks, ARC_LAMP_FORM_xxxx, xxxx=BLUE or RED,\n"
86 "order definition frames, ORDER_FLAT_xxx,\n"
90 "arc lamps, ARC_LAMP_xxx,\n"
91 "standard stars, STANDARD_xxx\n"
92 "a wavelength catalogue table,LINE_REFER_TABLE, \n"
93 "and optionally a wavelength table of bright lines,LINE_INTMON_TABLE, \n"
94 "used only for computing Quality Control parameters.\n"
95 "a reference standard star flux table, FLUX_STD_TABLE, \n"
96 "a table describing the atmospheric extintion,EXTCOEFF_TABLE.\n"
97 "optionally, science frames, SCIENCE_xxx, or UVES_SCI_POINT_xxx, \n"
98 "or UVES_SCI_EXTND_xxx, or UVES_SCI_SLICER_xxx.\n"
99 "For further details on the data reduction and the input frame types\n"
100 "refer to the man page of the individual recipes.\n");
115 uves_redchain_define_parameters(cpl_parameterlist *parameters)
117 const char *recipe_id = make_str(UVES_REDCHAIN_ID);
118 const char *subcontext = NULL;
120 uves_par_new_value(
"scired",
122 "Whether or not to do science reduction. "
123 "If false, only master calibration frames "
124 "are created. If false, either zero or all "
125 "necessary calibration frames must be provided "
132 if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
140 if (uves_propagate_parameters(
141 make_str(UVES_MBIAS_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
150 if (uves_propagate_parameters(
151 make_str(UVES_MDARK_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
159 if (uves_propagate_parameters(
160 make_str(UVES_PHYSMOD_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
168 if (uves_propagate_parameters(
169 make_str(UVES_ORDERPOS_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
177 if (uves_propagate_parameters(
178 make_str(UVES_MFLAT_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
187 if (uves_propagate_parameters(
188 make_str(UVES_WAVECAL_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
204 uves_define_background_for_response_chain_parameters(parameters);
205 uves_define_extract_for_response_chain_parameters(parameters);
206 uves_define_reduce_for_response_chain_parameters(parameters);
207 uves_define_rebin_for_response_chain_parameters(parameters);
208 uves_define_efficiency_for_response_chain_parameters(parameters);
215 if (uves_propagate_parameters(
216 make_str(UVES_SCIRED_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
221 return (cpl_error_get_code() != CPL_ERROR_NONE);
235 UVES_CONCAT2X(UVES_REDCHAIN_ID,exe)(cpl_frameset *frames,
236 const cpl_parameterlist *parameters,
237 const char *starttime)
239 cpl_frameset *blue_frames = NULL;
240 cpl_frameset *red_frames = NULL;
241 cpl_frameset *common_frames = NULL;
251 bool run_orderpos[2];
253 bool run_response[2];
257 const char* PROCESS_CHIP=NULL;
262 starttime = starttime;
264 check( uves_get_parameter(parameters, NULL, make_str(UVES_REDCHAIN_ID),
"scired",
265 CPL_TYPE_BOOL, &do_science),
"Could not read parameter");
268 assure(!do_science ||
269 cpl_frameset_find(frames, UVES_SCIENCE(
true )) != NULL ||
270 cpl_frameset_find(frames, UVES_SCIENCE(
false)) != NULL ||
271 cpl_frameset_find(frames, UVES_SCI_EXTND(
true )) != NULL ||
272 cpl_frameset_find(frames, UVES_SCI_EXTND(
false)) != NULL ||
273 cpl_frameset_find(frames, UVES_SCI_POINT(
true )) != NULL ||
274 cpl_frameset_find(frames, UVES_SCI_POINT(
false)) != NULL ||
275 cpl_frameset_find(frames, UVES_SCI_SLICER(
true )) != NULL ||
276 cpl_frameset_find(frames, UVES_SCI_SLICER(
false)) != NULL,
277 CPL_ERROR_DATA_NOT_FOUND,
"No %s, %s, %s, %s, %s, %s, %s or %s in frame set",
280 UVES_SCI_EXTND(
true),
281 UVES_SCI_EXTND(
false),
282 UVES_SCI_POINT(
true),
283 UVES_SCI_POINT(
false),
284 UVES_SCI_SLICER(
true),
285 UVES_SCI_SLICER(
false));
287 blue_frames = cpl_frameset_new();
288 red_frames = cpl_frameset_new();
289 common_frames = cpl_frameset_new();
291 check( uves_get_parameter(parameters, NULL,
"uves",
"process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
292 "Could not read parameter");
300 nfrm=cpl_frameset_get_size(frames);
304 f=cpl_frameset_get_frame(frames,i);
305 if (frame_is_needed(
true, f))
308 check( cpl_frameset_insert(blue_frames, cpl_frame_duplicate(f)),
309 "Error extracting frame '%s' from frame set",
310 cpl_frame_get_tag(f));
312 if (frame_is_needed(
false, f))
315 check( cpl_frameset_insert(red_frames, cpl_frame_duplicate(f)),
316 "Error extracting frame '%s' from frame set",
317 cpl_frame_get_tag(f));
320 if (frame_is_needed(
true, f) &&
321 frame_is_needed(
false, f))
324 check( cpl_frameset_insert(common_frames, cpl_frame_duplicate(f)),
325 "Error extracting frame '%s' from frame set",
326 cpl_frame_get_tag(f));
331 cpl_frame *frm = NULL;
332 for (i=0;i<nfrm;i++) {
334 check_nomsg(cpl_frameset_erase_frame(frames, frm));
350 enum uves_chip chip1 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDL;
351 enum uves_chip chip2 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDU;
353 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
356 cpl_frameset_get_size(fms) >
357 cpl_frameset_get_size(common_frames);
359 uves_msg_debug(
"nraw_arm=%d (%s arm)", nraw_arm[blue], blue ?
"blue" :
"red");
361 run_scired[blue] = do_science &&
362 !(is_missing(fms, UVES_SCIENCE(blue), NULL) &&
363 is_missing(fms, UVES_SCI_EXTND(blue), NULL) &&
364 is_missing(fms, UVES_SCI_POINT(blue), NULL) &&
365 is_missing(fms, UVES_SCI_SLICER(blue), NULL));
370 (!do_science && nraw_arm[blue])) {
373 run_mbias[blue] = is_missing(fms,
374 UVES_MASTER_BIAS(chip1),
375 UVES_MASTER_BIAS(chip2)
381 UVES_MASTER_DARK(chip1),
382 UVES_MASTER_DARK(chip2))
385 UVES_MASTER_PDARK(chip1),
386 UVES_MASTER_PDARK(chip2))
388 !is_missing(fms, UVES_DARK(blue), NULL) ||
389 !is_missing(fms, UVES_PDARK(blue), NULL));
393 run_orderpos[blue] = is_missing(fms,
394 UVES_ORDER_TABLE(flames, chip1),
395 UVES_ORDER_TABLE(flames, chip2)
397 !is_missing(fms, UVES_ORDER_FLAT(flames, blue), NULL);
402 UVES_MASTER_FLAT(chip1),
403 UVES_MASTER_FLAT(chip2))
406 UVES_MASTER_DFLAT(chip1),
407 UVES_MASTER_DFLAT(chip2))
410 UVES_MASTER_IFLAT(chip1),
411 UVES_MASTER_IFLAT(chip2))
414 UVES_MASTER_SCREEN_FLAT(chip1),
415 UVES_MASTER_SCREEN_FLAT(chip2))
418 UVES_REF_TFLAT(chip1),
419 UVES_REF_TFLAT(chip2));
442 run_physmod[blue] = is_missing(fms,
443 UVES_LINE_TABLE(flames, chip1),
444 UVES_LINE_TABLE(flames, chip2))
447 UVES_GUESS_LINE_TABLE(flames, chip1),
448 UVES_GUESS_LINE_TABLE(flames, chip2))
452 UVES_LINE_TABLE_MIDAS(chip1, 1),
453 UVES_LINE_TABLE_MIDAS(chip2, 1)) ||
455 UVES_LINE_TABLE_MIDAS(chip1, 2),
456 UVES_LINE_TABLE_MIDAS(chip2, 2)) ||
458 UVES_LINE_TABLE_MIDAS(chip1, 3),
459 UVES_LINE_TABLE_MIDAS(chip2, 3))
470 UVES_LINE_TABLE(flames, chip1),
471 UVES_LINE_TABLE(flames, chip2))
475 UVES_LINE_TABLE_MIDAS(chip1, 1),
476 UVES_LINE_TABLE_MIDAS(chip2, 1)) ||
478 UVES_LINE_TABLE_MIDAS(chip1, 2),
479 UVES_LINE_TABLE_MIDAS(chip2, 2)) ||
481 UVES_LINE_TABLE_MIDAS(chip1, 3),
482 UVES_LINE_TABLE_MIDAS(chip2, 3))
488 UVES_ARC_LAMP(flames, blue), NULL) ||
490 UVES_ECH_ARC_LAMP(blue), NULL)
495 run_response[blue] = !is_missing(fms,
496 UVES_STD_STAR(blue), NULL);
499 uves_msg(
"Reduction strategy for %s arm:", (blue) ?
"BLUE" :
"RED");
500 uves_msg(
"Run %-13s: %s", make_str(UVES_MBIAS_ID) , (run_mbias[blue] ) ?
"Yes" :
"No");
501 uves_msg(
"Run %-13s: %s", make_str(UVES_MDARK_ID) , (run_mdark[blue] ) ?
"Yes" :
"No");
502 uves_msg(
"Run %-13s: %s", make_str(UVES_PHYSMOD_ID) , (run_physmod[blue] ) ?
"Yes" :
"No");
503 uves_msg(
"Run %-13s: %s", make_str(UVES_ORDERPOS_ID), (run_orderpos[blue]) ?
"Yes" :
"No");
504 uves_msg(
"Run %-13s: %s", make_str(UVES_MFLAT_ID) , (run_mflat[blue] ) ?
"Yes" :
"No");
505 uves_msg(
"Run %-13s: %s", make_str(UVES_WAVECAL_ID) , (run_wavecal[blue] ) ?
"Yes" :
"No");
506 uves_msg(
"Run %-13s: %s", make_str(UVES_RESPONSE_ID), (run_response[blue]) ?
"Yes" :
"No");
507 uves_msg(
"Run %-13s: %s", make_str(UVES_SCIRED_ID) , (run_scired[blue] ) ?
"Yes" :
"No");
512 (blue) ?
"BLUE" :
"RED");
514 run_mbias[blue] =
false;
515 run_mdark[blue] =
false;
516 run_mflat[blue] =
false;
517 run_physmod[blue] =
false;
518 run_orderpos[blue] =
false;
519 run_wavecal[blue] =
false;
520 run_response[blue] =
false;
534 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
536 assure( !run_mbias[blue] || !is_missing(fms, UVES_BIAS(blue), NULL),
537 CPL_ERROR_DATA_NOT_FOUND,
538 "One or more '%s' frames needed for recipe '%s'",
539 UVES_BIAS(blue), make_str(UVES_MBIAS_ID));
541 assure( !run_mdark[blue] ||
542 !is_missing(fms, UVES_DARK(blue), NULL) ||
543 !is_missing(fms, UVES_PDARK(blue), NULL),
544 CPL_ERROR_DATA_NOT_FOUND,
545 "One or more '%s' or '%s' frames needed for recipe '%s'",
546 UVES_DARK(blue), UVES_PDARK(blue), make_str(UVES_MDARK_ID));
548 assure( !run_physmod[blue] || !is_missing(fms, UVES_FORMATCHECK(flames, blue), NULL),
549 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
550 UVES_FORMATCHECK(flames, blue), make_str(UVES_PHYSMOD_ID));
552 assure( !run_orderpos[blue] || !is_missing(fms, UVES_ORDER_FLAT(flames, blue), NULL),
553 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
554 UVES_ORDER_FLAT(flames, blue), make_str(UVES_ORDERPOS_ID));
556 assure( !run_mflat[blue] ||
557 !is_missing(fms, UVES_FLAT(blue), NULL) ||
558 !is_missing(fms, UVES_IFLAT(blue), NULL) ||
559 !is_missing(fms, UVES_SCREEN_FLAT(blue), NULL) ||
560 !is_missing(fms, UVES_DFLAT(blue), NULL) ||
561 !is_missing(fms, UVES_TFLAT(blue), NULL),
562 CPL_ERROR_DATA_NOT_FOUND,
563 "One or more '%s', '%s', '%s', '%s' or '%s' frames needed for recipe '%s'",
566 UVES_SCREEN_FLAT(blue),
569 make_str(UVES_MFLAT_ID));
571 assure( !run_wavecal[blue] || (
572 !is_missing(fms, UVES_ARC_LAMP(flames, blue), NULL) ||
573 !is_missing(fms, UVES_ECH_ARC_LAMP(blue), NULL)),
574 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' or '%s' needed for recipe '%s'",
575 UVES_ARC_LAMP(flames, blue), UVES_ECH_ARC_LAMP(blue), make_str(UVES_WAVECAL_ID));
576 assure( !run_wavecal[blue] || !is_missing(fms, UVES_LINE_REFER_TABLE, NULL),
577 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
578 UVES_LINE_REFER_TABLE, make_str(UVES_WAVECAL_ID));
580 assure( !run_response[blue] || !is_missing(fms, UVES_STD_STAR(blue), NULL),
581 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
582 UVES_STD_STAR(blue), make_str(UVES_RESPONSE_ID));
583 assure( !run_response[blue] || !is_missing(fms, UVES_FLUX_STD_TABLE, NULL),
584 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
585 UVES_FLUX_STD_TABLE, make_str(UVES_RESPONSE_ID));
586 assure( !run_response[blue] || !is_missing(fms, UVES_EXTCOEFF_TABLE, NULL),
587 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
588 UVES_EXTCOEFF_TABLE, make_str(UVES_RESPONSE_ID));
602 enum uves_chip chip1 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDL;
603 enum uves_chip chip2 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDU;
605 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
609 const char *products[2];
611 int nprod =
sizeof(products) /
sizeof (
char *);
613 products[0] = UVES_MASTER_BIAS(chip1);
614 products[1] = UVES_MASTER_BIAS(chip2);
616 if (blue) nprod /= 2;
618 check( execute_recipe(make_str(UVES_MBIAS_ID), fms, parameters, products, nprod,
true),
619 "Recipe execution failed");
622 check( remove_input_frame(fms, UVES_BIAS(blue)),
"Error removing input frames");
626 const char *products[4];
628 int nprod =
sizeof(products) /
sizeof (
char *);
630 products[0] = UVES_MASTER_DARK(chip1);
631 products[1] = UVES_MASTER_PDARK(chip1);
632 products[2] = UVES_MASTER_DARK(chip2);
633 products[3] = UVES_MASTER_PDARK(chip2);
635 if (blue) nprod /= 2;
637 check( execute_recipe(
638 make_str(UVES_MDARK_ID), fms, parameters, products, nprod,
true),
639 "Recipe execution failed");
642 check( remove_input_frame(fms, UVES_DARK(blue)),
"Error removing input frames");
643 check( remove_input_frame(fms, UVES_PDARK(blue)),
"Error removing input frames");
645 if (run_physmod[blue])
647 const char *products[4];
648 int nprod =
sizeof(products) /
sizeof (
char *);
650 products[0] = UVES_GUESS_LINE_TABLE (flames, chip1);
651 products[1] = UVES_GUESS_ORDER_TABLE(flames, chip1);
652 products[2] = UVES_GUESS_LINE_TABLE (flames, chip2);
653 products[3] = UVES_GUESS_ORDER_TABLE(flames, chip2);
655 if (blue) nprod /= 2;
657 check( execute_recipe(
658 make_str(UVES_PHYSMOD_ID),
659 fms, parameters, products, nprod,
true),
660 "Recipe execution failed");
663 check( remove_input_frame(fms, UVES_FORMATCHECK(flames, blue)),
664 "Error removing input frames");
666 if (run_orderpos[blue])
668 const char *products[2];
669 int nprod =
sizeof(products) /
sizeof (
char *);
671 products[0] = UVES_ORDER_TABLE(flames, chip1);
672 products[1] = UVES_ORDER_TABLE(flames, chip2);
674 if (blue) nprod /= 2;
676 check( execute_recipe(
677 make_str(UVES_ORDERPOS_ID),
678 fms, parameters, products, nprod,
true),
679 "Recipe execution failed");
682 check( remove_input_frame(fms, UVES_ORDER_FLAT(flames, blue)),
683 "Error removing input frames");
687 const char *products[10];
689 int nprod =
sizeof(products) /
sizeof (
char *);
691 products[0] = UVES_MASTER_FLAT(chip1);
692 products[1] = UVES_MASTER_DFLAT(chip1);
693 products[2] = UVES_MASTER_IFLAT(chip1);
694 products[3] = UVES_MASTER_TFLAT(chip1);
695 products[4] = UVES_MASTER_SCREEN_FLAT(chip1);
696 products[5] = UVES_MASTER_FLAT(chip2);
697 products[6] = UVES_MASTER_DFLAT(chip2);
698 products[7] = UVES_MASTER_IFLAT(chip2);
699 products[8] = UVES_MASTER_TFLAT(chip2);
700 products[9] = UVES_MASTER_SCREEN_FLAT(chip2);
702 if (blue) nprod /= 2;
704 check( execute_recipe(make_str(UVES_MFLAT_ID),
705 fms, parameters, products, nprod,
true),
706 "Recipe execution failed");
709 check( remove_input_frame(fms, UVES_FLAT(blue)),
"Error removing input frames");
710 check( remove_input_frame(fms, UVES_IFLAT(blue)),
"Error removing input frames");
711 check( remove_input_frame(fms, UVES_DFLAT(blue)),
"Error removing input frames");
712 check( remove_input_frame(fms, UVES_TFLAT(blue)),
"Error removing input frames");
713 check( remove_input_frame(fms, UVES_SCREEN_FLAT(blue)),
"Error removing input frames");
715 if (run_wavecal[blue])
717 const char *products[2];
719 int nprod =
sizeof(products) /
sizeof (
char *);
721 products[0] = UVES_LINE_TABLE(flames, chip1);
722 products[1] = UVES_LINE_TABLE(flames, chip2);
724 if (blue) nprod /= 2;
726 check( execute_recipe(make_str(UVES_WAVECAL_ID),
727 fms, parameters, products, nprod,
true),
728 "Recipe execution failed");
731 check( remove_input_frame(fms, UVES_ARC_LAMP(flames, blue)),
732 "Error removing input frames");
733 check( remove_input_frame(fms, UVES_ECH_ARC_LAMP(blue)),
734 "Error removing input frames");
735 check( remove_input_frame(fms, UVES_LINE_REFER_TABLE),
736 "Error removing input frames");
738 if (run_response[blue])
740 const char *products[2];
742 int nprod =
sizeof(products) /
sizeof (
char *);
744 products[0] = UVES_INSTR_RESPONSE(chip1);
745 products[1] = UVES_INSTR_RESPONSE(chip2);
747 if (blue) nprod /= 2;
749 check( execute_recipe(make_str(UVES_RESPONSE_ID),
750 fms, parameters, products, nprod,
true),
751 "Recipe execution failed");
754 check( remove_input_frame(fms, UVES_STD_STAR(blue)),
"Error removing input frames");
755 check( remove_input_frame(fms, UVES_FLUX_STD_TABLE),
"Error removing input frames");
757 if (run_scired[blue])
759 const char *products[2];
761 int nprod =
sizeof(products) /
sizeof (
char *);
763 products[0] = blue ?
"RED_SCIENCE_BLUE" :
"RED_SCIENCE_REDL";
764 products[1] = blue ?
"RED_SCIENCE_BLUE" :
"RED_SCIENCE_REDU";
766 if (blue) nprod /= 2;
768 check( execute_recipe(make_str(UVES_SCIRED_ID),
769 fms, parameters, products, nprod,
false),
770 "Recipe execution failed");
773 check( remove_input_frame(fms, UVES_SCIENCE(blue)) ,
"Error removing input frames");
774 check( remove_input_frame(fms, UVES_SCI_EXTND(blue)) ,
"Error removing input frames");
775 check( remove_input_frame(fms, UVES_SCI_POINT(blue)) ,
"Error removing input frames");
776 check( remove_input_frame(fms, UVES_SCI_SLICER(blue)),
"Error removing input frames");
783 nfrm=cpl_frameset_get_size(fms);
786 f=cpl_frameset_get_frame(fms,i);
787 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
789 check( cpl_frameset_insert(frames, cpl_frame_duplicate(f)),
790 "Error inserting product '%s' into frame set",
791 cpl_frame_get_tag(f));
801 uves_free_frameset(&blue_frames);
802 uves_free_frameset(&red_frames);
803 uves_free_frameset(&common_frames);
812 frame_is_needed(
bool blue,
const cpl_frame *f)
814 const char *tag = cpl_frame_get_tag(f);
816 bool result = (strcmp(tag, UVES_ORDER_FLAT (flames, blue)) == 0 ||
817 strcmp(tag, UVES_BIAS (blue)) == 0 ||
818 strcmp(tag, UVES_DARK (blue)) == 0 ||
819 strcmp(tag, UVES_PDARK (blue)) == 0 ||
820 strcmp(tag, UVES_FLAT (blue)) == 0 ||
821 strcmp(tag, UVES_IFLAT (blue)) == 0 ||
822 strcmp(tag, UVES_DFLAT (blue)) == 0 ||
823 strcmp(tag, UVES_TFLAT (blue)) == 0 ||
824 strcmp(tag, UVES_SCREEN_FLAT(blue)) == 0 ||
825 strcmp(tag, UVES_STD_STAR (blue)) == 0 ||
826 strcmp(tag, UVES_FORMATCHECK(flames, blue)) == 0 ||
827 strcmp(tag, UVES_STD_STAR (blue)) == 0 ||
828 strcmp(tag, UVES_SCIENCE (blue)) == 0 ||
829 strcmp(tag, UVES_SCI_EXTND (blue)) == 0 ||
830 strcmp(tag, UVES_SCI_POINT (blue)) == 0 ||
831 strcmp(tag, UVES_SCI_SLICER (blue)) == 0 ||
832 strcmp(tag, UVES_ARC_LAMP (flames, blue)) == 0 ||
833 strcmp(tag, UVES_ECH_ARC_LAMP(blue)) == 0);
839 chip != UVES_CHIP_INVALID;
842 result = result || (strcmp(tag, UVES_DRS_SETUP(flames, chip)) == 0 ||
843 strcmp(tag, UVES_ORDER_TABLE(flames, chip)) == 0 ||
844 strcmp(tag, UVES_GUESS_ORDER_TABLE(flames, chip)) == 0 ||
845 strcmp(tag, UVES_MASTER_BIAS(chip)) == 0 ||
846 strcmp(tag, UVES_MASTER_DARK(chip)) == 0 ||
847 strcmp(tag, UVES_MASTER_PDARK(chip)) == 0 ||
848 strcmp(tag, UVES_MASTER_FLAT(chip)) == 0 ||
849 strcmp(tag, UVES_MASTER_DFLAT(chip)) == 0 ||
850 strcmp(tag, UVES_MASTER_IFLAT(chip)) == 0 ||
851 strcmp(tag, UVES_MASTER_TFLAT(chip)) == 0 ||
852 strcmp(tag, UVES_REF_TFLAT(chip)) == 0 ||
853 strcmp(tag, UVES_MASTER_SCREEN_FLAT(chip)) == 0 ||
854 strcmp(tag, UVES_LINE_TABLE (flames, chip)) == 0 ||
855 strcmp(tag, UVES_GUESS_LINE_TABLE(flames, chip)) == 0 ||
856 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 1)) == 0 ||
857 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 2)) == 0 ||
858 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 3)) == 0 ||
859 strcmp(tag, UVES_LINE_REFER_TABLE ) == 0 ||
860 strcmp(tag, UVES_FLUX_STD_TABLE ) == 0 ||
861 strcmp(tag, UVES_EXTCOEFF_TABLE ) == 0);
867 static cpl_error_code
868 execute_recipe(
const char *recipe_id,
869 cpl_frameset *frames,
const cpl_parameterlist *parameters,
870 const char *products[],
879 for (i = 0; i < n_products; i++)
881 if ((f = cpl_frameset_find(frames, products[i])) != NULL)
883 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
885 cpl_msg_warning(__func__,
"Ignoring %s frame in '%s'. "
886 "A new %s frame will now be calculated",
887 products[i], cpl_frame_get_filename(f),
890 cpl_frameset_erase_frame(frames, f);
896 check( uves_invoke_recipe(recipe_id, parameters, frames, make_str(UVES_REDCHAIN_ID), NULL),
897 "Recipe '%s' failed", recipe_id);
899 check(cpl_dfs_update_product_header(frames),
"Error updating pipe products' header");
908 for (i = 0; i < n_products; i++)
910 if ((f = cpl_frameset_find(frames, products[i])) != NULL &&
911 cpl_frame_get_group(f) != CPL_FRAME_GROUP_PRODUCT)
913 uves_msg(
"Removing %s frame in '%s' from frameset. "
914 "It is not tagged as a product",
915 products[i], cpl_frame_get_filename(f));
917 cpl_frameset_erase_frame(frames, f);
924 for (i = 0; i < n_products; i++)
926 cpl_frame *found = NULL;
928 int nfrm=cpl_frameset_get_size(frames);
931 f=cpl_frameset_get_frame(frames,j);
932 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
934 if (strcmp(cpl_frame_get_tag(f), products[i]) == 0)
944 uves_msg(
"Re-classifying %s product in '%s' PRODUCT->CALIB",
945 products[i], cpl_frame_get_filename(found));
947 cpl_frame_set_group(found, CPL_FRAME_GROUP_CALIB);
957 int nfrm=cpl_frameset_get_size(frames);
959 for (k=0;k<nfrm-nerased;k++)
961 f=cpl_frameset_get_frame(frames,k);
963 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
966 uves_msg(
"Removing product %s in '%s' from frameset. "
968 cpl_frame_get_tag(f), cpl_frame_get_filename(f));
970 cpl_frameset_erase_frame(frames, f);
979 return cpl_error_get_code();
989 is_missing(
const cpl_frameset *frames,
const char *frame1,
const char *frame2)
992 if (cpl_frameset_find_const(frames, frame1) == NULL)
994 uves_msg(
"checking for %s... no", frame1);
999 uves_msg(
"checking for %s... yes", frame1);
1002 if (frame2 != NULL && strcmp(frame1, frame2) != 0)
1004 if (cpl_frameset_find_const(frames, frame2) == NULL)
1006 uves_msg(
"checking for %s... no", frame2);
1011 uves_msg(
"checking for %s... yes", frame2);
1021 remove_input_frame(cpl_frameset *frames,
const char *tag)
1023 int removed = cpl_frameset_erase(frames, tag);
1027 uves_msg(
"Removing %d %s frame(s) from frame set", removed, tag);
#define uves_msg(...)
Print a message on 'info' or 'debug' level.
enum uves_chip uves_chip_get_first(bool blue)
Get first chip for blue or red arm.
enum uves_chip uves_chip_get_next(enum uves_chip chip)
Get next chip.
#define uves_msg_debug(...)
Print a debug message.
const char * uves_string_toupper(char *s)
Convert all lowercase characters in a string into uppercase characters.