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;
280 result = cpl_calloc( cpl_frameset_get_size(frames) + 1,
283 for (f = cpl_frameset_get_first(frames), i = 0;
285 f = cpl_frameset_get_next(frames))
287 if (cpl_frame_get_group(f) == CPL_FRAME_GROUP_RAW)
290 cpl_frame_set_group(f, CPL_FRAME_GROUP_NONE);
373 static cpl_error_code
377 const cpl_image *master_bias,
379 const cpl_image *master_dark,
381 const cpl_image *master_flat,
383 const cpl_table *ordertable,
385 const cpl_table *linetable[3],
388 const cpl_image *response_curve,
389 const cpl_table *master_response,
391 const cpl_table *atm_extinction,
399 const cpl_parameterlist *parameters,
400 const char *recipe_id,
404 cpl_image **background,
405 cpl_image **flatfielded_variance,
407 cpl_image **resampled_science,
408 cpl_image **resampled_mf,
409 cpl_image **rebinned_science,
410 cpl_image **rebinned_noise,
412 cpl_image **merged_sky,
413 cpl_image **merged_science,
415 cpl_image **reduced_science,
416 cpl_image **reduced_science_error,
417 cpl_table **cosmic_mask,
418 cpl_image **wave_map,
419 cpl_image **fluxcal_science,
420 cpl_image **fluxcal_error,
422 cpl_table **info_tbl,
423 double *extraction_slit,
424 cpl_table **order_trace)
427 cpl_image *merged_noise = NULL;
429 cpl_image *reduced_rebinned = NULL;
430 cpl_image *reduced_rebinned_noise = NULL;
432 cpl_table *response_table = NULL;
435 uves_msg(
"Reducing science object");
463 flatfielded_variance,
464 flatfielded_variance_header,
475 &reduced_rebinned_noise,
477 reduced_science_error,
481 "Could not reduce frame");
484 check( uves_plot_image_rows(*reduced_science,
485 1 + cpl_image_get_size_y(*reduced_science)/2,
486 1 + cpl_image_get_size_y(*reduced_science)/2, 1,
487 "Wavelength (arbitrary units)",
"Relative flux",
488 "Reduced science spectrum"),
497 if (response_curve != NULL || master_response != NULL)
504 int n_traces = cpl_image_get_size_y(*reduced_science);
506 uves_msg(
"Flux calibrating spectrum");
517 if (response_curve != NULL) {
518 response_table = cpl_table_new(cpl_image_get_size_x(response_curve));
519 cpl_table_new_column(response_table,
"LAMBDA", CPL_TYPE_DOUBLE);
520 cpl_table_new_column(response_table,
"FLUX_CONV", CPL_TYPE_DOUBLE);
523 "Error reading response curve start wavelength from header");
526 "Error reading bin width from header");
528 for (bin = 1; bin <= cpl_image_get_size_x(response_curve); bin++) {
533 lambda = lambda_start + (bin-1) * dlambda;
535 check( response = cpl_image_get(response_curve, bin, 1, &pis_rejected),
536 "Error reading response curve bin = %d", bin);
538 check((cpl_table_set_double(response_table,
"LAMBDA", bin - 1, lambda),
539 cpl_table_set_double(response_table,
"FLUX_CONV", bin - 1, response)),
540 "Error updating response table at row %d", bin - 1);
544 response_table = cpl_table_duplicate( master_response );
552 *reduced_science_error,
560 "Error normalizing reduced spectrum");
566 uves_msg(
"Multiplying by response function");
568 int nbins = cpl_image_get_size_x(*fluxcal_science);
569 int ntraces = cpl_image_get_size_y(*fluxcal_science);
570 double *fluxcal_science_data = cpl_image_get_data_double(*fluxcal_science);
571 double *fluxcal_science_noise = cpl_image_get_data_double(*fluxcal_error);
574 "Error reading start wavelength from reduced science header");
577 "Error reading bin width from header");
579 for (bin = 1; bin <= nbins; bin++)
586 lambda = lambda_start + (bin-1) * dlambda;
590 "LAMBDA",
"FLUX_CONV", &istart),
591 "Error interpolating response curve at lambda = %f wlu", lambda);
593 for (trace = 1; trace <= ntraces; trace++)
599 fluxcal_science_data [(bin-1) + (trace-1)*nbins] *= response;
600 fluxcal_science_noise[(bin-1) + (trace-1)*nbins] *= response;
609 check( uves_plot_image_rows(*fluxcal_science,
610 1 + cpl_image_get_size_y(*fluxcal_science)/2,
611 1 + cpl_image_get_size_y(*fluxcal_science)/2, 1,
612 "Wavelength (arbitrary units)",
613 "Flux (10^-16 erg/cm^2/Angstrom/s)",
614 "Flux calibrated science spectrum"),
619 "10^-16 erg/cm^2/Angstrom/s",
624 "Error initializing flux calibrated spectrum header");
629 uves_msg(
"Skipping absolute flux calibration");
633 uves_free_image(&merged_noise);
634 uves_free_image(&reduced_rebinned_noise);
635 uves_free_image(&reduced_rebinned);
636 uves_free_table(&response_table);
638 if (cpl_error_get_code() != CPL_ERROR_NONE)
642 return cpl_error_get_code();
657 const char *recipe_id,
const char *starttime)
662 bool extract_is_2d =
false;
665 cpl_image *raw_image[2] = {NULL, NULL};
670 cpl_image *master_bias = NULL;
673 cpl_image *master_flat = NULL;
676 cpl_image *master_dark = NULL;
679 cpl_table *ordertable = NULL;
682 cpl_table *traces = NULL;
685 const cpl_table *linetable[3] = {NULL, NULL, NULL};
687 const polynomial *dispersion_relation[3] = {NULL, NULL, NULL};
689 cpl_image *response_curve = NULL;
691 cpl_table *master_response = NULL;
693 cpl_table *atm_extinction = NULL;
697 cpl_image *background = NULL;
700 cpl_image *flatfielded_variance = NULL;
704 cpl_image *resampled_science = NULL;
706 cpl_image *resampled_mf = NULL;
708 cpl_image *rebinned_science = NULL;
709 cpl_image *rebinned_science_error = NULL;
713 cpl_image *merged_sky = NULL;
718 cpl_image *merged_science = NULL;
720 cpl_image *reduced_science = NULL;
721 cpl_image *reduced_science_error = NULL;
725 cpl_image *fluxcal_science = NULL;
726 cpl_image *fluxcal_error = NULL;
730 cpl_table *order_trace = NULL;
735 cpl_image *x2d = NULL;
738 cpl_image *fx2d = NULL;
741 cpl_table *cosmic_mask = NULL;
745 cpl_table* qclog[2] = {NULL, NULL};
746 cpl_table *qclog_tflat = NULL;
749 const char *raw_filename =
"";
750 const char *atm_ext_filename =
"";
751 const char *sci_type =
"";
752 cpl_frame **raw_frames = NULL;
753 char *product_tag = NULL;
754 char *product_filename = NULL;
755 char *context = NULL;
756 double extraction_slit;
763 cpl_table* info_tbl = NULL;
764 const char* PROCESS_CHIP=NULL;
765 bool red_ccd_is_new=0;
766 merge_method m_method;
767 const char* catg_is_noappend=NULL;
768 cpl_image* wave_map=NULL;
776 const char *ex_method =
"";
779 check( uves_get_parameter(parameters, NULL,
"uves",
"debug", CPL_TYPE_BOOL, &debug_mode),
780 "Could not read parameter");
784 check( uves_get_parameter(parameters, NULL,
"uves",
"debug", CPL_TYPE_BOOL, &debug_mode),
785 "Could not read parameter");
789 check( uves_get_parameter(parameters, NULL,
"uves",
"process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
790 "Could not read parameter");
794 check( uves_get_parameter(parameters,NULL,recipe_id,
"clean_traps", CPL_TYPE_BOOL, &CLEAN_TRAPS),
795 "Could not read parameter");
800 context = uves_sprintf(
"%s.%s.%s", recipe_id, UVES_REDUCE_ID, UVES_EXTRACT_ID);
802 check( uves_get_parameter(parameters, NULL,
804 CPL_TYPE_STRING, &ex_method),
805 "Could not read parameter");
807 extract_is_2d = (strcmp(ex_method,
"2d") == 0);
810 check( uves_load_science(frames, &raw_filename, raw_image, raw_header, rotated_header,
812 "Error loading raw frame");
814 if ((strcmp(sci_type,
"SCI_SLICER") == 0 ||
815 strcmp(sci_type,
"SCI_EXTND" ) == 0) &&
816 strcmp(ex_method,
"optimal") == 0)
819 "This may not work because the sky cannot be "
820 "reliably determined",
826 if (cpl_frameset_find(frames, UVES_EXTCOEFF_TABLE) != NULL)
828 check( uves_load_atmo_ext(frames, &atm_ext_filename, &atm_extinction),
829 "Error loading atm. extinction coefficients");
831 uves_msg_low(
"Using atmospheric extinction table in '%s'", atm_ext_filename);
835 uves_msg_low(
"No atmospheric extinction table. Flux calibration not done");
839 "Could not get merging method");
845 "Could not read x binning factor from input header");
847 "Could not read y binning factor from input header");
853 chip != UVES_CHIP_INVALID;
859 if(strcmp(PROCESS_CHIP,
"REDU") == 0) {
863 cpl_frame *mflat_frame = NULL;
864 const char *ordertable_filename =
"";
865 const char *linetable_filename =
"";
866 const char *master_bias_filename =
"";
867 const char *master_dark_filename =
"";
868 const char *master_flat_filename =
"";
869 const char *response_curve_filename =
"";
870 const char *chip_name =
"";
876 uves_msg(
"Processing %s chip in '%s'",
885 uves_free_image(&master_bias);
886 uves_free_propertylist(&master_bias_header);
887 if (cpl_frameset_find(frames, UVES_MASTER_BIAS(chip)) != NULL)
889 uves_free_image(&master_bias);
890 uves_free_propertylist(&master_bias_header);
892 check( uves_load_mbias(frames, chip_name, &master_bias_filename,
893 &master_bias, &master_bias_header,
895 "Error loading master bias");
897 uves_msg_low(
"Using master bias in '%s'", master_bias_filename);
901 uves_msg_low(
"No master bias in SOF. Bias subtraction not done");
905 uves_free_image(&master_dark);
906 uves_free_propertylist(&master_dark_header);
907 if (cpl_frameset_find(frames, UVES_MASTER_DARK(chip)) != NULL ||
908 cpl_frameset_find(frames, UVES_MASTER_PDARK(chip)) != NULL)
911 check( uves_load_mdark(frames, chip_name, &master_dark_filename,
912 &master_dark, &master_dark_header, chip),
913 "Error loading master dark");
915 uves_msg_low(
"Using master dark in '%s'", master_dark_filename);
919 uves_msg_low(
"No master dark in SOF. Dark subtraction not done");
923 uves_free_image(&master_flat);
924 uves_free_propertylist(&master_flat_header);
925 check( uves_load_mflat(frames, chip_name, &master_flat_filename, &master_flat,
926 &master_flat_header, chip, &mflat_frame),
927 "Error loading master flat");
929 uves_msg_low(
"Using master flat in '%s'", master_flat_filename);
933 uves_free_table (&ordertable);
934 uves_free_propertylist(&ordertable_header);
936 uves_free_table (&traces);
938 check( uves_load_ordertable(frames,
941 &ordertable_filename,
950 "Could not load order table");
951 uves_msg_low(
"Using order table in '%s'", ordertable_filename);
955 if (atm_extinction != NULL)
957 if (cpl_frameset_find(frames, UVES_INSTR_RESPONSE(chip)) != NULL ||
958 cpl_frameset_find(frames, UVES_MASTER_RESPONSE(chip)) != NULL)
960 uves_free_image(&response_curve);
961 uves_free_table(&master_response);
962 uves_free_propertylist(&response_curve_header);
963 check( uves_load_response_curve(frames, chip_name,
964 &response_curve_filename,
967 &response_curve_header,
969 "Error loading response curve");
972 master_response != NULL ?
"master " :
"",
973 response_curve_filename);
978 "Flux calibration not done");
984 "Do not look for response curve");
988 for(tracerow = 0; tracerow < cpl_table_get_nrow(traces); tracerow++)
993 int badpixels_cleaned;
994 trace_offset = cpl_table_get_double(traces,
"Offset" , tracerow, NULL);
995 trace_number = cpl_table_get_int (traces,
"TraceID" , tracerow, NULL);
996 trace_enabled = cpl_table_get_int (traces,
"Tracemask" , tracerow, NULL);
998 if (trace_enabled != 0)
1002 if (cpl_table_get_nrow(traces) > 1) {
1003 uves_msg(
"Processing trace %d", trace_number);
1010 for (window = 1; window <= 3; window ++) {
1011 uves_free_table_const ( &(linetable[window-1]) );
1012 uves_free_propertylist_const( &(linetable_header[window-1]) );
1014 check( uves_load_linetable_const(frames,
1018 cpl_table_get_column_min(
1019 ordertable,
"Order"),
1020 cpl_table_get_column_max(
1021 ordertable,
"Order"),
1022 &linetable_filename,
1023 &(linetable [window-1]),
1024 &(linetable_header [window-1]),
1025 &(dispersion_relation[window-1]),
1030 "Could not load line table, window #%d", window);
1032 uves_msg_low(
"Using line table(s) in '%s'", linetable_filename);
1036 uves_free_propertylist(&wave_acc_header);
1037 wave_acc_header=uves_paste_wave_accuracy(plist);
1038 uves_free_propertylist(&plist);
1042 uves_free_image(&x2d);
1043 uves_free_image(&fx2d);
1044 uves_free_propertylist(&x2d_header);
1045 uves_free_image(&background);
1046 uves_free_image(&flatfielded_variance);
1047 uves_free_propertylist(&flatfielded_variance_header);
1048 uves_free_image(&resampled_science);
1049 uves_free_image(&resampled_mf);
1050 uves_free_image(&rebinned_science);
1051 uves_free_image(&rebinned_science_error);
1052 uves_free_propertylist(&rebinned_header);
1053 uves_free_image(&merged_sky);
1054 uves_free_image(&merged_science);
1055 uves_free_propertylist(&merged_header);
1056 uves_free_image(&reduced_science);
1057 uves_free_image(&reduced_science_error);
1058 uves_free_table(&cosmic_mask);
1059 uves_free_image(&fluxcal_science);
1060 uves_free_image(&fluxcal_error);
1061 uves_free_propertylist(&fluxcal_header);
1062 uves_free_table(&info_tbl);
1063 uves_free_table(&order_trace);
1067 check( badpixels_cleaned =
1069 raw_header[raw_index],
1071 false,red_ccd_is_new),
1072 "Error replacing bad pixels");
1079 raw_image[raw_index],
1080 raw_header[raw_index],
1081 rotated_header[raw_index],
1092 dispersion_relation,
1095 response_curve_header,
1105 &flatfielded_variance,
1106 &flatfielded_variance_header,
1110 &rebinned_science_error,
1116 &reduced_science_error,
1125 "Science reduction failed");
1133 raw_header[raw_index],
1134 raw_image[raw_index],
1137 "Could not compute QC parameters");
1149 cpl_free(product_filename);
1150 check( product_filename =
1152 uves_scired_red_2d_science_filename(chip) :
1153 ((m_method == MERGE_NOAPPEND) ?
1154 uves_scired_red_noappend_science_filename(chip): uves_scired_red_science_filename(chip)),
1155 "Error getting filename");
1157 cpl_free(product_tag);
1158 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1159 product_tag = uves_sprintf(
1162 (extract_is_2d) ?
"_2D" :
"",
1167 check( uves_frameset_insert(frames,
1169 CPL_FRAME_GROUP_PRODUCT,
1170 CPL_FRAME_TYPE_IMAGE,
1171 CPL_FRAME_LEVEL_FINAL,
1174 raw_header[raw_index],
1179 PACKAGE
"/" PACKAGE_VERSION,
1184 "Could not add reduced science spectrum '%s' (%s) to frameset",
1185 product_filename, product_tag);
1187 uves_msg(
"Reduced science spectrum '%s' (%s) added to frameset",
1188 product_filename, product_tag);
1193 cpl_free(product_filename);
1194 check( product_filename = uves_scired_ext2d_filename(chip),
1195 "Error getting filename");
1197 cpl_free(product_tag);
1199 uves_sprintf(
"EXT_2D_%s_%s", sci_type,
1204 check( uves_frameset_insert(frames,
1206 CPL_FRAME_GROUP_PRODUCT,
1207 CPL_FRAME_TYPE_IMAGE,
1208 CPL_FRAME_LEVEL_FINAL,
1211 raw_header[raw_index],
1216 PACKAGE
"/" PACKAGE_VERSION,
1220 "Could not add 2d extracted "
1221 "spectrum '%s' (%s) to frameset",
1222 product_filename, product_tag);
1224 uves_msg(
"2d extracted spectrum '%s' (%s) added to frameset",
1225 product_filename, product_tag);
1231 cpl_free(product_filename);
1232 check( product_filename = (extract_is_2d) ?
1233 uves_scired_merged_2d_science_filename(chip) :
1234 uves_scired_merged_science_filename(chip),
1235 "Error getting filename");
1236 cpl_free(product_tag);
1237 product_tag = uves_sprintf(
1239 (extract_is_2d) ?
"MER_2D" :
"MERGED",
1244 check( uves_frameset_insert(frames,
1246 CPL_FRAME_GROUP_PRODUCT,
1247 CPL_FRAME_TYPE_IMAGE,
1248 CPL_FRAME_LEVEL_FINAL,
1251 raw_header[raw_index],
1256 PACKAGE
"/" PACKAGE_VERSION,
1260 "Could not add merged science spectrum '%s' (%s) to frameset",
1261 product_filename, product_tag);
1263 uves_msg(
"Merged science spectrum '%s' (%s) added to frameset",
1264 product_filename, product_tag);
1271 cpl_free(product_filename);
1272 check( product_filename = (extract_is_2d) ?
1273 uves_scired_resampled_2d_filename(chip) :
1274 uves_scired_resampled_filename(chip),
1275 "Error getting filename");
1277 cpl_free(product_tag);
1279 uves_sprintf(
"WCALIB_%s_%s", sci_type,
1284 check( uves_frameset_insert(frames,
1286 CPL_FRAME_GROUP_PRODUCT,
1287 CPL_FRAME_TYPE_IMAGE,
1288 CPL_FRAME_LEVEL_FINAL,
1291 raw_header[raw_index],
1296 PACKAGE
"/" PACKAGE_VERSION,
1300 "Could not add wavelength calibrated science "
1301 "spectrum '%s' (%s) to frameset", product_filename,
1304 uves_msg(
"Wavelength calibrated science spectrum '%s' "
1305 "(%s) added to frameset", product_filename,
1309 cpl_free(product_filename);
1311 check( product_filename =
1312 uves_order_extract_qc_standard_filename(chip),
1313 "Error getting filename");
1317 sprintf(extname,
"QC_INFO");
1320 check( uves_frameset_insert(frames,
1322 CPL_FRAME_GROUP_PRODUCT,
1323 CPL_FRAME_TYPE_TABLE,
1324 CPL_FRAME_LEVEL_INTERMEDIATE,
1326 UVES_ORDER_EXTRACT_QC(chip),
1327 raw_header[raw_index],
1328 rotated_header[raw_index],
1332 PACKAGE
"/" PACKAGE_VERSION,
1336 "Could not add extraction quality table %s (%s)"
1338 UVES_ORDER_EXTRACT_QC(chip));
1340 uves_msg(
"Extraction quality table '%s' "
1341 "(%s) added to frameset", product_filename,
1342 UVES_ORDER_EXTRACT_QC(chip));
1349 const char *ff =
"";
1353 context = uves_sprintf(
"%s.%s", recipe_id, UVES_REDUCE_ID);
1354 check( uves_get_parameter(parameters, NULL,
1357 CPL_TYPE_STRING, &ff),
1358 "Could not read parameter");
1361 if (strcmp(ff,
"no") != 0)
1365 cpl_table *qc_tabs[] = {NULL, NULL, NULL};
1371 if ( strcmp(recipe_id, make_str(UVES_TFLAT_ID)) == 0 )
1378 raw_header[raw_index],
1380 "Could not compute QC parameters");
1382 qc_tabs[0] = qclog_tflat;
1383 qc_tabs[1] = qclog[0];
1387 qc_tabs[0] = qclog[0];
1391 cpl_free(product_filename);
1392 check( product_filename =
1394 uves_scired_rebinned_2d_filename(chip) :
1395 uves_scired_rebinned_filename(chip),
1396 "Error getting filename");
1398 cpl_free(product_tag);
1399 product_tag = uves_sprintf(
1401 (extract_is_2d) ?
"WCAL_2D" :
"WCALIB_FF",
1406 check( uves_frameset_insert(frames,
1408 CPL_FRAME_GROUP_PRODUCT,
1409 CPL_FRAME_TYPE_IMAGE,
1410 CPL_FRAME_LEVEL_FINAL,
1413 raw_header[raw_index],
1423 "Could not add wavelength calibrated flat-fielded "
1424 "science spectrum '%s' (%s) to frameset",
1425 product_filename, product_tag);
1427 uves_msg(
"Wavelength calibrated flat-fielded science "
1428 "spectrum '%s' (%s) added to frameset",
1429 product_filename, product_tag);
1431 cpl_free(product_filename);
1432 check( product_filename =
1434 uves_scired_rebinned_2d_error_filename(chip) :
1435 uves_scired_rebinned_error_filename(chip),
1436 "Error getting filename");
1438 cpl_free(product_tag);
1439 product_tag = uves_sprintf(
1441 (extract_is_2d) ?
"ERRORBAR_WCAL_2D" :
"ERRORBAR_WCALIB_FF",
1449 check( uves_frameset_insert(frames,
1450 rebinned_science_error,
1451 CPL_FRAME_GROUP_PRODUCT,
1452 CPL_FRAME_TYPE_IMAGE,
1453 CPL_FRAME_LEVEL_FINAL,
1456 raw_header[raw_index],
1466 "Could not add wavelength calibrated flat-fielded "
1467 "science spectrum '%s' (%s) to frameset",
1468 product_filename, product_tag);
1470 uves_msg(
"Wavelength calibrated flat-fielded science "
1471 "spectrum error '%s' (%s) added to frameset",
1472 product_filename, product_tag);
1480 cpl_free(product_filename);
1481 check( product_filename =
1482 uves_scired_resampledmf_filename(chip),
1483 "Error getting filename");
1485 cpl_free(product_tag);
1488 "WCALIB_FLAT_OBJ_%s",
1520 cpl_free(raw_frames);
1524 cpl_frame_set_group(mflat_frame,
1525 CPL_FRAME_GROUP_RAW);
1529 check( uves_frameset_insert(
1532 CPL_FRAME_GROUP_PRODUCT,
1533 CPL_FRAME_TYPE_IMAGE,
1534 CPL_FRAME_LEVEL_FINAL,
1546 CPL_STATS_MIN | CPL_STATS_MAX),
1547 "Could not add wavelength calibrated "
1548 "flat-field '%s' (%s) to frameset",
1549 product_filename, product_tag);
1551 uves_msg(
"Wavelength calibrated flat-field "
1552 "spectrum '%s' (%s) added to frameset",
1553 product_filename, product_tag);
1559 raw_frames[i] != NULL;
1562 cpl_frame_set_group(
1564 CPL_FRAME_GROUP_RAW);
1567 cpl_frame_set_group(mflat_frame,
1568 CPL_FRAME_GROUP_CALIB);
1574 cpl_free(product_filename);
1575 check( product_filename =
1576 uves_scired_ff2d_filename(chip),
1577 "Error getting filename");
1579 cpl_free(product_tag);
1582 "FF_2D_%s_%s", sci_type,
1586 check( uves_frameset_insert(
1589 CPL_FRAME_GROUP_PRODUCT,
1590 CPL_FRAME_TYPE_IMAGE,
1591 CPL_FRAME_LEVEL_FINAL,
1594 raw_header[raw_index],
1604 "Could not add 2d extracted, flat-fielded "
1605 "spectrum '%s' (%s) to frameset",
1606 product_filename, product_tag);
1608 uves_msg(
"2d extracted, flat-fielded spectrum "
1609 "'%s' (%s) added to frameset",
1610 product_filename, product_tag);
1617 "Error writing error spectrum header");
1621 cpl_free(product_filename);
1623 check( product_filename =
1625 uves_scired_red_2d_error_filename(chip) :
1626 ((m_method == MERGE_NOAPPEND) ?
1627 uves_scired_red_noappend_error_filename(chip): uves_scired_red_error_filename(chip)),
1628 "Error getting filename");
1631 cpl_free(product_tag);
1632 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1633 product_tag = uves_sprintf(
"%s%s_%s_%s",
1634 (extract_is_2d) ?
"ERR_2D" :
"ERRORBAR",catg_is_noappend,
1647 check( uves_frameset_insert(
1649 reduced_science_error,
1650 CPL_FRAME_GROUP_PRODUCT,
1651 CPL_FRAME_TYPE_IMAGE,
1652 CPL_FRAME_LEVEL_FINAL,
1655 raw_header[raw_index],
1660 PACKAGE
"/" PACKAGE_VERSION,
1663 CPL_STATS_MIN | CPL_STATS_MAX),
1664 "Could not add error bars '%s' (%s) to frameset",
1665 product_filename, product_tag);
1667 uves_msg(
"Science spectrum error '%s' (%s) "
1668 "added to frameset",
1669 product_filename, product_tag);
1678 cpl_free(product_filename);
1679 check( product_filename =
1680 uves_scired_ff_variance_filename(chip),
1681 "Error getting filename");
1683 cpl_free(product_tag);
1685 uves_sprintf(
"VARIANCE_%s_%s", sci_type,
1691 check( uves_frameset_insert(frames,
1692 flatfielded_variance,
1693 CPL_FRAME_GROUP_PRODUCT,
1694 CPL_FRAME_TYPE_IMAGE,
1695 CPL_FRAME_LEVEL_FINAL,
1698 raw_header[raw_index],
1699 flatfielded_variance_header,
1703 PACKAGE
"/" PACKAGE_VERSION,
1706 CPL_STATS_MIN | CPL_STATS_MAX),
1707 "Could not add flat-fielded spectrum variance "
1708 "'%s' (%s) to frameset",
1709 product_filename, product_tag);
1711 uves_msg(
"Flat-fielded spectrum variance '%s' (%s) "
1712 "added to frameset",
1713 product_filename, product_tag);
1721 cpl_free(product_filename);
1722 check( product_filename =
1723 uves_scired_background_filename(chip),
1724 "Error getting filename");
1726 cpl_free(product_tag);
1728 uves_sprintf(
"BKG_SCI_%s",
1732 check( uves_frameset_insert(frames,
1734 CPL_FRAME_GROUP_PRODUCT,
1735 CPL_FRAME_TYPE_IMAGE,
1736 CPL_FRAME_LEVEL_FINAL,
1739 raw_header[raw_index],
1740 rotated_header[raw_index],
1744 PACKAGE
"/" PACKAGE_VERSION,
1747 CPL_STATS_MIN | CPL_STATS_MAX),
1748 "Could not add background image '%s' (%s) "
1749 "to frameset", product_filename, product_tag);
1751 uves_msg(
"Background image '%s' (%s) added to frameset",
1752 product_filename, product_tag);
1756 if (order_trace != NULL)
1759 uves_free_propertylist(&order_trace_header);
1773 order_trace_header,
"ESO QC OPTEX NORD",
1775 cpl_table_get_column_max(ordertable,
"Order")-
1776 cpl_table_get_column_min(ordertable,
"Order")+1));
1779 order_trace_header,
"ESO QC OPTEX XSIZE",
1780 cpl_image_get_size_x(raw_image[raw_index]));
1783 order_trace_header,
"ESO QC OPTEX YSIZE",
1784 uves_round_double(extraction_slit));
1787 cpl_free(product_filename);
1788 check( product_filename =
1789 uves_scired_ordertrace_filename(chip),
1790 "Error getting filename");
1792 cpl_free(product_tag);
1794 uves_sprintf(
"ORDER_TRACE_%s",
1798 sprintf(extname,
"TRACE_INFO");
1800 check( uves_frameset_insert(frames,
1802 CPL_FRAME_GROUP_PRODUCT,
1803 CPL_FRAME_TYPE_TABLE,
1804 CPL_FRAME_LEVEL_FINAL,
1807 raw_header[raw_index],
1817 "Could not add sky spectrum '%s' (%s) "
1819 product_filename, product_tag);
1821 uves_msg(
"Order trace table '%s' (%s) "
1822 "added to frameset",
1823 product_filename, product_tag);
1828 if (cosmic_mask != NULL)
1831 uves_free_propertylist(&cosmic_mask_header);
1834 cpl_free(product_filename);
1835 check( product_filename =
1836 uves_scired_crmask_filename(chip),
1837 "Error getting filename");
1839 cpl_free(product_tag);
1841 uves_sprintf(
"CRMASK_%s",
1845 sprintf(extname,
"CRH_MASK");
1848 check( uves_frameset_insert(frames,
1850 CPL_FRAME_GROUP_PRODUCT,
1851 CPL_FRAME_TYPE_TABLE,
1852 CPL_FRAME_LEVEL_FINAL,
1855 raw_header[raw_index],
1865 "Could not add cosmic ray table "
1866 "'%s' (%s) to frameset",
1867 product_filename, product_tag);
1869 uves_msg(
"Cosmic ray table '%s' (%s) "
1870 "added to frameset",
1871 product_filename, product_tag);
1881 if (wave_map != NULL)
1884 uves_free_propertylist(&wave_map_header);
1887 cpl_free(product_filename);
1888 check( product_filename =
1889 uves_scired_wmap_filename(chip),
1890 "Error getting filename");
1892 cpl_free(product_tag);
1894 uves_sprintf(
"WAVE_MAP_%s",
1898 check( uves_frameset_insert(frames,
1900 CPL_FRAME_GROUP_PRODUCT,
1901 CPL_FRAME_TYPE_IMAGE,
1902 CPL_FRAME_LEVEL_FINAL,
1905 raw_header[raw_index],
1915 "Could not add wave map "
1916 "'%s' (%s) to frameset",
1917 product_filename, product_tag);
1920 "added to frameset",
1921 product_filename, product_tag);
1925 uves_free_image(&wave_map);
1928 if (merged_sky != NULL)
1934 cpl_free(product_filename);
1935 check( product_filename =
1936 uves_scired_merged_sky_filename(chip),
1937 "Error getting filename");
1939 cpl_free(product_tag);
1941 uves_sprintf(
"MERGED_SKY_%s",
1947 check( uves_frameset_insert(
1950 CPL_FRAME_GROUP_PRODUCT,
1951 CPL_FRAME_TYPE_IMAGE,
1952 CPL_FRAME_LEVEL_FINAL,
1955 raw_header[raw_index],
1964 CPL_STATS_MIN | CPL_STATS_MAX),
1965 "Could not add sky spectrum "
1966 "'%s' (%s) to frameset",
1967 product_filename, product_tag);
1969 uves_msg(
"Sky spectrum '%s' (%s) added to frameset",
1970 product_filename, product_tag);
1979 if (fluxcal_science != NULL)
1983 cpl_free(product_filename);
1985 check( product_filename =
1987 uves_scired_fluxcal_science_2d_filename(chip) :
1988 ((m_method == MERGE_NOAPPEND) ?
1989 uves_scired_fluxcal_science_noappend_filename(chip): uves_scired_fluxcal_science_filename(chip)),
1990 "Error getting filename");
1993 cpl_free(product_tag);
1997 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
1998 product_tag = uves_sprintf(
"FLUXCAL%s%s_%s_%s",
1999 (extract_is_2d) ?
"_2D" :
"",catg_is_noappend,
2007 check( uves_frameset_insert(frames,
2009 CPL_FRAME_GROUP_PRODUCT,
2010 CPL_FRAME_TYPE_IMAGE,
2011 CPL_FRAME_LEVEL_FINAL,
2014 raw_header[raw_index],
2023 CPL_STATS_MIN | CPL_STATS_MAX),
2024 "Could not add flux-calibrated science "
2025 "spectrum '%s' (%s) to frameset",
2026 product_filename, product_tag);
2028 uves_msg(
"Flux-calibrated science spectrum "
2029 "'%s' (%s) added to frameset",
2030 product_filename, product_tag);
2034 "10^-16 erg/cm^2/Angstrom/s"),
2035 "Error writing error spectrum header");
2037 cpl_free(product_filename);
2039 check( product_filename =
2041 uves_scired_fluxcal_error_2d_filename(chip) :
2042 ((m_method == MERGE_NOAPPEND) ?
2043 uves_scired_fluxcal_error_noappend_filename(chip): uves_scired_fluxcal_error_filename(chip)),
2044 "Error getting filename");
2047 cpl_free(product_tag);
2050 catg_is_noappend=uves_get_pro_catg_special(extract_is_2d,m_method);
2051 product_tag = uves_sprintf(
"FLUXCAL_ERRORBAR%s%s_%s_%s",
2052 (extract_is_2d) ?
"_2D" :
"",catg_is_noappend,
2057 check( uves_frameset_insert(frames,
2059 CPL_FRAME_GROUP_PRODUCT,
2060 CPL_FRAME_TYPE_IMAGE,
2061 CPL_FRAME_LEVEL_FINAL,
2064 raw_header[raw_index],
2073 CPL_STATS_MIN | CPL_STATS_MAX),
2074 "Could not add flux-calibrated science "
2075 "spectrum error '%s' (%s) to frameset",
2076 product_filename, product_tag);
2078 uves_msg(
"Flux-calibrated science spectrum error "
2079 "'%s' (%s) added to frameset",
2080 product_filename, product_tag);
2087 uves_msg(
"Skipping trace number %d", trace_number);
2094 if(strcmp(PROCESS_CHIP,
"REDL") == 0) {
2097 uves_free_propertylist(&table_header);
2103 uves_free_table(&info_tbl);
2104 uves_free_image(&raw_image[0]);
2105 uves_free_image(&raw_image[1]);
2106 uves_free_propertylist(&raw_header[0]);
2107 uves_free_propertylist(&raw_header[1]);
2108 uves_free_propertylist(&rotated_header[0]);
2109 uves_free_propertylist(&rotated_header[1]);
2110 uves_free_propertylist(&wave_map_header);
2111 uves_free_propertylist(&wave_acc_header);
2114 uves_free_image(&master_bias);
2115 uves_free_propertylist(&master_bias_header);
2117 uves_free_image(&master_dark);
2118 uves_free_propertylist(&master_dark_header);
2120 uves_free_image(&master_flat);
2121 uves_free_propertylist(&master_flat_header);
2123 uves_free_table(&ordertable);
2124 uves_free_propertylist(&ordertable_header);
2126 uves_free_table(&traces);
2128 uves_free_table_const( &(linetable[0]) );
2129 uves_free_table_const( &(linetable[1]) );
2130 uves_free_table_const( &(linetable[2]) );
2131 uves_free_propertylist_const( &(linetable_header[0]) );
2132 uves_free_propertylist_const( &(linetable_header[1]) );
2133 uves_free_propertylist_const( &(linetable_header[2]) );
2138 uves_free_image(&response_curve);
2139 uves_free_propertylist(&response_curve_header);
2140 uves_free_table(&master_response);
2142 uves_free_table(&atm_extinction);
2147 uves_free_image(&background);
2148 uves_free_image(&flatfielded_variance);
2149 uves_free_propertylist(&flatfielded_variance_header);
2150 uves_free_image(&rebinned_science);
2151 uves_free_image(&rebinned_science_error);
2152 uves_free_propertylist(&rebinned_header);
2153 uves_free_image(&resampled_science);
2154 uves_free_image(&resampled_mf);
2155 uves_free_image(&merged_sky);
2157 uves_free_image(&merged_science);
2158 uves_free_propertylist(&merged_header);
2159 uves_free_image(&reduced_science);
2160 uves_free_image(&reduced_science_error);
2161 uves_free_image(&fluxcal_science);
2162 uves_free_image(&fluxcal_error);
2163 uves_free_propertylist(&fluxcal_header);
2164 uves_free_table(&cosmic_mask);
2165 uves_free_propertylist(&cosmic_mask_header);
2167 uves_free_table(&order_trace);
2168 uves_free_propertylist(&order_trace_header);
2170 uves_free_image(&x2d);
2171 uves_free_image(&fx2d);
2172 uves_free_propertylist(&x2d_header);
2174 cpl_free(raw_frames);
2175 cpl_free(product_filename);
2177 cpl_free(product_tag);
2195 const cpl_image *raw_image,
2204 "Science-Reduction-Test-Results",
2233 cpl_image *window = NULL;
2250 "Instrument mode used.",
2256 "Optical path used.",
2262 "Slit common name.",
2266 "Error reading exposure time");
2268 nx = cpl_image_get_size_x(ima);
2269 ny = cpl_image_get_size_y(ima);
2271 for (i = 1; i <= ny; i++)
2275 int xlo = uves_max_int(1 , (nx+1)/2 - size);
2276 int xhi = uves_min_int(nx, (nx+1)/2 + size);
2278 double min, max, avg, rms, med;
2280 uves_free_image(&window);
2281 window = cpl_image_extract(ima, xlo, i, xhi, i);
2284 if (cpl_image_count_rejected(window) >= cpl_image_get_size_x(window) - 2)
2286 min = max = avg = rms = med = 0;
2290 min = cpl_image_get_min (window) / exptime;
2291 max = cpl_image_get_max (window) / exptime;
2292 avg = cpl_image_get_mean (window) / exptime;
2293 rms = cpl_image_get_stdev (window) / exptime;
2294 med = cpl_image_get_median(window) / exptime;
2297 sprintf(key_name,
"QC ORD%d DATAMIN", i);
2301 "extracted order datamin",
2304 sprintf(key_name,
"QC ORD%d DATAMAX", i);
2308 "extracted order datamax",
2311 sprintf(key_name,
"QC ORD%d DATAAVG", i);
2315 "extracted order datamean",
2318 sprintf(key_name,
"QC ORD%d DATARMS", i);
2322 "extracted order datarms",
2325 sprintf(key_name,
"QC ORD%d DATAMED", i);
2329 "extracted order datamed",
2334 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..