186 #include <uves_parameters.h>
187 #include <uves_utils.h>
188 #include <uves_utils_wrappers.h>
189 #include <uves_dfs.h>
190 #include <uves_recipe.h>
191 #include <uves_error.h>
192 #include <uves_msg.h>
200 static const bool flames =
false;
205 static bool frame_is_needed(
bool blue,
const cpl_frame *f);
206 static cpl_error_code execute_recipe(
const char *recipe_id,
207 cpl_frameset *frames,
const cpl_parameterlist *parameters,
208 const char *products[],
int n_products,
bool reclassify);
209 static bool is_missing(
const cpl_frameset *frames,
const char *frame1,
const char *frame2);
210 static void remove_input_frame(cpl_frameset *frames,
const char *tag);
212 static int uves_redchain_define_parameters(cpl_parameterlist *parameters);
217 #define cpl_plugin_get_info uves_redchain_get_info
219 UVES_REDCHAIN_ID, UVES_REDCHAIN_DOM, uves_redchain_define_parameters,
220 "Jonas M. Larsen",
"cpl@eso.org",
221 "Runs the full UVES reduction chain",
222 "This recipe does a complete science reduction. It runs all necessary\n"
223 "calibration recipes depending on the availability of raw/processed\n"
224 "calibration frames.\n"
225 "Input frames are all UVES raw and reference frames:\n"
226 "formatchecks, ARC_LAMP_FORM_xxxx, xxxx=BLUE or RED,\n"
227 "order definition frames, ORDER_FLAT_xxx,\n"
228 "biases, BIAS_xxx,\n"
231 "arc lamps, ARC_LAMP_xxx,\n"
232 "standard stars, STANDARD_xxx\n"
233 "a wavelength catalogue table,LINE_REFER_TABLE, \n"
234 "and optionally a wavelength table of bright lines,LINE_INTMON_TABLE, \n"
235 "used only for computing Quality Control parameters.\n"
236 "a reference standard star flux table, FLUX_STD_TABLE, \n"
237 "a table describing the atmospheric extintion,EXTCOEFF_TABLE.\n"
238 "optionally, science frames, SCIENCE_xxx, or UVES_SCI_POINT_xxx, \n"
239 "or UVES_SCI_EXTND_xxx, or UVES_SCI_SLICER_xxx.\n"
240 "For further details on the data reduction and the input frame types\n"
241 "refer to the man page of the individual recipes.\n");
256 uves_redchain_define_parameters(cpl_parameterlist *parameters)
258 const char *recipe_id = make_str(UVES_REDCHAIN_ID);
259 const char *subcontext = NULL;
261 uves_par_new_value(
"scired",
263 "Whether or not to do science reduction. "
264 "If false, only master calibration frames "
265 "are created. If false, either zero or all "
266 "necessary calibration frames must be provided "
273 if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
281 if (uves_propagate_parameters(
282 make_str(UVES_MBIAS_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
291 if (uves_propagate_parameters(
292 make_str(UVES_MDARK_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
300 if (uves_propagate_parameters(
301 make_str(UVES_PHYSMOD_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
309 if (uves_propagate_parameters(
310 make_str(UVES_ORDERPOS_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
318 if (uves_propagate_parameters(
319 make_str(UVES_MFLAT_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
328 if (uves_propagate_parameters(
329 make_str(UVES_WAVECAL_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
345 uves_define_background_for_response_chain_parameters(parameters);
346 uves_define_extract_for_response_chain_parameters(parameters);
347 uves_define_reduce_for_response_chain_parameters(parameters);
348 uves_define_rebin_for_response_chain_parameters(parameters);
349 uves_define_efficiency_for_response_chain_parameters(parameters);
356 if (uves_propagate_parameters(
357 make_str(UVES_SCIRED_ID), parameters, make_str(UVES_REDCHAIN_ID), NULL) != 0)
362 return (cpl_error_get_code() != CPL_ERROR_NONE);
376 UVES_CONCAT2X(UVES_REDCHAIN_ID,exe)(cpl_frameset *frames,
377 const cpl_parameterlist *parameters,
378 const char *starttime)
380 cpl_frameset *blue_frames = NULL;
381 cpl_frameset *red_frames = NULL;
382 cpl_frameset *common_frames = NULL;
392 bool run_orderpos[2];
394 bool run_response[2];
398 const char* PROCESS_CHIP=NULL;
403 starttime = starttime;
405 check( uves_get_parameter(parameters, NULL, make_str(UVES_REDCHAIN_ID),
"scired",
406 CPL_TYPE_BOOL, &do_science),
"Could not read parameter");
409 assure(!do_science ||
410 cpl_frameset_find(frames, UVES_SCIENCE(
true )) != NULL ||
411 cpl_frameset_find(frames, UVES_SCIENCE(
false)) != NULL ||
412 cpl_frameset_find(frames, UVES_SCI_EXTND(
true )) != NULL ||
413 cpl_frameset_find(frames, UVES_SCI_EXTND(
false)) != NULL ||
414 cpl_frameset_find(frames, UVES_SCI_POINT(
true )) != NULL ||
415 cpl_frameset_find(frames, UVES_SCI_POINT(
false)) != NULL ||
416 cpl_frameset_find(frames, UVES_SCI_SLICER(
true )) != NULL ||
417 cpl_frameset_find(frames, UVES_SCI_SLICER(
false)) != NULL,
418 CPL_ERROR_DATA_NOT_FOUND,
"No %s, %s, %s, %s, %s, %s, %s or %s in frame set",
421 UVES_SCI_EXTND(
true),
422 UVES_SCI_EXTND(
false),
423 UVES_SCI_POINT(
true),
424 UVES_SCI_POINT(
false),
425 UVES_SCI_SLICER(
true),
426 UVES_SCI_SLICER(
false));
428 blue_frames = cpl_frameset_new();
429 red_frames = cpl_frameset_new();
430 common_frames = cpl_frameset_new();
432 check( uves_get_parameter(parameters, NULL,
"uves",
"process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
433 "Could not read parameter");
440 for (f = cpl_frameset_get_first(frames);
442 f = cpl_frameset_get_next(frames))
446 if (frame_is_needed(
true, f))
449 check( cpl_frameset_insert(blue_frames, cpl_frame_duplicate(f)),
450 "Error extracting frame '%s' from frame set",
451 cpl_frame_get_tag(f));
453 if (frame_is_needed(
false, f))
456 check( cpl_frameset_insert(red_frames, cpl_frame_duplicate(f)),
457 "Error extracting frame '%s' from frame set",
458 cpl_frame_get_tag(f));
461 if (frame_is_needed(
true, f) &&
462 frame_is_needed(
false, f))
465 check( cpl_frameset_insert(common_frames, cpl_frame_duplicate(f)),
466 "Error extracting frame '%s' from frame set",
467 cpl_frame_get_tag(f));
473 while ((f = cpl_frameset_get_first(frames)) != NULL)
475 cpl_frameset_erase_frame(frames, f);
489 enum uves_chip chip1 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDL;
490 enum uves_chip chip2 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDU;
492 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
495 cpl_frameset_get_size(fms) >
496 cpl_frameset_get_size(common_frames);
498 uves_msg_debug(
"nraw_arm=%d (%s arm)", nraw_arm[blue], blue ?
"blue" :
"red");
500 run_scired[blue] = do_science &&
501 !(is_missing(fms, UVES_SCIENCE(blue), NULL) &&
502 is_missing(fms, UVES_SCI_EXTND(blue), NULL) &&
503 is_missing(fms, UVES_SCI_POINT(blue), NULL) &&
504 is_missing(fms, UVES_SCI_SLICER(blue), NULL));
509 (!do_science && nraw_arm[blue])) {
512 run_mbias[blue] = is_missing(fms,
513 UVES_MASTER_BIAS(chip1),
514 UVES_MASTER_BIAS(chip2)
520 UVES_MASTER_DARK(chip1),
521 UVES_MASTER_DARK(chip2))
524 UVES_MASTER_PDARK(chip1),
525 UVES_MASTER_PDARK(chip2))
527 !is_missing(fms, UVES_DARK(blue), NULL) ||
528 !is_missing(fms, UVES_PDARK(blue), NULL));
532 run_orderpos[blue] = is_missing(fms,
533 UVES_ORDER_TABLE(flames, chip1),
534 UVES_ORDER_TABLE(flames, chip2)
536 !is_missing(fms, UVES_ORDER_FLAT(flames, blue), NULL);
541 UVES_MASTER_FLAT(chip1),
542 UVES_MASTER_FLAT(chip2))
545 UVES_MASTER_DFLAT(chip1),
546 UVES_MASTER_DFLAT(chip2))
549 UVES_MASTER_IFLAT(chip1),
550 UVES_MASTER_IFLAT(chip2))
553 UVES_MASTER_SCREEN_FLAT(chip1),
554 UVES_MASTER_SCREEN_FLAT(chip2))
557 UVES_REF_TFLAT(chip1),
558 UVES_REF_TFLAT(chip2));
581 run_physmod[blue] = is_missing(fms,
582 UVES_LINE_TABLE(flames, chip1),
583 UVES_LINE_TABLE(flames, chip2))
586 UVES_GUESS_LINE_TABLE(flames, chip1),
587 UVES_GUESS_LINE_TABLE(flames, chip2))
591 UVES_LINE_TABLE_MIDAS(chip1, 1),
592 UVES_LINE_TABLE_MIDAS(chip2, 1)) ||
594 UVES_LINE_TABLE_MIDAS(chip1, 2),
595 UVES_LINE_TABLE_MIDAS(chip2, 2)) ||
597 UVES_LINE_TABLE_MIDAS(chip1, 3),
598 UVES_LINE_TABLE_MIDAS(chip2, 3))
609 UVES_LINE_TABLE(flames, chip1),
610 UVES_LINE_TABLE(flames, chip2))
614 UVES_LINE_TABLE_MIDAS(chip1, 1),
615 UVES_LINE_TABLE_MIDAS(chip2, 1)) ||
617 UVES_LINE_TABLE_MIDAS(chip1, 2),
618 UVES_LINE_TABLE_MIDAS(chip2, 2)) ||
620 UVES_LINE_TABLE_MIDAS(chip1, 3),
621 UVES_LINE_TABLE_MIDAS(chip2, 3))
627 UVES_ARC_LAMP(flames, blue), NULL) ||
629 UVES_ECH_ARC_LAMP(blue), NULL)
634 run_response[blue] = !is_missing(fms,
635 UVES_STD_STAR(blue), NULL);
638 uves_msg(
"Reduction strategy for %s arm:", (blue) ?
"BLUE" :
"RED");
639 uves_msg(
"Run %-13s: %s", make_str(UVES_MBIAS_ID) , (run_mbias[blue] ) ?
"Yes" :
"No");
640 uves_msg(
"Run %-13s: %s", make_str(UVES_MDARK_ID) , (run_mdark[blue] ) ?
"Yes" :
"No");
641 uves_msg(
"Run %-13s: %s", make_str(UVES_PHYSMOD_ID) , (run_physmod[blue] ) ?
"Yes" :
"No");
642 uves_msg(
"Run %-13s: %s", make_str(UVES_ORDERPOS_ID), (run_orderpos[blue]) ?
"Yes" :
"No");
643 uves_msg(
"Run %-13s: %s", make_str(UVES_MFLAT_ID) , (run_mflat[blue] ) ?
"Yes" :
"No");
644 uves_msg(
"Run %-13s: %s", make_str(UVES_WAVECAL_ID) , (run_wavecal[blue] ) ?
"Yes" :
"No");
645 uves_msg(
"Run %-13s: %s", make_str(UVES_RESPONSE_ID), (run_response[blue]) ?
"Yes" :
"No");
646 uves_msg(
"Run %-13s: %s", make_str(UVES_SCIRED_ID) , (run_scired[blue] ) ?
"Yes" :
"No");
651 (blue) ?
"BLUE" :
"RED");
653 run_mbias[blue] =
false;
654 run_mdark[blue] =
false;
655 run_mflat[blue] =
false;
656 run_physmod[blue] =
false;
657 run_orderpos[blue] =
false;
658 run_wavecal[blue] =
false;
659 run_response[blue] =
false;
673 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
675 assure( !run_mbias[blue] || !is_missing(fms, UVES_BIAS(blue), NULL),
676 CPL_ERROR_DATA_NOT_FOUND,
677 "One or more '%s' frames needed for recipe '%s'",
678 UVES_BIAS(blue), make_str(UVES_MBIAS_ID));
680 assure( !run_mdark[blue] ||
681 !is_missing(fms, UVES_DARK(blue), NULL) ||
682 !is_missing(fms, UVES_PDARK(blue), NULL),
683 CPL_ERROR_DATA_NOT_FOUND,
684 "One or more '%s' or '%s' frames needed for recipe '%s'",
685 UVES_DARK(blue), UVES_PDARK(blue), make_str(UVES_MDARK_ID));
687 assure( !run_physmod[blue] || !is_missing(fms, UVES_FORMATCHECK(flames, blue), NULL),
688 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
689 UVES_FORMATCHECK(flames, blue), make_str(UVES_PHYSMOD_ID));
691 assure( !run_orderpos[blue] || !is_missing(fms, UVES_ORDER_FLAT(flames, blue), NULL),
692 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
693 UVES_ORDER_FLAT(flames, blue), make_str(UVES_ORDERPOS_ID));
695 assure( !run_mflat[blue] ||
696 !is_missing(fms, UVES_FLAT(blue), NULL) ||
697 !is_missing(fms, UVES_IFLAT(blue), NULL) ||
698 !is_missing(fms, UVES_SCREEN_FLAT(blue), NULL) ||
699 !is_missing(fms, UVES_DFLAT(blue), NULL) ||
700 !is_missing(fms, UVES_TFLAT(blue), NULL),
701 CPL_ERROR_DATA_NOT_FOUND,
702 "One or more '%s', '%s', '%s', '%s' or '%s' frames needed for recipe '%s'",
705 UVES_SCREEN_FLAT(blue),
708 make_str(UVES_MFLAT_ID));
710 assure( !run_wavecal[blue] || (
711 !is_missing(fms, UVES_ARC_LAMP(flames, blue), NULL) ||
712 !is_missing(fms, UVES_ECH_ARC_LAMP(blue), NULL)),
713 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' or '%s' needed for recipe '%s'",
714 UVES_ARC_LAMP(flames, blue), UVES_ECH_ARC_LAMP(blue), make_str(UVES_WAVECAL_ID));
715 assure( !run_wavecal[blue] || !is_missing(fms, UVES_LINE_REFER_TABLE, NULL),
716 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
717 UVES_LINE_REFER_TABLE, make_str(UVES_WAVECAL_ID));
719 assure( !run_response[blue] || !is_missing(fms, UVES_STD_STAR(blue), NULL),
720 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
721 UVES_STD_STAR(blue), make_str(UVES_RESPONSE_ID));
722 assure( !run_response[blue] || !is_missing(fms, UVES_FLUX_STD_TABLE, NULL),
723 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
724 UVES_FLUX_STD_TABLE, make_str(UVES_RESPONSE_ID));
725 assure( !run_response[blue] || !is_missing(fms, UVES_EXTCOEFF_TABLE, NULL),
726 CPL_ERROR_DATA_NOT_FOUND,
"Frame '%s' needed for recipe '%s'",
727 UVES_EXTCOEFF_TABLE, make_str(UVES_RESPONSE_ID));
741 enum uves_chip chip1 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDL;
742 enum uves_chip chip2 = (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDU;
744 cpl_frameset *fms = (blue) ? blue_frames : red_frames;
748 const char *products[2];
750 int nprod =
sizeof(products) /
sizeof (
char *);
752 products[0] = UVES_MASTER_BIAS(chip1);
753 products[1] = UVES_MASTER_BIAS(chip2);
755 if (blue) nprod /= 2;
757 check( execute_recipe(make_str(UVES_MBIAS_ID), fms, parameters, products, nprod,
true),
758 "Recipe execution failed");
761 check( remove_input_frame(fms, UVES_BIAS(blue)),
"Error removing input frames");
765 const char *products[4];
767 int nprod =
sizeof(products) /
sizeof (
char *);
769 products[0] = UVES_MASTER_DARK(chip1);
770 products[1] = UVES_MASTER_PDARK(chip1);
771 products[2] = UVES_MASTER_DARK(chip2);
772 products[3] = UVES_MASTER_PDARK(chip2);
774 if (blue) nprod /= 2;
776 check( execute_recipe(
777 make_str(UVES_MDARK_ID), fms, parameters, products, nprod,
true),
778 "Recipe execution failed");
781 check( remove_input_frame(fms, UVES_DARK(blue)),
"Error removing input frames");
782 check( remove_input_frame(fms, UVES_PDARK(blue)),
"Error removing input frames");
784 if (run_physmod[blue])
786 const char *products[4];
787 int nprod =
sizeof(products) /
sizeof (
char *);
789 products[0] = UVES_GUESS_LINE_TABLE (flames, chip1);
790 products[1] = UVES_GUESS_ORDER_TABLE(flames, chip1);
791 products[2] = UVES_GUESS_LINE_TABLE (flames, chip2);
792 products[3] = UVES_GUESS_ORDER_TABLE(flames, chip2);
794 if (blue) nprod /= 2;
796 check( execute_recipe(
797 make_str(UVES_PHYSMOD_ID),
798 fms, parameters, products, nprod,
true),
799 "Recipe execution failed");
802 check( remove_input_frame(fms, UVES_FORMATCHECK(flames, blue)),
803 "Error removing input frames");
805 if (run_orderpos[blue])
807 const char *products[2];
808 int nprod =
sizeof(products) /
sizeof (
char *);
810 products[0] = UVES_ORDER_TABLE(flames, chip1);
811 products[1] = UVES_ORDER_TABLE(flames, chip2);
813 if (blue) nprod /= 2;
815 check( execute_recipe(
816 make_str(UVES_ORDERPOS_ID),
817 fms, parameters, products, nprod,
true),
818 "Recipe execution failed");
821 check( remove_input_frame(fms, UVES_ORDER_FLAT(flames, blue)),
822 "Error removing input frames");
826 const char *products[10];
828 int nprod =
sizeof(products) /
sizeof (
char *);
830 products[0] = UVES_MASTER_FLAT(chip1);
831 products[1] = UVES_MASTER_DFLAT(chip1);
832 products[2] = UVES_MASTER_IFLAT(chip1);
833 products[3] = UVES_MASTER_TFLAT(chip1);
834 products[4] = UVES_MASTER_SCREEN_FLAT(chip1);
835 products[5] = UVES_MASTER_FLAT(chip2);
836 products[6] = UVES_MASTER_DFLAT(chip2);
837 products[7] = UVES_MASTER_IFLAT(chip2);
838 products[8] = UVES_MASTER_TFLAT(chip2);
839 products[9] = UVES_MASTER_SCREEN_FLAT(chip2);
841 if (blue) nprod /= 2;
843 check( execute_recipe(make_str(UVES_MFLAT_ID),
844 fms, parameters, products, nprod,
true),
845 "Recipe execution failed");
848 check( remove_input_frame(fms, UVES_FLAT(blue)),
"Error removing input frames");
849 check( remove_input_frame(fms, UVES_IFLAT(blue)),
"Error removing input frames");
850 check( remove_input_frame(fms, UVES_DFLAT(blue)),
"Error removing input frames");
851 check( remove_input_frame(fms, UVES_TFLAT(blue)),
"Error removing input frames");
852 check( remove_input_frame(fms, UVES_SCREEN_FLAT(blue)),
"Error removing input frames");
854 if (run_wavecal[blue])
856 const char *products[2];
858 int nprod =
sizeof(products) /
sizeof (
char *);
860 products[0] = UVES_LINE_TABLE(flames, chip1);
861 products[1] = UVES_LINE_TABLE(flames, chip2);
863 if (blue) nprod /= 2;
865 check( execute_recipe(make_str(UVES_WAVECAL_ID),
866 fms, parameters, products, nprod,
true),
867 "Recipe execution failed");
870 check( remove_input_frame(fms, UVES_ARC_LAMP(flames, blue)),
871 "Error removing input frames");
872 check( remove_input_frame(fms, UVES_ECH_ARC_LAMP(blue)),
873 "Error removing input frames");
874 check( remove_input_frame(fms, UVES_LINE_REFER_TABLE),
875 "Error removing input frames");
877 if (run_response[blue])
879 const char *products[2];
881 int nprod =
sizeof(products) /
sizeof (
char *);
883 products[0] = UVES_INSTR_RESPONSE(chip1);
884 products[1] = UVES_INSTR_RESPONSE(chip2);
886 if (blue) nprod /= 2;
888 check( execute_recipe(make_str(UVES_RESPONSE_ID),
889 fms, parameters, products, nprod,
true),
890 "Recipe execution failed");
893 check( remove_input_frame(fms, UVES_STD_STAR(blue)),
"Error removing input frames");
894 check( remove_input_frame(fms, UVES_FLUX_STD_TABLE),
"Error removing input frames");
896 if (run_scired[blue])
898 const char *products[2];
900 int nprod =
sizeof(products) /
sizeof (
char *);
902 products[0] = blue ?
"RED_SCIENCE_BLUE" :
"RED_SCIENCE_REDL";
903 products[1] = blue ?
"RED_SCIENCE_BLUE" :
"RED_SCIENCE_REDU";
905 if (blue) nprod /= 2;
907 check( execute_recipe(make_str(UVES_SCIRED_ID),
908 fms, parameters, products, nprod,
false),
909 "Recipe execution failed");
912 check( remove_input_frame(fms, UVES_SCIENCE(blue)) ,
"Error removing input frames");
913 check( remove_input_frame(fms, UVES_SCI_EXTND(blue)) ,
"Error removing input frames");
914 check( remove_input_frame(fms, UVES_SCI_POINT(blue)) ,
"Error removing input frames");
915 check( remove_input_frame(fms, UVES_SCI_SLICER(blue)),
"Error removing input frames");
921 for (f = cpl_frameset_get_first(fms);
923 f = cpl_frameset_get_next(fms))
925 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
927 check( cpl_frameset_insert(frames, cpl_frame_duplicate(f)),
928 "Error inserting product '%s' into frame set",
929 cpl_frame_get_tag(f));
939 uves_free_frameset(&blue_frames);
940 uves_free_frameset(&red_frames);
941 uves_free_frameset(&common_frames);
950 frame_is_needed(
bool blue,
const cpl_frame *f)
952 const char *tag = cpl_frame_get_tag(f);
954 bool result = (strcmp(tag, UVES_ORDER_FLAT (flames, blue)) == 0 ||
955 strcmp(tag, UVES_BIAS (blue)) == 0 ||
956 strcmp(tag, UVES_DARK (blue)) == 0 ||
957 strcmp(tag, UVES_PDARK (blue)) == 0 ||
958 strcmp(tag, UVES_FLAT (blue)) == 0 ||
959 strcmp(tag, UVES_IFLAT (blue)) == 0 ||
960 strcmp(tag, UVES_DFLAT (blue)) == 0 ||
961 strcmp(tag, UVES_TFLAT (blue)) == 0 ||
962 strcmp(tag, UVES_SCREEN_FLAT(blue)) == 0 ||
963 strcmp(tag, UVES_STD_STAR (blue)) == 0 ||
964 strcmp(tag, UVES_FORMATCHECK(flames, blue)) == 0 ||
965 strcmp(tag, UVES_STD_STAR (blue)) == 0 ||
966 strcmp(tag, UVES_SCIENCE (blue)) == 0 ||
967 strcmp(tag, UVES_SCI_EXTND (blue)) == 0 ||
968 strcmp(tag, UVES_SCI_POINT (blue)) == 0 ||
969 strcmp(tag, UVES_SCI_SLICER (blue)) == 0 ||
970 strcmp(tag, UVES_ARC_LAMP (flames, blue)) == 0 ||
971 strcmp(tag, UVES_ECH_ARC_LAMP(blue)) == 0);
977 chip != UVES_CHIP_INVALID;
980 result = result || (strcmp(tag, UVES_DRS_SETUP(flames, chip)) == 0 ||
981 strcmp(tag, UVES_ORDER_TABLE(flames, chip)) == 0 ||
982 strcmp(tag, UVES_GUESS_ORDER_TABLE(flames, chip)) == 0 ||
983 strcmp(tag, UVES_MASTER_BIAS(chip)) == 0 ||
984 strcmp(tag, UVES_MASTER_DARK(chip)) == 0 ||
985 strcmp(tag, UVES_MASTER_PDARK(chip)) == 0 ||
986 strcmp(tag, UVES_MASTER_FLAT(chip)) == 0 ||
987 strcmp(tag, UVES_MASTER_DFLAT(chip)) == 0 ||
988 strcmp(tag, UVES_MASTER_IFLAT(chip)) == 0 ||
989 strcmp(tag, UVES_MASTER_TFLAT(chip)) == 0 ||
990 strcmp(tag, UVES_REF_TFLAT(chip)) == 0 ||
991 strcmp(tag, UVES_MASTER_SCREEN_FLAT(chip)) == 0 ||
992 strcmp(tag, UVES_LINE_TABLE (flames, chip)) == 0 ||
993 strcmp(tag, UVES_GUESS_LINE_TABLE(flames, chip)) == 0 ||
994 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 1)) == 0 ||
995 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 2)) == 0 ||
996 strcmp(tag, UVES_LINE_TABLE_MIDAS(chip, 3)) == 0 ||
997 strcmp(tag, UVES_LINE_REFER_TABLE ) == 0 ||
998 strcmp(tag, UVES_FLUX_STD_TABLE ) == 0 ||
999 strcmp(tag, UVES_EXTCOEFF_TABLE ) == 0);
1005 static cpl_error_code
1006 execute_recipe(
const char *recipe_id,
1007 cpl_frameset *frames,
const cpl_parameterlist *parameters,
1008 const char *products[],
1013 cpl_frame *f = NULL;
1017 for (i = 0; i < n_products; i++)
1019 if ((f = cpl_frameset_find(frames, products[i])) != NULL)
1021 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
1023 cpl_msg_warning(__func__,
"Ignoring %s frame in '%s'. "
1024 "A new %s frame will now be calculated",
1025 products[i], cpl_frame_get_filename(f),
1028 cpl_frameset_erase_frame(frames, f);
1034 check( uves_invoke_recipe(recipe_id, parameters, frames, make_str(UVES_REDCHAIN_ID), NULL),
1035 "Recipe '%s' failed", recipe_id);
1037 check(cpl_dfs_update_product_header(frames),
"Error updating pipe products' header");
1046 for (i = 0; i < n_products; i++)
1048 if ((f = cpl_frameset_find(frames, products[i])) != NULL &&
1049 cpl_frame_get_group(f) != CPL_FRAME_GROUP_PRODUCT)
1051 uves_msg(
"Removing %s frame in '%s' from frameset. "
1052 "It is not tagged as a product",
1053 products[i], cpl_frame_get_filename(f));
1055 cpl_frameset_erase_frame(frames, f);
1062 for (i = 0; i < n_products; i++)
1064 cpl_frame *found = NULL;
1065 for (f = cpl_frameset_get_first(frames);
1067 f = cpl_frameset_get_next(frames))
1069 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
1071 if (strcmp(cpl_frame_get_tag(f), products[i]) == 0)
1081 uves_msg(
"Re-classifying %s product in '%s' PRODUCT->CALIB",
1082 products[i], cpl_frame_get_filename(found));
1084 cpl_frame_set_group(found, CPL_FRAME_GROUP_CALIB);
1092 for (f = cpl_frameset_get_first(frames);
1094 f = cpl_frameset_get_next(frames))
1096 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_PRODUCT)
1099 uves_msg(
"Removing product %s in '%s' from frameset. "
1101 cpl_frame_get_tag(f), cpl_frame_get_filename(f));
1103 cpl_frameset_erase_frame(frames, f);
1110 return cpl_error_get_code();
1120 is_missing(
const cpl_frameset *frames,
const char *frame1,
const char *frame2)
1122 bool result =
false;
1123 if (cpl_frameset_find_const(frames, frame1) == NULL)
1125 uves_msg(
"checking for %s... no", frame1);
1130 uves_msg(
"checking for %s... yes", frame1);
1133 if (frame2 != NULL && strcmp(frame1, frame2) != 0)
1135 if (cpl_frameset_find_const(frames, frame2) == NULL)
1137 uves_msg(
"checking for %s... no", frame2);
1142 uves_msg(
"checking for %s... yes", frame2);
1152 remove_input_frame(cpl_frameset *frames,
const char *tag)
1154 int removed = cpl_frameset_erase(frames, tag);
1158 uves_msg(
"Removing %d %s frame(s) from frame set", removed, tag);