44 #include <uves_reduce_scired.h>
46 #include <uves_reduce.h>
47 #include <uves_reduce_utils.h>
48 #include <uves_corrbadpix.h>
50 #include <uves_chip.h>
51 #include <uves_plot.h>
53 #include <uves_pfits.h>
54 #include <uves_parameters.h>
56 #include <uves_utils.h>
57 #include <uves_utils_wrappers.h>
58 #include <uves_qclog.h>
59 #include <uves_error.h>
60 #include <uves_merge.h>
62 #include <uves_dump.h>
73 const cpl_image *raw_image,
86 const char *
const uves_scired_desc_short =
"Reduces a science frame";
87 const char *
const uves_scired_desc =
88 "This recipe reduces a science frame (SCIENCE_BLUE or SCIENCE_RED, or\n"
89 "UVES_SCI_POINT_BLUE or UVES_SCI_POINT_RED, or \n"
90 "UVES_SCI_EXTND_BLUE or UVES_SCI_EXTND_RED or \n"
91 "UVES_SCI_SLICER_BLUE or UVES_SCI_SLICER_RED) using "
92 "a combination (depending on recipe parameters and provided input frames) of "
94 " - bias subtraction,\n"
95 " - dark subtraction,\n"
96 " - background subtraction,\n"
97 " - extraction/cosmic ray removal,\n"
98 " - flat field correction,\n"
99 " - wavelength rebinning,\n"
100 " - sky subtraction,\n"
101 " - order merging,\n"
102 " - response correction (if response curve is provided).\n"
104 "Additional input for this recipe are: \n"
105 "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
106 "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
107 "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n"
108 "optionally an instrument response table, INSTR_RESPONSE_xxx\n"
109 "optionally a table describing the atmospheric extintion,\n"
111 "For each chip (xxxx = BLUE, REDL, REDU) the recipe produces a combination of "
113 " 'RED_SCIENCE_xxxx' Reduced science spectrum\n"
114 " 'MERGED_SCIENCE_xxxx' Merged spectrum, no sky subtraction\n"
115 " 'WCALIB_SCIENCE_xxxx' Extracted, wavelength calibrated frame in\n"
116 " (wavelength, order) space\n"
117 " 'WCALIB_FF_SCIENCE_xxxx' Extracted, flat-fielded, wave.cal. frame in\n"
118 " (wavelength, order) space\n"
119 " (Only if flatfielding done)\n"
120 " 'WCALIB_FLAT_OBJ_xxxx' Extracted, wavelength calibrated flat field\n"
121 " in (wavelength, order) space\n"
122 " (Only if flatfielding done)\n"
123 " 'ERRORBAR_SCIENCE_xxxx' Error bars of 'RED_SCIENCE_xxxx'\n"
124 " 'VARIANCE_SCIENCE_xxxx' Variance of extracted, flatfielded object in\n"
125 " (pixel, order) space\n"
126 " 'ORDER_TRACE_xxxx' Table describing the spatial profile\n"
127 " 'FLUXCAL_SCIENCE_xxxx' Flux-calibrated science spectrum\n"
128 " 'FLUXCAL_ERROR_xxxx' Error bars of 'FLUXCAL_SCIENCE_xxxx'\n"
129 " 'BKG_SCI_xxxx' The subtracted background image\n"
130 " 'CRMASK_xxxx' List of cosmic ray hits\n"
131 " 'MERGED_SKY_xxxx' The merged sky spectrum\n"
132 " 'EXT_2D_SCIENCE_xxxx' The 2d extracted spectrum\n"
133 " 'FF2D_SCIENCE_xxxx' The 2d extracted, flat-fielded spectrum\n"
134 " 'WCAL2D_SCIENCE_xxxx' The 2d extracted, flat-fielded, wave.cal. spectrum\n"
135 " 'MER2D_SCIENCE_xxxx' The 2d reduced, flux-calibrated (if possible) \n"
136 " science spectrum\n";
150 const char* key_comm=NULL;
156 sprintf(key_name_o,
"CUNIT1");
157 key_comm=
"Wavelength units";
160 sprintf(key_name_i,
"ESO QC LINE RESIDRMS WLU");
161 sprintf(key_name_o,
"LAMRMS");
162 key_comm=
"RMS of wavelength solution [CUNIT1]";
171 sprintf(key_name_i,
"ESO QC NLINSOL");
172 sprintf(key_name_o,
"LAMNLIN");
173 key_comm=
"No. of lines used in wavelength solution";
182 sprintf(key_name_i,
"ESO QC LINE WAVEERR");
183 sprintf(key_name_o,
"CRDER1");
184 key_comm=
"Wavelength uncertainty [CUNIT1]";
192 sprintf(key_name_i,
"ESO QC LINE SYSERR");
193 sprintf(key_name_o,
"CSYER1");
194 key_comm=
"Typical systematic wavelength error [CUNIT1]";
217 const char *recipe_id)
223 if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
232 if (uves_corr_traps_define_parameters(parameters,recipe_id)
241 if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
242 recipe_id, NULL) != 0)
247 return (cpl_error_get_code() != CPL_ERROR_NONE);
252 uves_get_pro_catg_special(
bool extract_is_2d, merge_method m_method) {
253 const char* result=NULL;
254 if(extract_is_2d && m_method == MERGE_NOAPPEND) {
256 }
else if (!extract_is_2d &&
257 m_method == MERGE_NOAPPEND) {
276 cpl_frame **result = NULL;
279 sz=cpl_frameset_get_size(frames);
280 result = cpl_calloc( sz + 1,
sizeof(*result) );
282 for ( i = 0;i < sz; i++ )
284 f=cpl_frameset_get_frame(frames, i);
285 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_RAW)
288 cpl_frame_set_group(f, CPL_FRAME_GROUP_NONE);
371 static cpl_error_code
375 const cpl_image *master_bias,
377 const cpl_image *master_dark,
379 const cpl_image *master_flat,
381 const cpl_table *ordertable,
383 const cpl_table *linetable[3],
386 const cpl_image *response_curve,
387 const cpl_table *master_response,
389 const cpl_table *atm_extinction,
397 const cpl_parameterlist *parameters,
398 const char *recipe_id,
402 cpl_image **background,
403 cpl_image **flatfielded_variance,
405 cpl_image **resampled_science,
406 cpl_image **resampled_mf,
407 cpl_image **rebinned_science,
408 cpl_image **rebinned_noise,
410 cpl_image **merged_sky,
411 cpl_image **merged_science,
413 cpl_image **reduced_science,
414 cpl_image **reduced_science_error,
415 cpl_table **cosmic_mask,
416 cpl_image **wave_map,
417 cpl_image **fluxcal_science,
418 cpl_image **fluxcal_error,
420 cpl_table **info_tbl,
421 double *extraction_slit,
422 cpl_table **order_trace)
425 cpl_image *merged_noise = NULL;
427 cpl_image *reduced_rebinned = NULL;
428 cpl_image *reduced_rebinned_noise = NULL;
430 cpl_table *response_table = NULL;
433 uves_msg(
"Reducing science object");
461 flatfielded_variance,
462 flatfielded_variance_header,
473 &reduced_rebinned_noise,
475 reduced_science_error,
479 "Could not reduce frame");
482 check( uves_plot_image_rows(*reduced_science,
483 1 + cpl_image_get_size_y(*reduced_science)/2,
484 1 + cpl_image_get_size_y(*reduced_science)/2, 1,
485 "Wavelength (arbitrary units)",
"Relative flux",
486 "Reduced science spectrum"),
495 if (response_curve != NULL || master_response != NULL)
502 int n_traces = cpl_image_get_size_y(*reduced_science);
504 uves_msg(
"Flux calibrating spectrum");
515 if (response_curve != NULL) {
516 response_table = cpl_table_new(cpl_image_get_size_x(response_curve));
517 cpl_table_new_column(response_table,
"LAMBDA", CPL_TYPE_DOUBLE);
518 cpl_table_new_column(response_table,
"FLUX_CONV", CPL_TYPE_DOUBLE);
521 "Error reading response curve start wavelength from header");
524 "Error reading bin width from header");
526 for (bin = 1; bin <= cpl_image_get_size_x(response_curve); bin++) {
531 lambda = lambda_start + (bin-1) * dlambda;
533 check( response = cpl_image_get(response_curve, bin, 1, &pis_rejected),
534 "Error reading response curve bin = %d", bin);
536 check((cpl_table_set_double(response_table,
"LAMBDA", bin - 1, lambda),
537 cpl_table_set_double(response_table,
"FLUX_CONV", bin - 1, response)),
538 "Error updating response table at row %d", bin - 1);
542 response_table = cpl_table_duplicate( master_response );
550 *reduced_science_error,
558 "Error normalizing reduced spectrum");
564 uves_msg(
"Multiplying by response function");
566 int nbins = cpl_image_get_size_x(*fluxcal_science);
567 int ntraces = cpl_image_get_size_y(*fluxcal_science);
568 double *fluxcal_science_data = cpl_image_get_data_double(*fluxcal_science);
569 double *fluxcal_science_noise = cpl_image_get_data_double(*fluxcal_error);
572 "Error reading start wavelength from reduced science header");
575 "Error reading bin width from header");
577 for (bin = 1; bin <= nbins; bin++)
584 lambda = lambda_start + (bin-1) * dlambda;
588 "LAMBDA",
"FLUX_CONV", &istart),
589 "Error interpolating response curve at lambda = %f wlu", lambda);
591 for (trace = 1; trace <= ntraces; trace++)
597 fluxcal_science_data [(bin-1) + (trace-1)*nbins] *= response;
598 fluxcal_science_noise[(bin-1) + (trace-1)*nbins] *= response;
607 check( uves_plot_image_rows(*fluxcal_science,
608 1 + cpl_image_get_size_y(*fluxcal_science)/2,
609 1 + cpl_image_get_size_y(*fluxcal_science)/2, 1,
610 "Wavelength (arbitrary units)",
611 "Flux (10^-16 erg/cm^2/Angstrom/s)",
612 "Flux calibrated science spectrum"),
617 "10^-16 erg/cm^2/Angstrom/s",
622 "Error initializing flux calibrated spectrum header");
627 uves_msg(
"Skipping absolute flux calibration");
631 uves_free_image(&merged_noise);
632 uves_free_image(&reduced_rebinned_noise);
633 uves_free_image(&reduced_rebinned);
634 uves_free_table(&response_table);
636 if (cpl_error_get_code() != CPL_ERROR_NONE)
640 return cpl_error_get_code();
655 const char *recipe_id,
const char *starttime)
660 bool extract_is_2d =
false;
663 cpl_image *raw_image[2] = {NULL, NULL};
668 cpl_image *master_bias = NULL;
671 cpl_image *master_flat = NULL;
674 cpl_image *master_dark = NULL;
677 cpl_table *ordertable = NULL;
680 cpl_table *traces = NULL;
683 const cpl_table *linetable[3] = {NULL, NULL, NULL};
685 const polynomial *dispersion_relation[3] = {NULL, NULL, NULL};
687 cpl_image *response_curve = NULL;
689 cpl_table *master_response = NULL;
691 cpl_table *atm_extinction = NULL;
695 cpl_image *background = NULL;
698 cpl_image *flatfielded_variance = NULL;
702 cpl_image *resampled_science = NULL;
704 cpl_image *resampled_mf = NULL;
706 cpl_image *rebinned_science = NULL;
707 cpl_image *rebinned_science_error = NULL;
711 cpl_image *merged_sky = NULL;
716 cpl_image *merged_science = NULL;
718 cpl_image *reduced_science = NULL;
719 cpl_image *reduced_science_error = NULL;
723 cpl_image *fluxcal_science = NULL;
724 cpl_image *fluxcal_error = NULL;
728 cpl_table *order_trace = NULL;
733 cpl_image *x2d = NULL;
736 cpl_image *fx2d = NULL;
739 cpl_table *cosmic_mask = NULL;
743 cpl_table* qclog[2] = {NULL, NULL};
744 cpl_table *qclog_tflat = NULL;
747 const char *raw_filename =
"";
748 const char *atm_ext_filename =
"";
749 const char *sci_type =
"";
750 cpl_frame **raw_frames = NULL;
751 char *product_tag = NULL;
752 char *product_filename = NULL;
753 char *context = NULL;
754 double extraction_slit;
761 cpl_table* info_tbl = NULL;
762 const char* PROCESS_CHIP=NULL;
763 bool red_ccd_is_new=0;
764 merge_method m_method;
765 const char* catg_is_noappend=NULL;
766 cpl_image* wave_map=NULL;
774 const char *ex_method =
"";
777 check( uves_get_parameter(parameters, NULL,
"uves",
"debug", CPL_TYPE_BOOL, &debug_mode),
778 "Could not read parameter");
782 check( uves_get_parameter(parameters, NULL,
"uves",
"debug", CPL_TYPE_BOOL, &debug_mode),
783 "Could not read parameter");
787 check( uves_get_parameter(parameters, NULL,
"uves",
"process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
788 "Could not read parameter");
792 check( uves_get_parameter(parameters,NULL,recipe_id,
"clean_traps", CPL_TYPE_BOOL, &CLEAN_TRAPS),
793 "Could not read parameter");
798 context = uves_sprintf(
"%s.%s.%s", recipe_id, UVES_REDUCE_ID, UVES_EXTRACT_ID);
800 check( uves_get_parameter(parameters, NULL,
802 CPL_TYPE_STRING, &ex_method),
803 "Could not read parameter");
805 extract_is_2d = (strcmp(ex_method,
"2d") == 0);
808 check( uves_load_science(frames, &raw_filename, raw_image, raw_header, rotated_header,
810 "Error loading raw frame");
812 if ((strcmp(sci_type,
"SCI_SLICER") == 0 ||
813 strcmp(sci_type,
"SCI_EXTND" ) == 0) &&
814 strcmp(ex_method,
"optimal") == 0)
817 "This may not work because the sky cannot be "
818 "reliably determined",
824 if (cpl_frameset_find(frames, UVES_EXTCOEFF_TABLE) != NULL)
826 check( uves_load_atmo_ext(frames, &atm_ext_filename, &atm_extinction),
827 "Error loading atm. extinction coefficients");
829 uves_msg_low(
"Using atmospheric extinction table in '%s'", atm_ext_filename);
833 uves_msg_low(
"No atmospheric extinction table. Flux calibration not done");
837 "Could not get merging method");
843 "Could not read x binning factor from input header");
845 "Could not read y binning factor from input header");
851 chip != UVES_CHIP_INVALID;
857 if(strcmp(PROCESS_CHIP,
"REDU") == 0) {
861 cpl_frame *mflat_frame = NULL;
862 const char *ordertable_filename =
"";
863 const char *linetable_filename =
"";
864 const char *master_bias_filename =
"";
865 const char *master_dark_filename =
"";
866 const char *master_flat_filename =
"";
867 const char *response_curve_filename =
"";
868 const char *chip_name =
"";
874 uves_msg(
"Processing %s chip in '%s'",
883 uves_free_image(&master_bias);
884 uves_free_propertylist(&master_bias_header);
885 if (cpl_frameset_find(frames, UVES_MASTER_BIAS(chip)) != NULL)
887 uves_free_image(&master_bias);
888 uves_free_propertylist(&master_bias_header);
890 check( uves_load_mbias(frames, chip_name, &master_bias_filename,
891 &master_bias, &master_bias_header,
893 "Error loading master bias");
895 uves_msg_low(
"Using master bias in '%s'", master_bias_filename);
899 uves_msg_low(
"No master bias in SOF. Bias subtraction not done");
903 uves_free_image(&master_dark);
904 uves_free_propertylist(&master_dark_header);
905 if (cpl_frameset_find(frames, UVES_MASTER_DARK(chip)) != NULL ||
906 cpl_frameset_find(frames, UVES_MASTER_PDARK(chip)) != NULL)
909 check( uves_load_mdark(frames, chip_name, &master_dark_filename,
910 &master_dark, &master_dark_header, chip),
911 "Error loading master dark");
913 uves_msg_low(
"Using master dark in '%s'", master_dark_filename);
917 uves_msg_low(
"No master dark in SOF. Dark subtraction not done");
921 uves_free_image(&master_flat);
922 uves_free_propertylist(&master_flat_header);
923 check( uves_load_mflat(frames, chip_name, &master_flat_filename, &master_flat,
924 &master_flat_header, chip, &mflat_frame),
925 "Error loading master flat");
927 uves_msg_low(
"Using master flat in '%s'", master_flat_filename);
931 uves_free_table (&ordertable);
932 uves_free_propertylist(&ordertable_header);
934 uves_free_table (&traces);
936 check( uves_load_ordertable(frames,
939 &ordertable_filename,
948 "Could not load order table");
949 uves_msg_low(
"Using order table in '%s'", ordertable_filename);
953 if (atm_extinction != NULL)
955 if (cpl_frameset_find(frames, UVES_INSTR_RESPONSE(chip)) != NULL ||
956 cpl_frameset_find(frames, UVES_MASTER_RESPONSE(chip)) != NULL)
958 uves_free_image(&response_curve);
959 uves_free_table(&master_response);
960 uves_free_propertylist(&response_curve_header);
961 check( uves_load_response_curve(frames, chip_name,
962 &response_curve_filename,
965 &response_curve_header,
967 "Error loading response curve");
970 master_response != NULL ?
"master " :
"",
971 response_curve_filename);
976 "Flux calibration not done");
982 "Do not look for response curve");
986 for(tracerow = 0; tracerow < cpl_table_get_nrow(traces); tracerow++)
991 int badpixels_cleaned;
992 trace_offset = cpl_table_get_double(traces,
"Offset" , tracerow, NULL);
993 trace_number = cpl_table_get_int (traces,
"TraceID" , tracerow, NULL);
994 trace_enabled = cpl_table_get_int (traces,
"Tracemask" , tracerow, NULL);
996 if (trace_enabled != 0)
1000 if (cpl_table_get_nrow(traces) > 1) {
1001 uves_msg(
"Processing trace %d", trace_number);
1008 for (window = 1; window <= 3; window ++) {
1009 uves_free_table_const ( &(linetable[window-1]) );
1010 uves_free_propertylist_const( &(linetable_header[window-1]) );
1012 check( uves_load_linetable_const(frames,
1016 cpl_table_get_column_min(
1017 ordertable,
"Order"),
1018 cpl_table_get_column_max(
1019 ordertable,
"Order"),
1020 &linetable_filename,
1021 &(linetable [window-1]),
1022 &(linetable_header [window-1]),
1023 &(dispersion_relation[window-1]),
1028 "Could not load line table, window #%d", window);
1030 uves_msg_low(
"Using line table(s) in '%s'", linetable_filename);
1034 uves_free_propertylist(&wave_acc_header);
1035 wave_acc_header=uves_paste_wave_accuracy(plist);
1036 uves_free_propertylist(&plist);
1040 uves_free_image(&x2d);
1041 uves_free_image(&fx2d);
1042 uves_free_propertylist(&x2d_header);
1043 uves_free_image(&background);
1044 uves_free_image(&flatfielded_variance);
1045 uves_free_propertylist(&flatfielded_variance_header);
1046 uves_free_image(&resampled_science);
1047 uves_free_image(&resampled_mf);
1048 uves_free_image(&rebinned_science);
1049 uves_free_image(&rebinned_science_error);
1050 uves_free_propertylist(&rebinned_header);
1051 uves_free_image(&merged_sky);
1052 uves_free_image(&merged_science);
1053 uves_free_propertylist(&merged_header);
1054 uves_free_image(&reduced_science);
1055 uves_free_image(&reduced_science_error);
1056 uves_free_table(&cosmic_mask);
1057 uves_free_image(&fluxcal_science);
1058 uves_free_image(&fluxcal_error);
1059 uves_free_propertylist(&fluxcal_header);
1060 uves_free_table(&info_tbl);
1061 uves_free_table(&order_trace);
1065 check( badpixels_cleaned =
1067 raw_header[raw_index],
1069 false,red_ccd_is_new),
1070 "Error replacing bad pixels");
1077 raw_image[raw_index],
1078 raw_header[raw_index],
1079 rotated_header[raw_index],
1090 dispersion_relation,
1093 response_curve_header,
1103 &flatfielded_variance,
1104 &flatfielded_variance_header,
1108 &rebinned_science_error,
1114 &reduced_science_error,
1123 "Science reduction failed");
1131 raw_header[raw_index],
1132 raw_image[raw_index],
1135 "Could not compute QC parameters");
1147 cpl_free(product_filename);
1148 check( product_filename =
1150 uves_scired_red_2d_science_filename(chip) :
1151 ((m_method == MERGE_NOAPPEND) ?
1152 uves_scired_red_noappend_science_filename(chip): uves_scired_red_science_filename(chip)),
1153 "Error getting filename");
1155 cpl_free(product_tag);
1156 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1157 product_tag = uves_sprintf(
1160 (extract_is_2d) ?
"_2D" :
"",
1165 check( uves_frameset_insert(frames,
1167 CPL_FRAME_GROUP_PRODUCT,
1168 CPL_FRAME_TYPE_IMAGE,
1169 CPL_FRAME_LEVEL_FINAL,
1172 raw_header[raw_index],
1177 PACKAGE
"/" PACKAGE_VERSION,
1182 "Could not add reduced science spectrum '%s' (%s) to frameset",
1183 product_filename, product_tag);
1185 uves_msg(
"Reduced science spectrum '%s' (%s) added to frameset",
1186 product_filename, product_tag);
1191 cpl_free(product_filename);
1192 check( product_filename = uves_scired_ext2d_filename(chip),
1193 "Error getting filename");
1195 cpl_free(product_tag);
1197 uves_sprintf(
"EXT_2D_%s_%s", sci_type,
1202 check( uves_frameset_insert(frames,
1204 CPL_FRAME_GROUP_PRODUCT,
1205 CPL_FRAME_TYPE_IMAGE,
1206 CPL_FRAME_LEVEL_FINAL,
1209 raw_header[raw_index],
1214 PACKAGE
"/" PACKAGE_VERSION,
1218 "Could not add 2d extracted "
1219 "spectrum '%s' (%s) to frameset",
1220 product_filename, product_tag);
1222 uves_msg(
"2d extracted spectrum '%s' (%s) added to frameset",
1223 product_filename, product_tag);
1229 cpl_free(product_filename);
1230 check( product_filename = (extract_is_2d) ?
1231 uves_scired_merged_2d_science_filename(chip) :
1232 uves_scired_merged_science_filename(chip),
1233 "Error getting filename");
1234 cpl_free(product_tag);
1235 product_tag = uves_sprintf(
1237 (extract_is_2d) ?
"MER_2D" :
"MERGED",
1242 check( uves_frameset_insert(frames,
1244 CPL_FRAME_GROUP_PRODUCT,
1245 CPL_FRAME_TYPE_IMAGE,
1246 CPL_FRAME_LEVEL_FINAL,
1249 raw_header[raw_index],
1254 PACKAGE
"/" PACKAGE_VERSION,
1258 "Could not add merged science spectrum '%s' (%s) to frameset",
1259 product_filename, product_tag);
1261 uves_msg(
"Merged science spectrum '%s' (%s) added to frameset",
1262 product_filename, product_tag);
1269 cpl_free(product_filename);
1270 check( product_filename = (extract_is_2d) ?
1271 uves_scired_resampled_2d_filename(chip) :
1272 uves_scired_resampled_filename(chip),
1273 "Error getting filename");
1275 cpl_free(product_tag);
1277 uves_sprintf(
"WCALIB_%s_%s", sci_type,
1282 check( uves_frameset_insert(frames,
1284 CPL_FRAME_GROUP_PRODUCT,
1285 CPL_FRAME_TYPE_IMAGE,
1286 CPL_FRAME_LEVEL_FINAL,
1289 raw_header[raw_index],
1294 PACKAGE
"/" PACKAGE_VERSION,
1298 "Could not add wavelength calibrated science "
1299 "spectrum '%s' (%s) to frameset", product_filename,
1302 uves_msg(
"Wavelength calibrated science spectrum '%s' "
1303 "(%s) added to frameset", product_filename,
1307 cpl_free(product_filename);
1309 check( product_filename =
1310 uves_order_extract_qc_standard_filename(chip),
1311 "Error getting filename");
1315 sprintf(extname,
"QC_INFO");
1318 check( uves_frameset_insert(frames,
1320 CPL_FRAME_GROUP_PRODUCT,
1321 CPL_FRAME_TYPE_TABLE,
1322 CPL_FRAME_LEVEL_INTERMEDIATE,
1324 UVES_ORDER_EXTRACT_QC(chip),
1325 raw_header[raw_index],
1326 rotated_header[raw_index],
1330 PACKAGE
"/" PACKAGE_VERSION,
1334 "Could not add extraction quality table %s (%s)"
1336 UVES_ORDER_EXTRACT_QC(chip));
1338 uves_msg(
"Extraction quality table '%s' "
1339 "(%s) added to frameset", product_filename,
1340 UVES_ORDER_EXTRACT_QC(chip));
1347 const char *ff =
"";
1351 context = uves_sprintf(
"%s.%s", recipe_id, UVES_REDUCE_ID);
1352 check( uves_get_parameter(parameters, NULL,
1355 CPL_TYPE_STRING, &ff),
1356 "Could not read parameter");
1359 if (strcmp(ff,
"no") != 0)
1363 cpl_table *qc_tabs[] = {NULL, NULL, NULL};
1369 if ( strcmp(recipe_id, make_str(UVES_TFLAT_ID)) == 0 )
1376 raw_header[raw_index],
1378 "Could not compute QC parameters");
1380 qc_tabs[0] = qclog_tflat;
1381 qc_tabs[1] = qclog[0];
1385 qc_tabs[0] = qclog[0];
1389 cpl_free(product_filename);
1390 check( product_filename =
1392 uves_scired_rebinned_2d_filename(chip) :
1393 uves_scired_rebinned_filename(chip),
1394 "Error getting filename");
1396 cpl_free(product_tag);
1397 product_tag = uves_sprintf(
1399 (extract_is_2d) ?
"WCAL_2D" :
"WCALIB_FF",
1404 check( uves_frameset_insert(frames,
1406 CPL_FRAME_GROUP_PRODUCT,
1407 CPL_FRAME_TYPE_IMAGE,
1408 CPL_FRAME_LEVEL_FINAL,
1411 raw_header[raw_index],
1421 "Could not add wavelength calibrated flat-fielded "
1422 "science spectrum '%s' (%s) to frameset",
1423 product_filename, product_tag);
1425 uves_msg(
"Wavelength calibrated flat-fielded science "
1426 "spectrum '%s' (%s) added to frameset",
1427 product_filename, product_tag);
1429 cpl_free(product_filename);
1430 check( product_filename =
1432 uves_scired_rebinned_2d_error_filename(chip) :
1433 uves_scired_rebinned_error_filename(chip),
1434 "Error getting filename");
1436 cpl_free(product_tag);
1437 product_tag = uves_sprintf(
1439 (extract_is_2d) ?
"ERRORBAR_WCAL_2D" :
"ERRORBAR_WCALIB_FF",
1447 check( uves_frameset_insert(frames,
1448 rebinned_science_error,
1449 CPL_FRAME_GROUP_PRODUCT,
1450 CPL_FRAME_TYPE_IMAGE,
1451 CPL_FRAME_LEVEL_FINAL,
1454 raw_header[raw_index],
1464 "Could not add wavelength calibrated flat-fielded "
1465 "science spectrum '%s' (%s) to frameset",
1466 product_filename, product_tag);
1468 uves_msg(
"Wavelength calibrated flat-fielded science "
1469 "spectrum error '%s' (%s) added to frameset",
1470 product_filename, product_tag);
1478 cpl_free(product_filename);
1479 check( product_filename =
1480 uves_scired_resampledmf_filename(chip),
1481 "Error getting filename");
1483 cpl_free(product_tag);
1486 "WCALIB_FLAT_OBJ_%s",
1518 cpl_free(raw_frames);
1522 cpl_frame_set_group(mflat_frame,
1523 CPL_FRAME_GROUP_RAW);
1527 check( uves_frameset_insert(
1530 CPL_FRAME_GROUP_PRODUCT,
1531 CPL_FRAME_TYPE_IMAGE,
1532 CPL_FRAME_LEVEL_FINAL,
1544 CPL_STATS_MIN | CPL_STATS_MAX),
1545 "Could not add wavelength calibrated "
1546 "flat-field '%s' (%s) to frameset",
1547 product_filename, product_tag);
1549 uves_msg(
"Wavelength calibrated flat-field "
1550 "spectrum '%s' (%s) added to frameset",
1551 product_filename, product_tag);
1557 raw_frames[i] != NULL;
1560 cpl_frame_set_group(
1562 CPL_FRAME_GROUP_RAW);
1565 cpl_frame_set_group(mflat_frame,
1566 CPL_FRAME_GROUP_CALIB);
1572 cpl_free(product_filename);
1573 check( product_filename =
1574 uves_scired_ff2d_filename(chip),
1575 "Error getting filename");
1577 cpl_free(product_tag);
1580 "FF_2D_%s_%s", sci_type,
1584 check( uves_frameset_insert(
1587 CPL_FRAME_GROUP_PRODUCT,
1588 CPL_FRAME_TYPE_IMAGE,
1589 CPL_FRAME_LEVEL_FINAL,
1592 raw_header[raw_index],
1602 "Could not add 2d extracted, flat-fielded "
1603 "spectrum '%s' (%s) to frameset",
1604 product_filename, product_tag);
1606 uves_msg(
"2d extracted, flat-fielded spectrum "
1607 "'%s' (%s) added to frameset",
1608 product_filename, product_tag);
1615 "Error writing error spectrum header");
1619 cpl_free(product_filename);
1621 check( product_filename =
1623 uves_scired_red_2d_error_filename(chip) :
1624 ((m_method == MERGE_NOAPPEND) ?
1625 uves_scired_red_noappend_error_filename(chip): uves_scired_red_error_filename(chip)),
1626 "Error getting filename");
1629 cpl_free(product_tag);
1630 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1631 product_tag = uves_sprintf(
"%s%s_%s_%s",
1632 (extract_is_2d) ?
"ERR_2D" :
"ERRORBAR",catg_is_noappend,
1645 check( uves_frameset_insert(
1647 reduced_science_error,
1648 CPL_FRAME_GROUP_PRODUCT,
1649 CPL_FRAME_TYPE_IMAGE,
1650 CPL_FRAME_LEVEL_FINAL,
1653 raw_header[raw_index],
1658 PACKAGE
"/" PACKAGE_VERSION,
1661 CPL_STATS_MIN | CPL_STATS_MAX),
1662 "Could not add error bars '%s' (%s) to frameset",
1663 product_filename, product_tag);
1665 uves_msg(
"Science spectrum error '%s' (%s) "
1666 "added to frameset",
1667 product_filename, product_tag);
1676 cpl_free(product_filename);
1677 check( product_filename =
1678 uves_scired_ff_variance_filename(chip),
1679 "Error getting filename");
1681 cpl_free(product_tag);
1683 uves_sprintf(
"VARIANCE_%s_%s", sci_type,
1689 check( uves_frameset_insert(frames,
1690 flatfielded_variance,
1691 CPL_FRAME_GROUP_PRODUCT,
1692 CPL_FRAME_TYPE_IMAGE,
1693 CPL_FRAME_LEVEL_FINAL,
1696 raw_header[raw_index],
1697 flatfielded_variance_header,
1701 PACKAGE
"/" PACKAGE_VERSION,
1704 CPL_STATS_MIN | CPL_STATS_MAX),
1705 "Could not add flat-fielded spectrum variance "
1706 "'%s' (%s) to frameset",
1707 product_filename, product_tag);
1709 uves_msg(
"Flat-fielded spectrum variance '%s' (%s) "
1710 "added to frameset",
1711 product_filename, product_tag);
1719 cpl_free(product_filename);
1720 check( product_filename =
1721 uves_scired_background_filename(chip),
1722 "Error getting filename");
1724 cpl_free(product_tag);
1726 uves_sprintf(
"BKG_SCI_%s",
1730 check( uves_frameset_insert(frames,
1732 CPL_FRAME_GROUP_PRODUCT,
1733 CPL_FRAME_TYPE_IMAGE,
1734 CPL_FRAME_LEVEL_FINAL,
1737 raw_header[raw_index],
1738 rotated_header[raw_index],
1742 PACKAGE
"/" PACKAGE_VERSION,
1745 CPL_STATS_MIN | CPL_STATS_MAX),
1746 "Could not add background image '%s' (%s) "
1747 "to frameset", product_filename, product_tag);
1749 uves_msg(
"Background image '%s' (%s) added to frameset",
1750 product_filename, product_tag);
1754 if (order_trace != NULL)
1757 uves_free_propertylist(&order_trace_header);
1771 order_trace_header,
"ESO QC OPTEX NORD",
1773 cpl_table_get_column_max(ordertable,
"Order")-
1774 cpl_table_get_column_min(ordertable,
"Order")+1));
1777 order_trace_header,
"ESO QC OPTEX XSIZE",
1778 cpl_image_get_size_x(raw_image[raw_index]));
1781 order_trace_header,
"ESO QC OPTEX YSIZE",
1782 uves_round_double(extraction_slit));
1785 cpl_free(product_filename);
1786 check( product_filename =
1787 uves_scired_ordertrace_filename(chip),
1788 "Error getting filename");
1790 cpl_free(product_tag);
1792 uves_sprintf(
"ORDER_TRACE_%s",
1796 sprintf(extname,
"TRACE_INFO");
1798 check( uves_frameset_insert(frames,
1800 CPL_FRAME_GROUP_PRODUCT,
1801 CPL_FRAME_TYPE_TABLE,
1802 CPL_FRAME_LEVEL_FINAL,
1805 raw_header[raw_index],
1815 "Could not add sky spectrum '%s' (%s) "
1817 product_filename, product_tag);
1819 uves_msg(
"Order trace table '%s' (%s) "
1820 "added to frameset",
1821 product_filename, product_tag);
1826 if (cosmic_mask != NULL)
1829 uves_free_propertylist(&cosmic_mask_header);
1832 cpl_free(product_filename);
1833 check( product_filename =
1834 uves_scired_crmask_filename(chip),
1835 "Error getting filename");
1837 cpl_free(product_tag);
1839 uves_sprintf(
"CRMASK_%s",
1843 sprintf(extname,
"CRH_MASK");
1846 check( uves_frameset_insert(frames,
1848 CPL_FRAME_GROUP_PRODUCT,
1849 CPL_FRAME_TYPE_TABLE,
1850 CPL_FRAME_LEVEL_FINAL,
1853 raw_header[raw_index],
1863 "Could not add cosmic ray table "
1864 "'%s' (%s) to frameset",
1865 product_filename, product_tag);
1867 uves_msg(
"Cosmic ray table '%s' (%s) "
1868 "added to frameset",
1869 product_filename, product_tag);
1879 if (wave_map != NULL)
1882 uves_free_propertylist(&wave_map_header);
1885 cpl_free(product_filename);
1886 check( product_filename =
1887 uves_scired_wmap_filename(chip),
1888 "Error getting filename");
1890 cpl_free(product_tag);
1892 uves_sprintf(
"WAVE_MAP_%s",
1896 check( uves_frameset_insert(frames,
1898 CPL_FRAME_GROUP_PRODUCT,
1899 CPL_FRAME_TYPE_IMAGE,
1900 CPL_FRAME_LEVEL_FINAL,
1903 raw_header[raw_index],
1913 "Could not add wave map "
1914 "'%s' (%s) to frameset",
1915 product_filename, product_tag);
1918 "added to frameset",
1919 product_filename, product_tag);
1923 uves_free_image(&wave_map);
1926 if (merged_sky != NULL)
1932 cpl_free(product_filename);
1933 check( product_filename =
1934 uves_scired_merged_sky_filename(chip),
1935 "Error getting filename");
1937 cpl_free(product_tag);
1939 uves_sprintf(
"MERGED_SKY_%s",
1945 check( uves_frameset_insert(
1948 CPL_FRAME_GROUP_PRODUCT,
1949 CPL_FRAME_TYPE_IMAGE,
1950 CPL_FRAME_LEVEL_FINAL,
1953 raw_header[raw_index],
1962 CPL_STATS_MIN | CPL_STATS_MAX),
1963 "Could not add sky spectrum "
1964 "'%s' (%s) to frameset",
1965 product_filename, product_tag);
1967 uves_msg(
"Sky spectrum '%s' (%s) added to frameset",
1968 product_filename, product_tag);
1977 if (fluxcal_science != NULL)
1981 cpl_free(product_filename);
1983 check( product_filename =
1985 uves_scired_fluxcal_science_2d_filename(chip) :
1986 ((m_method == MERGE_NOAPPEND) ?
1987 uves_scired_fluxcal_science_noappend_filename(chip): uves_scired_fluxcal_science_filename(chip)),
1988 "Error getting filename");
1991 cpl_free(product_tag);
1995 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1996 product_tag = uves_sprintf(
"FLUXCAL%s%s_%s_%s",
1997 (extract_is_2d) ?
"_2D" :
"",catg_is_noappend,
2005 check( uves_frameset_insert(frames,
2007 CPL_FRAME_GROUP_PRODUCT,
2008 CPL_FRAME_TYPE_IMAGE,
2009 CPL_FRAME_LEVEL_FINAL,
2012 raw_header[raw_index],
2021 CPL_STATS_MIN | CPL_STATS_MAX),
2022 "Could not add flux-calibrated science "
2023 "spectrum '%s' (%s) to frameset",
2024 product_filename, product_tag);
2026 uves_msg(
"Flux-calibrated science spectrum "
2027 "'%s' (%s) added to frameset",
2028 product_filename, product_tag);
2032 "10^-16 erg/cm^2/Angstrom/s"),
2033 "Error writing error spectrum header");
2035 cpl_free(product_filename);
2037 check( product_filename =
2039 uves_scired_fluxcal_error_2d_filename(chip) :
2040 ((m_method == MERGE_NOAPPEND) ?
2041 uves_scired_fluxcal_error_noappend_filename(chip): uves_scired_fluxcal_error_filename(chip)),
2042 "Error getting filename");
2045 cpl_free(product_tag);
2048 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
2049 product_tag = uves_sprintf(
"FLUXCAL_ERRORBAR%s%s_%s_%s",
2050 (extract_is_2d) ?
"_2D" :
"",catg_is_noappend,
2055 check( uves_frameset_insert(frames,
2057 CPL_FRAME_GROUP_PRODUCT,
2058 CPL_FRAME_TYPE_IMAGE,
2059 CPL_FRAME_LEVEL_FINAL,
2062 raw_header[raw_index],
2071 CPL_STATS_MIN | CPL_STATS_MAX),
2072 "Could not add flux-calibrated science "
2073 "spectrum error '%s' (%s) to frameset",
2074 product_filename, product_tag);
2076 uves_msg(
"Flux-calibrated science spectrum error "
2077 "'%s' (%s) added to frameset",
2078 product_filename, product_tag);
2085 uves_msg(
"Skipping trace number %d", trace_number);
2092 if(strcmp(PROCESS_CHIP,
"REDL") == 0) {
2095 uves_free_propertylist(&table_header);
2101 uves_free_table(&info_tbl);
2102 uves_free_image(&raw_image[0]);
2103 uves_free_image(&raw_image[1]);
2104 uves_free_propertylist(&raw_header[0]);
2105 uves_free_propertylist(&raw_header[1]);
2106 uves_free_propertylist(&rotated_header[0]);
2107 uves_free_propertylist(&rotated_header[1]);
2108 uves_free_propertylist(&wave_map_header);
2109 uves_free_propertylist(&wave_acc_header);
2112 uves_free_image(&master_bias);
2113 uves_free_propertylist(&master_bias_header);
2115 uves_free_image(&master_dark);
2116 uves_free_propertylist(&master_dark_header);
2118 uves_free_image(&master_flat);
2119 uves_free_propertylist(&master_flat_header);
2121 uves_free_table(&ordertable);
2122 uves_free_propertylist(&ordertable_header);
2124 uves_free_table(&traces);
2126 uves_free_table_const( &(linetable[0]) );
2127 uves_free_table_const( &(linetable[1]) );
2128 uves_free_table_const( &(linetable[2]) );
2129 uves_free_propertylist_const( &(linetable_header[0]) );
2130 uves_free_propertylist_const( &(linetable_header[1]) );
2131 uves_free_propertylist_const( &(linetable_header[2]) );
2136 uves_free_image(&response_curve);
2137 uves_free_propertylist(&response_curve_header);
2138 uves_free_table(&master_response);
2140 uves_free_table(&atm_extinction);
2145 uves_free_image(&background);
2146 uves_free_image(&flatfielded_variance);
2147 uves_free_propertylist(&flatfielded_variance_header);
2148 uves_free_image(&rebinned_science);
2149 uves_free_image(&rebinned_science_error);
2150 uves_free_propertylist(&rebinned_header);
2151 uves_free_image(&resampled_science);
2152 uves_free_image(&resampled_mf);
2153 uves_free_image(&merged_sky);
2155 uves_free_image(&merged_science);
2156 uves_free_propertylist(&merged_header);
2157 uves_free_image(&reduced_science);
2158 uves_free_image(&reduced_science_error);
2159 uves_free_image(&fluxcal_science);
2160 uves_free_image(&fluxcal_error);
2161 uves_free_propertylist(&fluxcal_header);
2162 uves_free_table(&cosmic_mask);
2163 uves_free_propertylist(&cosmic_mask_header);
2165 uves_free_table(&order_trace);
2166 uves_free_propertylist(&order_trace_header);
2168 uves_free_image(&x2d);
2169 uves_free_image(&fx2d);
2170 uves_free_propertylist(&x2d_header);
2172 cpl_free(raw_frames);
2173 cpl_free(product_filename);
2175 cpl_free(product_tag);
2193 const cpl_image *raw_image,
2202 "Science-Reduction-Test-Results",
2231 cpl_image *window = NULL;
2248 "Instrument mode used.",
2254 "Optical path used.",
2260 "Slit common name.",
2264 "Error reading exposure time");
2266 nx = cpl_image_get_size_x(ima);
2267 ny = cpl_image_get_size_y(ima);
2269 for (i = 1; i <= ny; i++)
2273 int xlo = uves_max_int(1 , (nx+1)/2 - size);
2274 int xhi = uves_min_int(nx, (nx+1)/2 + size);
2276 double min, max, avg, rms, med;
2278 uves_free_image(&window);
2279 window = cpl_image_extract(ima, xlo, i, xhi, i);
2282 if (cpl_image_count_rejected(window) >= cpl_image_get_size_x(window) - 2)
2284 min = max = avg = rms = med = 0;
2288 min = cpl_image_get_min (window) / exptime;
2289 max = cpl_image_get_max (window) / exptime;
2290 avg = cpl_image_get_mean (window) / exptime;
2291 rms = cpl_image_get_stdev (window) / exptime;
2292 med = cpl_image_get_median(window) / exptime;
2295 sprintf(key_name,
"QC ORD%d DATAMIN", i);
2299 "extracted order datamin",
2302 sprintf(key_name,
"QC ORD%d DATAMAX", i);
2306 "extracted order datamax",
2309 sprintf(key_name,
"QC ORD%d DATAAVG", i);
2313 "extracted order datamean",
2316 sprintf(key_name,
"QC ORD%d DATARMS", i);
2320 "extracted order datarms",
2323 sprintf(key_name,
"QC ORD%d DATAMED", i);
2327 "extracted order datamed",
2332 uves_free_image(&window);
void uves_reduce_scired(cpl_frameset *frames, const cpl_parameterlist *parameters, const char *recipe_id, const char *starttime)
Get the command line options and execute the data reduction.
static void scired_qclog(const cpl_table *info_tbl, const uves_propertylist *raw_header, const cpl_image *raw_image, double slit, cpl_table *qclog)
compute science QC
void uves_polynomial_delete(polynomial **p)
Delete a polynomial.
#define uves_msg_warning(...)
Print an warning message.
cpl_error_code uves_pfits_set_ctype1(uves_propertylist *plist, const char *ctype1)
Write the ctype1 keyword.
double uves_propertylist_get_double(const uves_propertylist *self, const char *name)
Get the double value of the given property list entry.
int uves_qclog_add_string(cpl_table *table, const char *key_name, const char *value, const char *key_help, const char *format)
Add string key to QC-LOG table.
static void tflat_qclog(const cpl_image *ima, const uves_propertylist *raw_header, cpl_table *qclog)
compute tflat QC
int uves_scired_define_parameters_body(cpl_parameterlist *parameters, const char *recipe_id)
Setup the recipe options.
int uves_qclog_delete(cpl_table **table)
delete QC-LOG table
cpl_error_code uves_propertylist_append_c_int(uves_propertylist *self, const char *name, int value, const char *comment)
Append an integer value to a property list.
int uves_qclog_add_double(cpl_table *table, const char *key_name, const double value, const char *key_help, const char *format)
Add double key to QC-LOG table.
const char * uves_pfits_get_slit1_name(const uves_propertylist *plist)
Get image slicer name.
uves_propertylist * uves_initialize_image_header(const char *ctype1, const char *ctype2, const char *cunit1, const char *cunit2, const char *bunit, const double bscale, double crval1, double crval2, double crpix1, double crpix2, double cdelt1, double cdelt2)
Initialize image header.
uves_propertylist * uves_propertylist_new(void)
Create an empty property list.
int uves_pfits_get_binx(const uves_propertylist *plist)
Find out the x binning factor.
double uves_spline_hermite_table(double xp, const cpl_table *t, const char *column_x, const char *column_y, int *istart)
Spline interpolation based on Hermite polynomials.
#define uves_msg(...)
Print a message on 'info' or 'debug' level.
uves_propertylist * uves_propertylist_load(const char *name, int position)
Create a property list from a file.
cpl_error_code uves_pfits_set_ctype2(uves_propertylist *plist, const char *ctype2)
Write the ctype2 keyword.
int uves_pfits_get_biny(const uves_propertylist *plist)
Find out the y binning factor.
void uves_qclog_add_sci(cpl_table *qclog, const uves_propertylist *raw_header, const cpl_image *raw_image, double slit, const cpl_table *info_tbl)
Write QC parameters related to science reduction.
static cpl_error_code uves_scired_process_chip(const cpl_image *raw_image, const uves_propertylist *raw_header, const uves_propertylist *rotated_header, const cpl_image *master_bias, const uves_propertylist *mbias_header, const cpl_image *master_dark, const uves_propertylist *mdark_header, const cpl_image *master_flat, const uves_propertylist *mflat_header, const cpl_table *ordertable, const polynomial *order_locations, const cpl_table *linetable[3], const uves_propertylist *linetable_header[3], const polynomial *dispersion_relation[3], const cpl_image *response_curve, const cpl_table *master_response, const uves_propertylist *response_curve_header, const cpl_table *atm_extinction, enum uves_chip chip, bool debug_mode, const cpl_parameterlist *parameters, const char *recipe_id, cpl_image **x2d, uves_propertylist **x2d_header, cpl_image **fx2d, cpl_image **background, cpl_image **flatfielded_variance, uves_propertylist **flatfielded_variance_header, cpl_image **resampled_science, cpl_image **resampled_mf, cpl_image **rebinned_science, cpl_image **rebinned_noise, uves_propertylist **rebinned_header, cpl_image **merged_sky, cpl_image **merged_science, uves_propertylist **merged_header, cpl_image **reduced_science, cpl_image **reduced_science_error, cpl_table **cosmic_mask, cpl_image **wave_map, cpl_image **fluxcal_science, cpl_image **fluxcal_error, uves_propertylist **fluxcal_header, cpl_table **info_tbl, double *extraction_slit, cpl_table **order_trace)
Reduce one chip of a UVES science frame.
bool uves_ccd_is_new(const uves_propertylist *plist)
Find out if CCD header is new.
const char * uves_remove_string_prefix(const char *s, const char *prefix)
Remove named prefix from string.
void uves_polynomial_delete_const(const polynomial **p)
Delete a const polynomial.
double uves_pfits_get_exptime(const uves_propertylist *plist)
Find out the exposure time in seconds.
cpl_error_code uves_propertylist_append_c_string(uves_propertylist *self, const char *name, const char *value, const char *comment)
Append a string value to a property list.
const char * uves_pfits_get_insmode(const uves_propertylist *plist)
find out the chip name value
const char * uves_pfits_get_inspath(const uves_propertylist *plist)
find out the chip name value
cpl_image * uves_normalize_spectrum(const cpl_image *spectrum, const cpl_image *spectrum_error, const uves_propertylist *spectrum_header, const uves_propertylist *raw_header, int n_traces, enum uves_chip chip, const cpl_table *atm_extinction, bool correct_binning, cpl_image **scaled_error)
Normalize a spectrum.
int uves_chip_get_index(enum uves_chip chip)
Convert to integer.
enum uves_chip uves_chip_get_first(bool blue)
Get first chip for blue or red arm.
merge_method uves_get_merge_method(const cpl_parameterlist *parameters, const char *context, const char *subcontext)
Read merging method from parameter list.
cpl_error_code uves_pfits_set_extname(uves_propertylist *plist, const char *extname)
Write the EXTNAME keyword.
int uves_propertylist_get_int(const uves_propertylist *self, const char *name)
Get the integer value of the given property list entry.
#define uves_msg_low(...)
Print a message on a lower message level.
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_chip_tostring_upper(enum uves_chip chip)
Convert to string.
double uves_pfits_get_cdelt1(const uves_propertylist *plist)
Find out the cdelt1.
static cpl_frame ** set_all_raw_none(cpl_frameset *frames)
Change tag of RAW frames to NONE.
int uves_correct_badpix_all(cpl_image *master_bias, uves_propertylist *mbias_header, enum uves_chip chip, int binx, int biny, int mark_bad, bool red_ccd_new)
Correct all bad pixels on a chip.
double uves_pfits_get_crval1(const uves_propertylist *plist)
Find out the crval1.
cpl_error_code uves_pfits_set_bunit(uves_propertylist *plist, const char *bunit)
Write the bunit keyword.
const char * uves_string_toupper(char *s)
Convert all lowercase characters in a string into uppercase characters.
cpl_error_code uves_propertylist_append_c_double(uves_propertylist *self, const char *name, double value, const char *comment)
Append a double value to a property list.
cpl_table * uves_qclog_init(const uves_propertylist *raw_header, enum uves_chip chip)
Init QC-LOG table.
cpl_error_code uves_propertylist_update_int(uves_propertylist *self, const char *name, int value)
Update a property list with a integer value.
const char * uves_pfits_get_chipid(const uves_propertylist *plist, enum uves_chip chip)
Find out the chip ID.
int uves_propertylist_has(const uves_propertylist *self, const char *name)
Check whether a property is present in a property list.
cpl_error_code uves_reduce(const cpl_image *raw_image, const uves_propertylist *raw_header, const uves_propertylist *rotated_header, const cpl_image *master_bias, const uves_propertylist *mbias_header, const cpl_image *master_dark, const uves_propertylist *mdark_header, const cpl_image *master_flat, const uves_propertylist *mflat_header, const cpl_table *ordertable, const polynomial *order_locations, const cpl_table *linetable[3], const uves_propertylist *linetable_header[3], const polynomial *dispersion_relation[3], enum uves_chip chip, bool debug_mode, const cpl_parameterlist *parameters, const char *rec_id, const char *mode, cpl_image **x, uves_propertylist **x_header, cpl_image **fx, cpl_table **cosmic_mask, cpl_image **wave_map, cpl_image **background, cpl_image **flatfielded_variance, uves_propertylist **flatfielded_variance_header, cpl_image **resampled_spectrum, cpl_image **resampled_mf, cpl_image **merged_sky, cpl_image **rebinned_spectrum, cpl_image **rebinned_noise, uves_propertylist **rebinned_header, cpl_image **merged_spectrum, cpl_image **merged_noise, uves_propertylist **merged_header, cpl_image **reduced_rebinned_spectrum, cpl_image **reduced_rebinned_noise, cpl_image **reduced_spectrum, cpl_image **reduced_noise, cpl_table **info_tbl, double *extraction_slit, cpl_table **order_trace)
Reduce a science frame.
cpl_error_code uves_propertylist_append(uves_propertylist *self, const uves_propertylist *other)
Append a property list..