1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
|
/* *
* This file is part of the ESO UVES Pipeline *
* Copyright (C) 2004,2005 European Southern Observatory *
* *
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
* */
/*
* $Author: amodigli $
* $Date: 2013-08-08 13:36:46 $
* $Revision: 1.85 $
* $Name: not supported by cvs2svn $
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/*----------------------------------------------------------------------------*/
/**
* @defgroup uves_response Recipe: Response
*
* This recipe calculates the response function and the quantum detection
* efficiency.
* See man-page for details.
*/
/*----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
Includes
-----------------------------------------------------------------------------*/
/* Definitions */
#include <uves.h>
/* Macro steps */
#include <uves_reduce.h>
#include <uves_reduce_utils.h>
#include <uves_response_efficiency.h>
#include <uves_response_utils.h>
/* Utility functions */
#include <uves_extract.h>
#include <uves_plot.h>
#include <uves_dfs.h>
#include <uves_pfits.h>
#include <uves_parameters.h>
#include <uves_utils.h>
#include <uves_utils_wrappers.h>
#include <uves_utils_cpl.h>
#include <uves_qclog.h>
#include <uves_recipe.h>
#include <uves_error.h>
#include <uves_msg.h>
#include <uves_merge.h>
/* Library */
#include <cpl.h>
#include <stdbool.h>
#include <string.h>
/*-----------------------------------------------------------------------------
Functions prototypes
-----------------------------------------------------------------------------*/
static void uves_efficiency_qclog(cpl_table* table,
uves_propertylist* raw_header,
enum uves_chip chip,
cpl_table* qclog,
const char *ref_obj_name);
static int
uves_response_define_parameters(cpl_parameterlist *parameters);
/*-----------------------------------------------------------------------------
Recipe standard code
-----------------------------------------------------------------------------*/
#define cpl_plugin_get_info uves_response_get_info
UVES_RECIPE_DEFINE(
UVES_RESPONSE_ID, UVES_RESPONSE_DOM, uves_response_define_parameters,
"Jonas M. Larsen", "cpl@eso.org",
"Determines response function and quantum efficiency",
"This recipe reduces a standard star frame (STANDARD_xxx or STANDARD_xxx,\n"
"where xxx = BLUE, RED) using a combination (depending on recipe parameters\n"
"and provided input frames) of the steps:\n"
" - bias subtraction,\n"
" - dark subtraction,\n"
" - background subtraction,\n"
" - extraction/cosmic ray removal,\n"
" - flat-field correction,\n"
" - wavelength rebinning,\n"
" - sky subtraction,\n"
" - order merging.\n"
"\n"
" Expected input for this recipe is an raw std star frame, STANDARD_xxx or \n"
"order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
"line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
"MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, a reference standard star\n"
"flux table, FLUX_STD_TABLE, a table describing the atmospheric extintion,\n"
"EXTCOEFF_TABLE. \n"
"Two reductions are performed, the first using optimal extraction (used to\n"
"compute the instrument response function), the second using linear extraction\n"
"(used to get the Quantum Detection Efficiency)\n"
"\n"
"For each chip (xxxx = BLUE, REDL, REDU) the recipe produces\n"
" INSTR_RESPONSE_xxxx Response curve\n"
" WCALIB_FF_RESPONSE_xxxx Response curve in (lambda,order) space before\n"
" correcting for exposure time, gain, binning and\n"
" atmospheric absorption\n"
" RED_STD_xxxx Reduced spectrum\n"
" EFFICIENCY_TABLE_xxxx Efficiency table\n"
" BKG_STD_xxxx The subtracted background\n");
/**@{*/
/*----------------------------------------------------------------------------*/
/**
@brief Setup the recipe options
@param parameters the parameterlist to fill
@return 0 if everything is ok
*/
/*----------------------------------------------------------------------------*/
static int
uves_response_define_parameters(cpl_parameterlist *parameters)
{
/*****************
* General *
*****************/
if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
{
return -1;
}
/*******************
* Reduce *
******************/
/* Get reduce parameters for the top level and also for 'efficiency' substep */
if (uves_propagate_parameters_step(
UVES_REDUCE_ID, parameters, make_str(UVES_RESPONSE_ID), NULL) != 0)
{
return -1;
}
check(uves_define_efficiency_parameters(parameters),
"Defining efficiency parameters");
cleanup:
return (cpl_error_get_code() != CPL_ERROR_NONE);
}
/*----------------------------------------------------------------------------*/
/**
@brief Reduce one chip of a UVES std frame
@param raw_image The raw image
@param raw_header FITS header of raw image
@param rotated_header Header describing the geometry of the raw image after
rotation and removal of pre- and overscan areas
@param master_bias The master bias image for this chip, or NULL
@param master_dark The master dark image for this chip, or NULL
@param mflat_header FITS header of master flat frame
@param master_flat The master flat image for this chip, or NULL
@param mdark_header FITS header of master dark frame
@param ordertable Order table describing the order locations on the raw image
@param order_locations The polynomial describing the order positions
@param linetable Length 3 array of linetable for sky, object, sky.
@param linetable_header Length 3 array of linetable headers for sky, object, sky.
@param dispersion_relation Length 3 array of dispersion relations for sky, object, sky.
@param flux_table Catalogue standard star fluxes
@param atm_extinction Atmospheric extinction coefficients
@param chip CCD chip
@param debug_mode If set to true, intermediate results are saved to
the current directory
@param parameters The recipe parameter list containing parameters
for background subtraction, flat-fielding, extraction,
rebinning
@param calc_response Also calculate response curve (or just do the reduction)?
@param PACCURACY Pointing accuracy (in arcseconds) used to identify object
@param ref_obj_id (out) Reference object ID
@param reduced_spectrum (out) The extracted, flat-fielded, rebinned, merged,
sky-subtracted (but not flux calibrated) science spectrum
@param reduced_header (out) Header describing the geometry of the @em reduced_spectrum
@param background (out) The background image that was subtracted
@param response_orders (out) The response curve per order (2d image), which was
not corrected for exposure time, gain, binning, atm. absorption.
@param response_header_2d (out) Header describing the geometry of @em response_orders
@param response_curve (out) The (merged and therefore 1d) response curve
@param response_header (out) Header describing the geometry of @em response_curve
@param blaze_efficiency (out) Efficiency at blaze function maximum, for each order
@param efficiency (out) The quantum detection efficiency table
@param extraction_slit (out) extraction slit length used
@return The reduced spectrum
This function reduces the provided @em raw_image (see @c uves_reduce) and
computes the response function as
@em R ( @em lambda ) = @em flux_cat / @em flux_std
where @em flux_cat is the tabulated standard star flux, and @em flux_std is
the observed flux (corrected for exposure time, gain, binning and moved
to the top of the atmosphere)
Additionally the instrument Quantum Detection Efficiency is computed.
(see @c uves_response_efficiency)
**/
/*----------------------------------------------------------------------------*/
static cpl_error_code
uves_response_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_table *flux_table,
const cpl_table *atm_extinction,
enum uves_chip chip,
/* General */
bool debug_mode,
/* Backsub */
/* Flat fielding */
/* Extraction */
/* Rebinning */
const cpl_parameterlist *parameters,
bool calc_response,
/* Identification */
double PACCURACY,
/* Output */
char **ref_obj_id,
cpl_image **reduced_spectrum,
uves_propertylist **reduced_header,
cpl_image **background,
cpl_image **response_orders,
uves_propertylist **response_header_2d,
cpl_image **response_curve,
uves_propertylist **response_header,
cpl_table **efficiency,
cpl_table** blaze_efficiency,
cpl_table** info_tbl,
double *extraction_slit)
{
cpl_image *rebinned_spectrum = NULL;
cpl_image *rebinned_noise = NULL;
uves_propertylist *rebinned_header = NULL;
cpl_image *reduced_rebinned = NULL;
cpl_image *reduced_rebinned_noise = NULL;
cpl_image *reduced_noise = NULL;
cpl_table *cosmic_mask = NULL; /* Cosmic ray table (not a product of this recipe) */
cpl_table *order_trace = NULL; /* Order trace table (not a product of this recipe) */
cpl_image *merged_spectrum = NULL; /* Not sky-subtracted (if simple extraction) */
cpl_image *wave_map = NULL;
cpl_image *merged_sky = NULL;
cpl_image *merged_noise = NULL;
cpl_image *reduced_scaled = NULL; /* Merged, sky-subtracted and normalized
(exposure time, gain...) */
cpl_table *catalogue_flux = NULL; /* Std star catalogue flux */
/* Do the science reduction. Produces wave.cal. spectra. */
uves_msg("Reducing standard star");
check( uves_reduce(raw_image,
raw_header,
rotated_header,
master_bias,
mbias_header,
master_dark,
mdark_header,
master_flat,
mflat_header,
ordertable,
order_locations,
linetable,
linetable_header,
dispersion_relation,
chip,
debug_mode,
parameters,
make_str(UVES_RESPONSE_ID),
"",
/* Output */
NULL,
NULL,
NULL, /* 2d products */
&cosmic_mask,
&wave_map,
background,
NULL,
NULL, /* Variance of flat-fielded */
NULL,
NULL, /* Don't need these
intermediate products */
&merged_sky,
&rebinned_spectrum,
&rebinned_noise,
&rebinned_header,
&merged_spectrum,
&merged_noise,
reduced_header,
&reduced_rebinned,
&reduced_rebinned_noise,
reduced_spectrum,
&reduced_noise,
info_tbl,
extraction_slit,
&order_trace),
"Could not reduce frame");
check( uves_plot_image_rows(*reduced_spectrum, 1, 1, 1,
"Wavelength (arbitrary units)", NULL,
"Reduced spectrum (%s chip)",
uves_chip_tostring_upper(chip)),
"Plotting failed");
if (calc_response)
{
/* Calculate 2d response curve (but don't scale to unit exposure time, ...) */
uves_msg("Filtering rebinned spectrum");
check( uves_filter_image_median(&reduced_rebinned, 10, 0, false),
"Could not smooth spectrum");
check( uves_filter_image_average(reduced_rebinned, 10, 0),
"Could not smooth spectrum");
uves_msg("Calculating 2d response curve");
check( *response_orders = uves_calculate_response(reduced_rebinned,
rebinned_header,
flux_table,
raw_header,
PACCURACY,
true,
/* std_flux / flux */
ref_obj_id),
"Could not calculate response curve");
check( *response_header_2d = uves_propertylist_duplicate(rebinned_header),
"Error creating FITS header for 2d response curve");
check( uves_pfits_set_bunit(*response_header_2d, "FLUX_CAT / FLUX_STD"),
"Error writing BUNIT keyword");
/*
* Calculate 1d response curve
*/
uves_msg("Normalizing reduced spectrum");
{
int n_traces = cpl_image_get_size_y(*reduced_spectrum);
assure( n_traces == 1, CPL_ERROR_ILLEGAL_INPUT,
"2d extraction/reduction not supported");
check( reduced_scaled = uves_normalize_spectrum(*reduced_spectrum,
reduced_noise,
*reduced_header,
raw_header,
n_traces,
chip,
atm_extinction,
true, /* Yes, divide by binning */
NULL), /* Noise spectrum */
"Error normalizing reduced spectrum");
}
uves_msg("Filtering reduced spectrum");
check( uves_filter_image_median(&reduced_scaled, 10, 0, false),
"Could not smooth spectrum");
check( uves_filter_image_average(reduced_scaled, 10, 0),
"Could not smooth spectrum");
uves_msg("Calculating response curve from scaled spectrum");
cpl_free(*ref_obj_id); *ref_obj_id = NULL;
check( *response_curve = uves_calculate_response(reduced_scaled,
*reduced_header,
flux_table,
raw_header,
PACCURACY,
true, /* catalogue_flux / flux */
ref_obj_id),
"Could not calculate response curve");
check( *response_header = uves_propertylist_duplicate(*reduced_header),
"Error creating FITS header for response curve");
check( uves_pfits_set_bunit(*response_header, "FLUX_CAT / FLUX_STD"),
"Error writing BUNIT keyword");
if (debug_mode)
{
check( uves_save_image_local("Pre-smoothed response curve", "raw_response",
*response_curve, chip, -1, -1, *response_header, true),
"Error saving image");
}
check( uves_plot_image_rows(*response_curve, 1, 1, 1, "Wavelength (arbitrary units)",
NULL,
"Raw response (%s chip)", uves_chip_tostring_upper(chip)),
"Plotting failed");
/* Rebin the response curve to 50 wlu:
1) smooth it using a radius of 25 wlu,
2) then extract every n'th pixel where n = 50/step */
uves_msg("Rebinning response curve to step size = 50 w.l.u.");
{
double dlambda, lambda_start;
int n, bin, newbin;
check( lambda_start = uves_pfits_get_crval1(*response_header),
"Error reading start wavelength from header");
check( dlambda = uves_pfits_get_cdelt1(*response_header),
"Error reading wavelength step from header");
n = uves_round_double(50.0/dlambda);
assure( n >= 1, CPL_ERROR_ILLEGAL_OUTPUT,
"Cannot rebin to 50 w.l.u. Current step is only %f w.l.u.", dlambda);
/* Filter radius = 25 wlu, 0 (It's a 1d image) */
check( uves_filter_image_average(*response_curve, n/2, 0),
"Error filtering response curve");
newbin = 1;
for (bin = 1+n/2; bin <= cpl_image_get_size_x(*response_curve); bin += n)
{
int pis_rejected;
/* Write to the same image buffer */
cpl_image_set(*response_curve,
newbin, 1,
cpl_image_get(*response_curve, bin, 1, &pis_rejected)
);
newbin++;
}
/* Extract image, update start+step wavelengths */
uves_crop_image(response_curve, 1, 1, newbin-1, 1);
lambda_start = lambda_start + dlambda * ((1+n/2) - 1); /* Center of first bin */
dlambda = n * dlambda;
check( uves_pfits_set_crval1(*response_header, lambda_start),
"Error updating start wavelength");
check( uves_pfits_set_cdelt1(*response_header, dlambda),
"Error updating wavelength step");
}
check( uves_plot_image_rows(*response_curve, 1, 1, 1, "Wavelength (arbitrary units)",
NULL,
"Response curve (%s chip)",
uves_chip_tostring_upper(chip)),
"Plotting failed");
/* Calculate efficiency table */
uves_msg("Calculating efficiency curve");
check( uves_response_efficiency(raw_image,
raw_header,
rotated_header,
master_bias,
mbias_header,
master_dark,
mdark_header,
ordertable,
order_locations,
linetable,
linetable_header,
dispersion_relation,
flux_table,
atm_extinction,
chip,
debug_mode,
parameters,
PACCURACY,
efficiency,
blaze_efficiency),
"Efficiency calculation failed");
check( uves_plot_table(*efficiency, "Wave", "Eff",
"Detection Quantum Efficiency (%s chip)",
uves_chip_tostring_upper(chip)),
"Plotting failed");
/* Save blaze function efficiency (efficiency at center of order) */
if (debug_mode) check( uves_save_table_local("Blaze efficiency table",
"blaze_efficiency",
*blaze_efficiency, chip, -1, -1, rotated_header, NULL),
"Error saving blaze efficiency table");
}
else
{
uves_msg("Skipping response/efficiency computation");
}
cleanup:
uves_free_propertylist(&rebinned_header);
uves_free_image(&rebinned_noise);
uves_free_image(&rebinned_spectrum);
uves_free_table(&cosmic_mask);
uves_free_table(&order_trace);
uves_free_image(&merged_spectrum);
uves_free_image(&merged_noise);
uves_free_image(&merged_sky);
uves_free_image(&reduced_rebinned);
uves_free_image(&reduced_rebinned_noise);
uves_free_image(&reduced_noise);
uves_free_image(&reduced_scaled);
uves_free_table(&catalogue_flux);
if (cpl_error_get_code() != CPL_ERROR_NONE)
{
/* Output */
uves_free_image(reduced_spectrum);
uves_free_image(background);
uves_free_image(response_orders);
uves_free_image(response_curve);
uves_free_propertylist(reduced_header);
uves_free_propertylist(response_header);
uves_free_propertylist(response_header_2d);
uves_free_table(efficiency);
}
return cpl_error_get_code();
}
/*----------------------------------------------------------------------------*/
/**
@brief Get the command line options and execute the data reduction
@param parameters the parameters list
@param frames the frames list
@return CPL_ERROR_NONE if everything is ok
*/
/*----------------------------------------------------------------------------*/
static void
UVES_CONCAT2X(UVES_RESPONSE_ID,exe)(cpl_frameset *frames,
const cpl_parameterlist *parameters,
const char *starttime)
{
/*
* Variables containg the values of recipe parameters
*/
/* General */
bool debug_mode;
/* Background subtraction */
/* Implicitly passed */
/* Flat-fielding */
/* Extraction */
/* Implicitly passed */
/* Rebinning */
/* Implicitly passed */
/* Efficiency */
double PACCURACY;
/* CPL objects */
/* Input, raw */
cpl_image *raw_image[2] = {NULL, NULL};
uves_propertylist *raw_header[2] = {NULL, NULL};
uves_propertylist *rotated_header[2] = {NULL, NULL};
/* Input, calib */
cpl_image *master_bias = NULL;
uves_propertylist *master_bias_header = NULL;
cpl_image *master_dark = NULL;
uves_propertylist *master_dark_header = NULL;
cpl_image *master_flat = NULL;
uves_propertylist *master_flat_header = NULL;
cpl_table *ordertable = NULL;
uves_propertylist *ordertable_header= NULL;
polynomial *order_locations = NULL;
cpl_table *traces = NULL;
cpl_table *flux_table = NULL;
cpl_table *atm_extinction = NULL;
uves_propertylist *table_header= NULL;
/* Line tables for sky, object, sky (UVES specific) */
const cpl_table *linetable[3] = {NULL, NULL, NULL};
const uves_propertylist *linetable_header[3] = {NULL, NULL, NULL};
const polynomial *dispersion_relation[3] = {NULL, NULL, NULL};
/* Output */
cpl_image *background = NULL;
cpl_image *reduced_spectrum = NULL;
uves_propertylist *spectrum_header = NULL;
cpl_image *response_orders = NULL;
uves_propertylist *response_header_2d = NULL;
cpl_image *response_curve = NULL;
uves_propertylist *response_header = NULL;
cpl_table *efficiency = NULL;
cpl_table *blaze_efficiency = NULL;
uves_propertylist *efficiency_header = NULL;
cpl_table* info_tbl=NULL;
/* Local variables */
cpl_table *qclog[2] = {NULL, NULL};
cpl_table *qclog_optext[2] = {NULL, NULL};
cpl_table *catalogue_flux = NULL;
const char *raw_filename = ""; /* Static */
const char *flux_table_filename = ""; /* Static */
const char *atm_ext_filename = ""; /* Static */
char *product_filename = NULL; /* Dynamically allocated */
char *prod_catg = NULL;
char *ref_obj_name = NULL; /* Reference object id */
bool calc_response = false; /* Calculate instr response? */
double extraction_slit;
bool blue = false;
enum uves_chip chip;
int binx = 0;
int biny = 0;
const char* PROCESS_CHIP=NULL;
const char *ordertable_filename = "";
const char *linetable_filename = "";
const char *master_bias_filename = "";
const char *master_dark_filename = "";
const char *master_flat_filename = "";
const char *chip_name = "";
int tracerow=0; /* Index of table row */
int raw_index = 0;
char extname[80];
double trace_offset=0;
int trace_number=0;
int trace_enabled=0;
int window=0; /* window number */
merge_method m_method;
/* Read recipe parameters */
{
/* General */
check( uves_get_parameter(parameters, NULL, "uves", "debug",
CPL_TYPE_BOOL , &debug_mode ), "Could not read parameter");
check( uves_get_parameter(parameters, NULL, "uves", "process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
"Could not read parameter");
uves_string_toupper((char*)PROCESS_CHIP);
/* Background subtraction, Flat-fielding, Rebinning */
/* The input parameter list is passed */
/* For both response curve and efficiency step:
Allow only extraction methods average/linear/optimal */
{
extract_method em;
/* Validate uves_response.reduce.extract.method */
check( em = uves_get_extract_method(
parameters, NULL,
make_str(UVES_RESPONSE_ID) "." UVES_REDUCE_ID "." UVES_EXTRACT_ID),
"Could not read extraction method");
assure( em == EXTRACT_LINEAR || em == EXTRACT_AVERAGE || em == EXTRACT_OPTIMAL,
CPL_ERROR_UNSUPPORTED_MODE,
"Use linear/average/optimal extraction method to calculate response curve");
/* Validate uves_response.efficiency.reduce.extract.method */
check( em = uves_get_extract_method(
parameters, NULL,
make_str(UVES_RESPONSE_ID) ".efficiency." UVES_REDUCE_ID "." UVES_EXTRACT_ID),
"Could not read extraction method");
assure( em == EXTRACT_LINEAR || em == EXTRACT_AVERAGE || em == EXTRACT_OPTIMAL,
CPL_ERROR_UNSUPPORTED_MODE,
"Use linear/average/optimal extraction "
"method to calculate quantum efficiency");
}
/* Identification */
check( uves_get_parameter(parameters, NULL,
make_str(UVES_RESPONSE_ID) ".efficiency", "paccuracy",
CPL_TYPE_DOUBLE, &PACCURACY),
"Could not read parameter");
}
/* Load raw image and header, and identify input frame as red or blue */
check( uves_load_standard(frames,
&raw_filename, raw_image, raw_header, rotated_header,
&blue),
"Error loading raw frame");
/* Load flux table */
check( uves_load_flux_table(frames, &flux_table_filename, &flux_table),
"Error loading standard flux table");
uves_msg_low("Using standard star flux table in '%s'", flux_table_filename);
/* Before doing the reduction, find out if the standard star is in the table.
* If not, still do the science reduction, but skip the instr.response part
*/
catalogue_flux = uves_align(raw_header[0], flux_table, PACCURACY, &ref_obj_name);
calc_response = true;
if (cpl_error_get_code() == CPL_ERROR_INCOMPATIBLE_INPUT)
{
uves_error_reset();
uves_msg_warning("No catalogue object found within %.2f arcsecs. "
"Instrument response curve will not be computed",
PACCURACY);
calc_response = false;
}
/* Load atmospheric extinction table */
check( uves_load_atmo_ext(frames, &atm_ext_filename, &atm_extinction),
"Error loading extinction coefficients");
uves_msg_low("Using atmospheric extinction table in '%s'", atm_ext_filename);
//cpl_parameterlist_dump(parameters,stdout);
//uves_msg("recipe=%s",UVES_RESPONSE_ID);
check( m_method = uves_get_merge_method(parameters, "uves_cal_response", "reduce"),
"Could not get merging method");
/* Adjust parameters according to binning
*/
check (binx = uves_pfits_get_binx(raw_header[0]),
"Could not read x binning factor from input header");
check (biny = uves_pfits_get_biny(raw_header[0]),
"Could not read y binning factor from input header");
/* Loop over one or two chips, over traces and
over extraction windows */
for (chip = uves_chip_get_first(blue);
chip != UVES_CHIP_INVALID;
chip = uves_chip_get_next(chip))
{
table_header = uves_propertylist_new();
if(strcmp(PROCESS_CHIP,"REDU") == 0) {
chip = uves_chip_get_next(chip);
}
/* const char *drs_filename = ""; not used */
raw_index = uves_chip_get_index(chip);
uves_msg("Processing %s chip in '%s'",
uves_chip_tostring_upper(chip), raw_filename);
check_nomsg( chip_name = uves_pfits_get_chipid(raw_header[raw_index], chip));
uves_msg_debug("Binning = %dx%d", binx, biny);
/* Load master bias, set pointer to NULL if not present */
uves_free_image(&master_bias);
uves_free_propertylist(&master_bias_header);
if (cpl_frameset_find(frames, UVES_MASTER_BIAS(chip)) != NULL)
{
check( uves_load_mbias(frames, chip_name,
&master_bias_filename,
&master_bias,
&master_bias_header, chip),
"Error loading master bias");
uves_msg_low("Using master bias in '%s'", master_bias_filename);
}
else
{
uves_msg_low("No master bias in SOF. Bias subtraction not done");
}
/* Load master dark, set pointer to NULL if not present */
uves_free_image(&master_dark);
uves_free_propertylist(&master_dark_header);
if (cpl_frameset_find(frames, UVES_MASTER_DARK(chip)) != NULL)
{
check( uves_load_mdark(frames, chip_name,
&master_dark_filename,
&master_dark,
&master_dark_header, chip),
"Error loading master dark");
uves_msg_low("Using master dark in '%s'", master_dark_filename);
}
else
{
uves_msg_low("No master dark in SOF. Dark subtraction not done");
}
/* Load master flat */
uves_free_image(&master_flat);
uves_free_propertylist(&master_flat_header);
check( uves_load_mflat_const(frames, chip_name,
&master_flat_filename,
&master_flat,
&master_flat_header,
chip, NULL), "Error loading master flat");
uves_msg_low("Using master flat in '%s'", master_flat_filename);
/* Load the order table for this chip */
uves_free_table (&ordertable);
uves_free_propertylist(&ordertable_header);
uves_polynomial_delete(&order_locations);
uves_free_table (&traces);
check( uves_load_ordertable(frames,
false, /* FLAMES? */
chip_name,
&ordertable_filename,
&ordertable,
&ordertable_header,
NULL,
&order_locations, &traces,
NULL, NULL,
NULL, NULL, /* fibre_pos,fibre_mask */
chip, false),
"Could not load order table");
uves_msg_low("Using order table in '%s'", ordertable_filename);
/* Loop over all traces (1 trace for UVES) */
for(tracerow = 0; tracerow < cpl_table_get_nrow(traces); tracerow++)
{
trace_offset = cpl_table_get_double(traces, "Offset" , tracerow, NULL);
trace_number = cpl_table_get_int (traces, "TraceID" , tracerow, NULL);
trace_enabled = cpl_table_get_int (traces, "Tracemask" , tracerow, NULL);
if (trace_enabled != 0)
{
if (cpl_table_get_nrow(traces) > 1) {
uves_msg("Processing trace %d", trace_number);
}
/* This is UVES specific. Load linetable for the
two sky windows (number 1, 3) and for the object
window (number 2) */
for (window = 1; window <= 3; window ++)
{
uves_free_table_const ( &(linetable[window-1]) );
uves_free_propertylist_const( &(linetable_header[window-1]) );
uves_polynomial_delete_const( &(dispersion_relation[window-1]) );
check( uves_load_linetable_const(
frames,
false, /* FLAMES? */
chip_name,
order_locations,
cpl_table_get_column_min(ordertable, "Order"),
cpl_table_get_column_max(ordertable, "Order"),
&linetable_filename,
&(linetable [window-1]),
&(linetable_header [window-1]),
&(dispersion_relation[window-1]),
NULL,
chip,
trace_number,
window),
"Could not load line table, window #%d", window);
}
uves_msg_low("Using line tables in '%s'", linetable_filename);
/* end, UVES specific */
/* Do the reduction + response calculation */
cpl_free(ref_obj_name); ref_obj_name = NULL;
uves_free_image(&reduced_spectrum);
uves_free_image(&background);
uves_free_image(&response_orders);
uves_free_image(&response_curve);
uves_free_propertylist(&response_header);
uves_free_propertylist(&spectrum_header);
uves_free_propertylist(&response_header_2d);
uves_free_table(&efficiency);
uves_free_table(&blaze_efficiency);
uves_free_table(&info_tbl);
check( uves_response_process_chip(
raw_image[raw_index], /* Raw */
raw_header[raw_index],
rotated_header[raw_index],
master_bias, /* Calibration */
master_bias_header,
master_dark,
master_dark_header,
master_flat,
master_flat_header,
ordertable,
order_locations,
linetable,
linetable_header,
dispersion_relation,
flux_table,
atm_extinction,
chip, /* Parameters */
debug_mode,
parameters,
calc_response,
PACCURACY, /* Identification */
&ref_obj_name,
&reduced_spectrum,
&spectrum_header,
&background,
&response_orders,
&response_header_2d,
&response_curve,
&response_header,
&efficiency,
&blaze_efficiency,
&info_tbl,
&extraction_slit),
"Response computation failed");
uves_msg("Saving products...");
/* Calculate QC (two tables) */
if (calc_response)
{
uves_qclog_delete(&qclog[0]);
qclog[0] = uves_qclog_init(raw_header[raw_index], chip);
check( uves_efficiency_qclog(blaze_efficiency,
raw_header[raw_index],
chip,
qclog[0],
ref_obj_name),
"Error generating efficiency QC log");
}
uves_qclog_delete(&qclog_optext[0]);
qclog_optext[0] = cpl_table_new(0);
/* Do not:
qclog_optext[0] = uves_qclog_init(raw_header[raw_index], chip);
because we don't want QC.DID for this
*/
cpl_table_new_column(qclog_optext[0],"key_name", CPL_TYPE_STRING);
cpl_table_new_column(qclog_optext[0],"key_type", CPL_TYPE_STRING);
cpl_table_new_column(qclog_optext[0],"key_value",CPL_TYPE_STRING);
cpl_table_new_column(qclog_optext[0],"key_help", CPL_TYPE_STRING);
check( uves_qclog_add_sci(qclog_optext[0],
raw_header[raw_index],
raw_image[raw_index],
extraction_slit,
info_tbl),
"Error generating extraction QC log");
if (calc_response)
{
/* Save response curve */
cpl_free(product_filename);
check( product_filename = uves_response_curve_filename(chip),
"Error getting filename");
uves_pfits_set_extname(response_header,"instrument response");
check( uves_frameset_insert(
frames,
response_curve,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_IMAGE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
UVES_INSTR_RESPONSE(chip),
raw_header[raw_index],
response_header,
NULL,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION,
qclog_optext,
starttime, false,
UVES_ALL_STATS),
"Could not add response curve '%s' (%s) to frameset",
product_filename, UVES_INSTR_RESPONSE(chip));
uves_msg("Response curve '%s' (%s) added to frameset",
product_filename, UVES_INSTR_RESPONSE(chip));
/* Save response curve (2d) */
cpl_free(product_filename);
check( product_filename =
uves_response_curve_2d_filename(chip),
"Error getting filename");
uves_pfits_set_extname(response_header_2d,"2D instrument response");
check( uves_frameset_insert(
frames,
response_orders,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_IMAGE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
UVES_WCALIB_FF_RESPONSE(chip),
raw_header[raw_index],
response_header_2d,
NULL,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION,
qclog_optext,
starttime, false,
UVES_ALL_STATS),
"Could not add response curve (2d) "
"'%s' (%s) to frameset",
product_filename, UVES_WCALIB_FF_RESPONSE(chip));
uves_msg("Response curve (2d) '%s' (%s) added to frameset",
product_filename, UVES_WCALIB_FF_RESPONSE(chip));
}
/* Save reduced spectrum */
cpl_free(product_filename);
if (m_method == MERGE_NOAPPEND) {
check( product_filename = uves_response_red_noappend_standard_filename(chip),
"Error getting filename");
prod_catg=UVES_RED_NOAPPEND_STD(chip);
} else {
check( product_filename = uves_response_red_standard_filename(chip),
"Error getting filename");
prod_catg=UVES_RED_STD(chip);
}
uves_pfits_set_extname(spectrum_header,"reduced spectrum");
check( uves_frameset_insert(frames,
reduced_spectrum,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_IMAGE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
prod_catg,
raw_header[raw_index],
spectrum_header,
NULL,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION,
qclog_optext,
starttime, false,
UVES_ALL_STATS),
"Could not add reduced spectrum '%s' (%s) to frameset",
product_filename, UVES_RED_STD(chip));
uves_msg("Reduced spectrum '%s' (%s) added to frameset",
product_filename, UVES_RED_STD(chip));
if (calc_response)
{
/* Save efficiency table */
uves_free_propertylist(&efficiency_header);
efficiency_header = uves_propertylist_new();
cpl_free(product_filename);
check( product_filename =
uves_response_efficiency_filename(chip),
"Error getting filename");
uves_pfits_set_extname(efficiency_header,"efficiency");
sprintf(extname,"EFFICIENCY");
uves_pfits_set_extname(table_header,extname);
check( uves_frameset_insert(
frames,
efficiency,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_TABLE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
UVES_EFFICIENCY_TABLE(chip),
raw_header[raw_index],
efficiency_header,
table_header,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION,
qclog,
starttime, true, 0),
"Could not add background image '%s' (%s) to frameset",
product_filename, UVES_EFFICIENCY_TABLE(chip));
uves_msg("Efficiency table '%s' (%s) added to frameset",
product_filename, UVES_EFFICIENCY_TABLE(chip));
} /* end if calc_response */
/* Save background image */
cpl_free(product_filename);
check( product_filename =
uves_response_bkg_standard_filename(chip),
"Error getting filename");
uves_pfits_set_extname(rotated_header[raw_index],"background");
check( uves_frameset_insert(frames,
background,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_IMAGE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
UVES_BKG_STD(chip),
raw_header[raw_index],
rotated_header[raw_index],
NULL,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION, NULL,
starttime, false,
CPL_STATS_MIN | CPL_STATS_MAX),
"Could not add background image '%s' (%s) to frameset",
product_filename, UVES_BKG_STD(chip));
uves_msg("Background image '%s' (%s) added to frameset",
product_filename, UVES_BKG_STD(chip));
/* Save info table */
cpl_free(product_filename);
check( product_filename =
uves_order_extract_qc_standard_filename(chip),
"Error getting filename");
uves_pfits_set_extname(rotated_header[raw_index],"quality control table");
sprintf(extname,"QC_INFO");
uves_pfits_set_extname(table_header,extname);
check( uves_frameset_insert(frames,
info_tbl,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_TYPE_TABLE,
CPL_FRAME_LEVEL_INTERMEDIATE,
product_filename,
UVES_ORDER_EXTRACT_QC(chip),
raw_header[raw_index],
rotated_header[raw_index],
table_header,
parameters,
make_str(UVES_RESPONSE_ID),
PACKAGE "/" PACKAGE_VERSION, NULL,
starttime, true,
0),
"Could not add extraction quality table '%s' (%s) to frameset",
product_filename, UVES_ORDER_EXTRACT_QC(chip));
uves_msg("Extraction quality table '%s' (%s) added to frameset",
product_filename, UVES_ORDER_EXTRACT_QC(chip));
}/* ... if trace is enabled */
else
{
uves_msg_low("Skipping trace number %d", trace_number);
}
}/* For each trace */
if(strcmp(PROCESS_CHIP,"REDL") == 0) {
chip = uves_chip_get_next(chip);
}
uves_free_propertylist(&table_header);
} /* For each chip */
cleanup:
/* Input */
uves_free_image(&raw_image[0]);
uves_free_image(&raw_image[1]);
uves_free_propertylist(&raw_header[0]);
uves_free_propertylist(&raw_header[1]);
uves_free_propertylist(&rotated_header[0]);
uves_free_propertylist(&rotated_header[1]);
/* Input, calib */
uves_free_image(&master_bias);
uves_free_propertylist(&master_bias_header);
uves_free_image(&master_dark);
uves_free_propertylist(&master_dark_header);
uves_free_image(&master_flat);
uves_free_propertylist(&master_flat_header);
uves_free_table(&ordertable);
uves_free_propertylist(&ordertable_header);
uves_polynomial_delete(&order_locations);
uves_free_table(&traces);
uves_free_propertylist(&table_header);
uves_free_table_const( &(linetable[0]) );
uves_free_table_const( &(linetable[1]) );
uves_free_table_const( &(linetable[2]) );
uves_free_propertylist_const( &(linetable_header[0]) );
uves_free_propertylist_const( &(linetable_header[1]) );
uves_free_propertylist_const( &(linetable_header[2]) );
uves_polynomial_delete_const( &(dispersion_relation[0]) );
uves_polynomial_delete_const( &(dispersion_relation[1]) );
uves_polynomial_delete_const( &(dispersion_relation[2]) );
uves_free_table( &flux_table );
uves_free_table( &atm_extinction );
/* Output */
uves_qclog_delete(&qclog[0]);
uves_qclog_delete(&qclog_optext[0]);
uves_free_image(&background);
uves_free_image(&reduced_spectrum);
uves_free_propertylist(&spectrum_header);
uves_free_propertylist(&response_header_2d);
uves_free_propertylist(&response_header);
uves_free_propertylist(&efficiency_header);
uves_free_image(&response_orders);
uves_free_image(&response_curve);
uves_free_table(&efficiency);
uves_free_table(&blaze_efficiency);
uves_free_table(&info_tbl);
/* Local */
uves_free_table(&catalogue_flux);
cpl_free(product_filename);
cpl_free(ref_obj_name);
return;
}
/**
@@ brief QC log generation
@param table efficiency table
@param info_tbl table with info on object location during extraction
@param raw_header FITS header
@param chip chip ID
@param qclog ouput QC log table
@param ref_obj_name reference object name
*/
static void uves_efficiency_qclog(cpl_table* table,
uves_propertylist* raw_header,
enum uves_chip chip,
cpl_table* qclog,
const char *ref_obj_name)
{
int i=0;
bool new_format;
check( new_format = uves_format_is_new(raw_header),
"Error determining FITS header format");
check_nomsg(uves_qclog_add_string(qclog,
"QC TEST1 ID",
"Efficiency-Test-Results",
"Name of QC test",
"%s"));
check_nomsg(uves_qclog_add_string(qclog,
uves_remove_string_prefix(UVES_INSPATH,"ESO "),
uves_pfits_get_inspath(raw_header),
"Optical path used.",
"%s"));
check_nomsg(uves_qclog_add_string(qclog,
uves_remove_string_prefix(UVES_INSMODE,"ESO "),
uves_pfits_get_insmode(raw_header),
"Instrument mode used.",
"%s"));
check_nomsg(uves_qclog_add_string(qclog,
uves_remove_string_prefix(UVES_GRATNAME(chip),"ESO "),
uves_pfits_get_gratname(raw_header,chip),
"Cross disperser ID",
"%s"));
check_nomsg(uves_qclog_add_common_wave(raw_header,
chip, qclog));
check_nomsg(
uves_qclog_add_string(qclog,
uves_remove_string_prefix(UVES_CHIP_NAME(chip),"ESO "),
/* UVES_QC_CHIP_VAL(chip), */
uves_pfits_get_chip_name(raw_header, chip),
"Detector chip name",
"%s"));
check_nomsg(
uves_qclog_add_double(qclog,
uves_remove_string_prefix(UVES_GRATWLEN(chip),"ESO "),
uves_pfits_get_gratwlen(raw_header,chip),
"Grating central wavelength [nm] (hs).",
"%.1f"));
check_nomsg(
uves_qclog_add_double(qclog,
uves_remove_string_prefix(UVES_CONAD(new_format, chip),"ESO "),
uves_pfits_get_conad(raw_header, chip),
"Conversion from ADUs to electrons",
"%8.2f"));
check_nomsg(
uves_qclog_add_double(qclog,
uves_remove_string_prefix(UVES_QC_UIT(new_format, chip), "ESO "),
uves_pfits_get_uit(raw_header),
"user defined subintegration time",
"%8.0f"));
check_nomsg(
uves_qclog_add_double(qclog,
"AIRMASS",
(uves_pfits_get_airmass_start(raw_header) +
uves_pfits_get_airmass_end(raw_header))/2.0,
"Averaged airmass",
"%8.4f"));
check_nomsg(
uves_qclog_add_string(qclog,
uves_remove_string_prefix(UVES_TARG_NAME, "ESO "),
ref_obj_name,
"OB target name",
"%s"));
for(i = 0; i < cpl_table_get_nrow(table); i++)
{
char key_name[25];
int order = cpl_table_get_int(table, "Order", i, NULL);
sprintf(key_name,"QC BLAZEFF%d", order);
check_nomsg(uves_qclog_add_double(qclog,
key_name,
cpl_table_get_double(table, "Eff", i, NULL),
"Blaze Efficiency",
"%13.6f"));
/*
uves_msg("QC-LOG: Wlen =%g Eff=%g",
cpl_table_get_double(table,"Wave",i,NULL),
cpl_table_get_double(table,"Eff",i,NULL));
*/
sprintf(key_name,"QC BLAZWLEN%d", order);
check_nomsg(uves_qclog_add_double(qclog,
key_name,
cpl_table_get_double(table, "Wave", i, NULL)/10.,
"Blaze wavelength", /* nm */
"%13.6f"));
}
/* Are these QC parameters needed anywhere? */
#if 0
for(i = 0; i < cpl_table_get_nrow(info_tbl); i++)
{
char key_name[25];
int order = cpl_table_get_int(info_tbl, "Order", i, NULL);
sprintf(key_name,"QC ORDER NUM%d", order);
check_nomsg(uves_qclog_add_int(qclog,
key_name,
order,
"Order Number",
"%d"));
/*
uves_msg("QC-LOG: Order =%d S/N=%g",
cpl_table_get_int(info_tbl,"Order",i,NULL),
cpl_table_get_double(info_tbl,"S/N",i,NULL));
*/
sprintf(key_name,"QC OBJ SN%d", order);
check_nomsg(uves_qclog_add_double(qclog,
key_name,
cpl_table_get_double(info_tbl,"S/N",i,NULL),
"Order S/N",
"%f13.6"));
}
#endif
cleanup:
return;
}
/**@}*/
|