00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 #include <uves_time.h>
00032 #include <uves_globals.h>
00033
00037
00038
00039
00040
00041
00042 #define FILE_NAME_SZ 1024
00043
00046
00047
00048
00049
00050 #include "uves_qclog.h"
00051
00052 #include <uves_baryvel.h>
00053 #include <uves_utils_wrappers.h>
00054 #include <uves_pfits.h>
00055 #include <uves_error.h>
00056 #include <uves_msg.h>
00057
00058 #include <irplib_utils.h>
00059 #include <string.h>
00060
00061
00062
00063
00064
00065
00066
00067
00068 static FILE * uves_paf_print_header(
00069 const char * filename,
00070 const char * paf_id,
00071 const char * paf_desc,
00072 const char * login_name,
00073 const char * datetime) ;
00074
00075
00100
00101 static FILE * uves_paf_print_header(
00102 const char * filename,
00103 const char * paf_id,
00104 const char * paf_desc,
00105 const char * login_name,
00106 const char * datetime)
00107 {
00108 FILE * paf ;
00109
00110 if ((paf=fopen(filename, "w"))==NULL) {
00111 uves_msg_error("cannot create PAF file [%s]", filename);
00112 return NULL ;
00113 }
00114 fprintf(paf, "PAF.HDR.START ; # start of header\n");
00115 fprintf(paf, "PAF.TYPE \"pipeline product\" ;\n");
00116 fprintf(paf, "PAF.ID \"%s\"\n", paf_id);
00117 fprintf(paf, "PAF.NAME \"%s\"\n", filename);
00118 fprintf(paf, "PAF.DESC \"%s\"\n", paf_desc);
00119 fprintf(paf, "PAF.CRTE.NAME \"%s\"\n", login_name) ;
00120 fprintf(paf, "PAF.CRTE.DAYTIM \"%s\"\n", datetime) ;
00121 fprintf(paf, "PAF.LCHG.NAME \"%s\"\n", login_name) ;
00122 fprintf(paf, "PAF.LCHG.DAYTIM \"%s\"\n", datetime) ;
00123 fprintf(paf, "PAF.CHCK.CHECKSUM \"\"\n");
00124 fprintf(paf, "PAF.HDR.END ; # end of header\n");
00125 fprintf(paf, "\n");
00126 return paf ;
00127 }
00128
00129
00136 char *
00137 uves_get_rootname(const char * filename)
00138 {
00139 static char path[MAX_NAME_SIZE+1];
00140 char * lastdot ;
00141
00142 if (strlen(filename)>MAX_NAME_SIZE) return NULL ;
00143 memset(path, MAX_NAME_SIZE, 0);
00144 strcpy(path, filename);
00145 lastdot = strrchr(path, '.');
00146 if (lastdot == NULL) return path ;
00147 if ((!strcmp(lastdot, ".fits")) || (!strcmp(lastdot, ".FITS")) ||
00148 (!strcmp(lastdot, ".paf")) || (!strcmp(lastdot, ".PAF")) ||
00149 (!strcmp(lastdot, ".dat")) || (!strcmp(lastdot, ".DAT")) ||
00150 (!strcmp(lastdot, ".tfits")) || (!strcmp(lastdot, ".TFITS")) ||
00151 (!strcmp(lastdot, ".ascii")) || (!strcmp(lastdot, ".ASCII")))
00152 {
00153 lastdot[0] = (char)0;
00154 }
00155 return path ;
00156 }
00164 void
00165 uves_get_paf_name(const char* in, int paf_no, char** paf)
00166 {
00167 char* tmp=NULL;
00168 char name_b[512] ;
00169
00170 if (strstr(in, "." ) != NULL )
00171 {
00172 tmp = uves_get_rootname(in);
00173 strcpy(name_b, tmp);
00174 }
00175 else
00176 {
00177 sprintf(name_b, "%s", in) ;
00178 }
00179
00180 sprintf(*paf, "%s-%d.paf", name_b, paf_no);
00181
00182 return;
00183 }
00189 int uves_blank2dot(const char * in, char* ou)
00190 {
00191 int len=0;
00192 int i=0;
00193
00194 strcpy(ou,in);
00195 len = strlen(in);
00196 for (i=0;i<len;i++)
00197 {
00198 if (in[i] == ' ') {
00199 ou[i] = '.';
00200 }
00201 }
00202 return 0;
00203 }
00204
00205
00206
00207
00208
00224
00225 int uves_save_paf(const char* filename,
00226 int paf_no,
00227 const char* rec_id,
00228 const cpl_table* qclog,
00229 uves_propertylist* plist,
00230 const uves_propertylist* rhead,
00231 const char* pro_catg)
00232 {
00233
00234
00235 FILE * paf ;
00236 const char * sval ;
00237 char key_name[FILE_NAME_SZ] ;
00238 char key_paf[FILE_NAME_SZ] ;
00239 char key_dpaf[FILE_NAME_SZ] ;
00240 char key_type[FILE_NAME_SZ] ;
00241 char key_value[FILE_NAME_SZ] ;
00242 char key_help[FILE_NAME_SZ] ;
00243 char* name_p=NULL;
00244
00245 int i =0;
00246 int n=0;
00247
00248 name_p = cpl_malloc(FILE_NAME_SZ * sizeof(char));
00249 uves_get_paf_name(filename, paf_no, &name_p);
00250
00251
00252 uves_msg( "Writing %s" , name_p) ;
00253
00254 if ((paf = uves_paf_print_header(
00255 name_p,
00256 rec_id,
00257 "QC file",
00258 "login-name",
00259 uves_get_datetime_iso8601())) == NULL) {
00260 uves_msg_error( "cannot open file [%s] for output", name_p) ;
00261 return -1 ;
00262 }
00263 cpl_free(name_p);
00264
00265
00266 strcpy(key_name,KEY_NAME_QC_DID);
00267 strcpy(key_paf,PAF_NAME_QC_DID);
00268 uves_blank2dot(key_paf,key_dpaf);
00269 fprintf(paf,"%-21s \"%s\" ; # %s \n",key_dpaf,
00270 uves_propertylist_get_string(plist,key_name),KEY_HELP_QC_DID);
00271
00272
00273 uves_blank2dot(PAF_NAME_PIPE_ID,key_dpaf);
00274 fprintf(paf,"%-21s \"%s/%s\" ; # %s \n", key_dpaf,
00275 PACKAGE, PACKAGE_VERSION,KEY_HELP_PIPE_ID);
00276
00277 strcpy(key_name, KEY_NAME_PIPEFILE);
00278 strcpy(key_paf, KEY_NAME_PIPEFILE);
00279 uves_blank2dot(key_paf, key_dpaf);
00280 if (uves_propertylist_contains(plist, key_name)) {
00281 fprintf(paf,"%-21s \"%s\" ; # %s \n", key_dpaf,
00282 uves_propertylist_get_string(plist,key_name),KEY_HELP_PIPEFILE);
00283 }
00284
00285
00286 strcpy(key_name,KEY_NAME_PRO_TYPE);
00287 strcpy(key_paf,PAF_NAME_PRO_TYPE);
00288 uves_blank2dot(key_paf,key_dpaf);
00289 if (uves_propertylist_contains(plist, key_name)) {
00290 fprintf(paf,"%-21s \"%s\" ; # %s \n", key_dpaf,
00291 uves_propertylist_get_string(plist,key_name),KEY_HELP_PRO_TYPE);
00292 }
00293
00294 strcpy(key_name,KEY_NAME_PRO_RECID);
00295 strcpy(key_paf,PAF_NAME_PRO_RECID);
00296 uves_blank2dot(key_paf,key_dpaf);
00297 if (uves_propertylist_contains(plist, key_name)) {
00298 fprintf(paf,"%-21s \"%s\" ; # %s \n", key_dpaf,
00299 uves_propertylist_get_string(plist,key_name),KEY_HELP_PRO_RECID);
00300 }
00301
00302
00303 strcpy(key_name,KEY_NAME_PRO_DRSID);
00304 strcpy(key_paf,PAF_NAME_PRO_DRSID);
00305 uves_blank2dot(key_paf,key_dpaf);
00306 if (uves_propertylist_contains(plist, key_name)) {
00307 fprintf(paf,"%-21s \"%s\" ; # %s \n",key_dpaf,
00308 uves_propertylist_get_string(plist,key_name),KEY_HELP_PRO_DRSID);
00309 }
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 if (uves_propertylist_contains(rhead,KEY_NAME_ARCFILE)) {
00321 sval = uves_pfits_get_arcfile(rhead);
00322 strcpy(key_paf,KEY_NAME_ARCFILE);
00323 uves_blank2dot(key_paf,key_dpaf);
00324 fprintf(paf, "%-21s \"%s\" ; # %s \n", key_dpaf,sval,KEY_HELP_ARCFILE) ;
00325 } else if (uves_propertylist_contains(rhead,KEY_NAME_PRO_REC1_RAW1_NAME)) {
00326 sval = uves_pfits_get_rec1raw1name(rhead);
00327 strcpy(key_paf,KEY_NAME_ARCFILE);
00328 uves_blank2dot(key_paf,key_dpaf);
00329 } else {
00330 uves_msg_error("%s is missing QC LOG will fail!",KEY_NAME_ARCFILE);
00331 }
00332
00333
00334 if (uves_propertylist_contains(plist,KEY_NAME_TPL_ID)) {
00335 sval = uves_pfits_get_templateid(plist);
00336 strcpy(key_paf,PAF_NAME_TPL_ID);
00337 uves_blank2dot(key_paf,key_dpaf);
00338 fprintf(paf, "%-21s \"%s\" ; # %s\n", key_dpaf,
00339 sval,KEY_HELP_TPL_ID) ;
00340
00341 }
00342
00343 if (uves_propertylist_contains(plist,KEY_NAME_DPR_TYPE)) {
00344 sval = uves_pfits_get_dpr_type(plist);
00345 strcpy(key_paf,PAF_NAME_DPR_TYPE);
00346 uves_blank2dot(key_paf,key_dpaf);
00347 fprintf(paf, "%-21s \"%s\" ; # %s\n", key_dpaf,
00348 sval, KEY_HELP_DPR_TYPE) ;
00349 }
00350
00351 if (uves_propertylist_contains(plist,KEY_NAME_DPR_TECH)) {
00352 sval = uves_pfits_get_dpr_tech(plist);
00353 strcpy(key_paf,PAF_NAME_DPR_TECH);
00354 uves_blank2dot(key_paf,key_dpaf);
00355 fprintf(paf, "%-21s \"%s\" ; # %s\n", key_dpaf,
00356 sval, KEY_HELP_DPR_TECH) ;
00357 }
00358
00359 if (uves_propertylist_contains(plist,KEY_NAME_DPR_CATG)) {
00360 sval = uves_pfits_get_dpr_catg(plist);
00361 strcpy(key_paf,PAF_NAME_DPR_CATG);
00362 uves_blank2dot(key_paf,key_dpaf);
00363 fprintf(paf, "%-21s \"%s\" ; # %s\n", key_dpaf,
00364 sval, KEY_HELP_DPR_CATG) ;
00365 }
00366
00367 strcpy(key_paf,PAF_NAME_PRO_CATG);
00368 uves_blank2dot(key_paf,key_dpaf);
00369 fprintf(paf, "%-21s \"%s\" ; # %s\n", key_dpaf,
00370 pro_catg, KEY_HELP_PRO_CATG) ;
00371
00372 n=cpl_table_get_nrow(qclog);
00373 for(i=0;i<n;i++)
00374 {
00375 strcpy(key_paf,cpl_table_get_string(qclog,"key_name",i));
00376 uves_blank2dot(key_paf,key_name);
00377 strcpy(key_type, cpl_table_get_string(qclog, "key_type",i));
00378 strcpy(key_value, cpl_table_get_string(qclog, "key_value",i));
00379 strcpy(key_help, cpl_table_get_string(qclog, "key_help" , i));
00380
00381 if (strcmp(key_type, "CPL_TYPE_STRING") == 0)
00382 {
00383 fprintf(paf,"%s \"%s\"\n",
00384 key_name, key_value);
00385 }
00386 else
00387 {
00388 fprintf(paf,"%s %s\n",
00389 key_name, key_value);
00390 }
00391 }
00392 fprintf(paf, "\n");
00393 fclose(paf) ;
00394
00395 return 0;
00396
00397 }
00398
00399
00400
00408
00409 cpl_table *
00410 uves_qclog_init(const uves_propertylist *raw_header,
00411 enum uves_chip chip)
00412 {
00413 cpl_table *qclog = NULL;
00414
00415 qclog = cpl_table_new(0);
00416 cpl_table_new_column(qclog,"key_name", CPL_TYPE_STRING);
00417 cpl_table_new_column(qclog,"key_type", CPL_TYPE_STRING);
00418 cpl_table_new_column(qclog,"key_value", CPL_TYPE_STRING);
00419 cpl_table_new_column(qclog,"key_help", CPL_TYPE_STRING);
00420
00421 check_nomsg(uves_qclog_add_string(qclog,
00422 uves_remove_string_prefix(KEY_NAME_QC_DID,"ESO "),
00423 "UVES-1.14",
00424 KEY_NAME_QC_DID,
00425 "%s"));
00426
00427
00428 if (uves_propertylist_contains(raw_header, UVES_INSPATH))
00429 {
00430 check_nomsg(uves_qclog_add_string(qclog,
00431 uves_remove_string_prefix(UVES_INSPATH,"ESO "),
00432 uves_pfits_get_inspath(raw_header),
00433 "Optical path used.",
00434 "%s"));
00435 }
00436 else
00437 {
00438 uves_msg_debug("Missing descriptor %s", UVES_INSPATH);
00439 }
00440
00441 if (uves_propertylist_contains(raw_header, UVES_INSMODE))
00442 {
00443 check_nomsg(uves_qclog_add_string(qclog,
00444 uves_remove_string_prefix(UVES_INSMODE,"ESO "),
00445 uves_pfits_get_insmode(raw_header),
00446 "Instrument mode used.",
00447 "%s"));
00448 }
00449 else
00450 {
00451 uves_msg_debug("Missing descriptor %s", UVES_INSMODE);
00452 }
00453
00454
00455 if (uves_propertylist_contains(raw_header, UVES_GRATNAME(chip)))
00456 {
00457 check_nomsg(uves_qclog_add_string(qclog,
00458 uves_remove_string_prefix(UVES_GRATNAME(chip),"ESO "),
00459 uves_pfits_get_gratname(raw_header,chip),
00460 "Grating common name",
00461 "%s"));
00462 }
00463 else
00464 {
00465 uves_msg_debug("Missing descriptor %s", UVES_GRATNAME(chip));
00466 }
00467
00468
00469 check_nomsg(uves_qclog_add_string(qclog,
00470 uves_remove_string_prefix(UVES_READ_SPEED,"ESO "),
00471 uves_pfits_get_readspeed(raw_header),
00472 "Readout speed",
00473 "%s"));
00474
00475 check_nomsg(uves_qclog_add_int(qclog,
00476 uves_remove_string_prefix(UVES_BINX, "ESO "),
00477 uves_pfits_get_binx(raw_header),
00478 "Binning factor along X",
00479 "%d"));
00480
00481 check_nomsg(uves_qclog_add_int(qclog,
00482 uves_remove_string_prefix(UVES_BINY, "ESO "),
00483 uves_pfits_get_biny(raw_header),
00484 "Binning factor along Y",
00485 "%d"));
00486
00487 if (uves_propertylist_contains(raw_header, UVES_CHIP_NAME(chip)))
00488 {
00489 check_nomsg(uves_qclog_add_string(qclog,
00490 uves_remove_string_prefix(UVES_CHIP_NAME(chip),"ESO "),
00491
00492 uves_pfits_get_chip_name(raw_header, chip),
00493 "Detector chip name",
00494 "%s"));
00495 }
00496 else
00497 {
00498 uves_msg_warning("Missing descriptor %s", UVES_CHIP_NAME(chip));
00499 }
00500
00501 cleanup:
00502 return qclog;
00503 }
00504
00505
00506
00507
00518
00519
00520 int
00521 uves_qclog_add_int(cpl_table* table,
00522 const char* key_name,
00523 const int value,
00524 const char* key_help,
00525 const char* format)
00526 {
00527 int sz = cpl_table_get_nrow(table);
00528 int raw = sz;
00529 char key_value[FILE_NAME_SZ];
00530 char key_type[FILE_NAME_SZ];
00531
00532 sprintf(key_value,format,value);
00533 strcpy(key_type,"CPL_TYPE_INT");
00534
00535 cpl_table_set_size(table,sz+1);
00536
00537 cpl_table_set_string(table,"key_name" ,raw,key_name);
00538 cpl_table_set_string(table,"key_type" ,raw,key_type);
00539 cpl_table_set_string(table,"key_value",raw,key_value);
00540 cpl_table_set_string(table,"key_help" ,raw,key_help);
00541
00542 return 0;
00543
00544 }
00545
00546
00547
00558
00559
00560 int
00561 uves_qclog_add_bool(cpl_table* table,
00562 const char* key_name,
00563 const char value,
00564 const char* key_help,
00565 const char* format)
00566 {
00567 int sz = cpl_table_get_nrow(table);
00568 int raw = sz;
00569 char key_value[FILE_NAME_SZ];
00570 char key_type[FILE_NAME_SZ];
00571
00572 sprintf(key_value,format,value);
00573 strcpy(key_type,"CPL_TYPE_BOOL");
00574
00575 cpl_table_set_size(table,sz+1);
00576
00577 cpl_table_set_string(table,"key_name" ,raw,key_name);
00578 cpl_table_set_string(table,"key_type" ,raw,key_type);
00579 cpl_table_set_string(table,"key_value",raw,key_value);
00580 cpl_table_set_string(table,"key_help" ,raw,key_help);
00581
00582 return 0;
00583
00584 }
00585
00596
00597
00598
00599 int
00600 uves_qclog_add_float(cpl_table* table,
00601 const char* key_name,
00602 const float value,
00603 const char* key_help,
00604 const char* format)
00605 {
00606 int sz = cpl_table_get_nrow(table);
00607 int raw = sz;
00608 char key_value[FILE_NAME_SZ];
00609 char key_type[FILE_NAME_SZ];
00610
00611 sprintf(key_value,format,value);
00612 strcpy(key_type,"CPL_TYPE_FLOAT");
00613
00614 cpl_table_set_size(table,sz+1);
00615
00616 cpl_table_set_string(table,"key_name" ,raw,key_name);
00617 cpl_table_set_string(table,"key_type" ,raw,key_type);
00618 cpl_table_set_string(table,"key_value",raw,key_value);
00619 cpl_table_set_string(table,"key_help" ,raw,key_help);
00620
00621 return 0;
00622
00623 }
00624
00625
00626
00637
00638
00639
00640 int
00641 uves_qclog_add_double(cpl_table* table,
00642 const char* key_name,
00643 const double value,
00644 const char* key_help,
00645 const char* format)
00646 {
00647 int sz = cpl_table_get_nrow(table);
00648 int raw = sz;
00649 char key_value[FILE_NAME_SZ];
00650 char key_type[FILE_NAME_SZ];
00651
00652 sprintf(key_value,format,value);
00653 strcpy(key_type,"CPL_TYPE_DOUBLE");
00654
00655 cpl_table_set_size(table,sz+1);
00656
00657 cpl_table_set_string(table,"key_name" ,raw,key_name);
00658 cpl_table_set_string(table,"key_type" ,raw,key_type);
00659 cpl_table_set_string(table,"key_value",raw,key_value);
00660 cpl_table_set_string(table,"key_help" ,raw,key_help);
00661
00662 return 0;
00663
00664 }
00665
00666
00677
00678
00679
00680
00681
00682 int
00683 uves_qclog_add_string(cpl_table* table,
00684 const char* key_name,
00685 const char* value,
00686 const char* key_help,
00687 const char* format)
00688 {
00689 int sz = cpl_table_get_nrow(table);
00690 int raw = sz;
00691 char key_value[FILE_NAME_SZ];
00692 char key_type[FILE_NAME_SZ];
00693
00694 sprintf(key_value,format,value);
00695 strcpy(key_type,"CPL_TYPE_STRING");
00696
00697 cpl_table_set_size(table,sz+1);
00698
00699 cpl_table_set_string(table,"key_name" ,raw,key_name);
00700 cpl_table_set_string(table,"key_type" ,raw,key_type);
00701 cpl_table_set_string(table,"key_value",raw,key_value);
00702 cpl_table_set_string(table,"key_help" ,raw,key_help);
00703
00704 return 0;
00705
00706 }
00707
00713
00714
00715 int
00716 uves_qclog_delete(cpl_table** table)
00717 {
00718 if (table != NULL) {
00719 cpl_table_delete(*table);
00720 *table = NULL;
00721 }
00722 return 0;
00723 }
00724
00725
00732
00733
00734
00735 int uves_pfits_put_qc(
00736 uves_propertylist * plist,
00737 const cpl_table * qclog)
00738 {
00739 char key_name[FILE_NAME_SZ];
00740 char key_value[FILE_NAME_SZ];
00741 char key_type[FILE_NAME_SZ];
00742 char key_help[FILE_NAME_SZ] ;
00743
00744 int i =0;
00745 int n =0;
00746
00747 if (plist == NULL) {
00748 uves_msg_error("plist=NULL, something strange");
00749 return -1 ;
00750 }
00751
00752
00753 n=cpl_table_get_nrow(qclog);
00754 for(i=0;i<n;i++) {
00755 strcpy(key_name,"ESO ");
00756 strcat(key_name,cpl_table_get_string(qclog,"key_name",i));
00757 strcpy(key_type,cpl_table_get_string(qclog,"key_type",i));
00758 strcpy(key_value,cpl_table_get_string(qclog,"key_value",i));
00759 strcpy(key_help,cpl_table_get_string(qclog,"key_help",i));
00760
00761
00762 if(!uves_propertylist_contains(plist,key_name)) {
00763 if(strcmp(key_type,"CPL_TYPE_STRING") == 0) {
00764 uves_propertylist_append_string(plist, key_name,key_value) ;
00765 uves_propertylist_set_comment(plist, key_name,key_help) ;
00766 } else if(strcmp(key_type,"CPL_TYPE_BOOL") == 0) {
00767
00768 uves_propertylist_append_bool(plist, key_name,atoi(key_value)) ;
00769 uves_propertylist_set_comment(plist, key_name,key_help) ;
00770 } else if(strcmp(key_type,"CPL_TYPE_INT") == 0) {
00771 uves_propertylist_append_int(plist,key_name,atoi(key_value)) ;
00772 uves_propertylist_set_comment(plist, key_name,key_help) ;
00773 } else if(strcmp(key_type,"CPL_TYPE_FLOAT") == 0) {
00774 uves_propertylist_append_float(plist, key_name,(float)atof(key_value)) ;
00775 uves_propertylist_set_comment(plist, key_name,key_help) ;
00776 } else if(strcmp(key_type,"CPL_TYPE_DOUBLE") == 0) {
00777 uves_propertylist_append_double(plist, key_name,atof(key_value)) ;
00778 uves_propertylist_set_comment(plist, key_name,key_help) ;
00779 }
00780 else
00781 {
00782 uves_msg_error("Unrecognized type: %s", key_type);
00783 return -1;
00784 }
00785 }
00786
00787 }
00788
00789 return 0 ;
00790 }
00791
00792
00801
00802 void
00803 uves_qclog_add_sci(cpl_table *qclog,
00804 const uves_propertylist *raw_header,
00805 const cpl_image *raw_image,
00806 double slit,
00807 const cpl_table *info_tbl)
00808 {
00809 char key_name[80];
00810
00811
00812
00813
00814
00815
00816 if (info_tbl != NULL) {
00817 int minorder = cpl_table_get_int(info_tbl, "Order", 0, NULL);
00818 int maxorder = minorder;
00819 int norder;
00820 int i;
00821
00822 for(i = 0; i < cpl_table_get_nrow(info_tbl); i++) {
00823 int order = cpl_table_get_int(info_tbl,"Order", i, NULL);
00824
00825 minorder = uves_min_int(minorder, order);
00826 maxorder = uves_max_int(maxorder, order);
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837 uves_msg_debug("QC-LOG: Order = %d, S/N = %g, Pos = %g, FHWM = %g, RI = %g",
00838 order,
00839 cpl_table_get_double(info_tbl, "ObjSnBlzCentre" ,i ,NULL),
00840 cpl_table_get_double(info_tbl, "ObjPosOnSlit" ,i ,NULL),
00841 cpl_table_get_double(info_tbl, "ObjFwhmAvg" ,i ,NULL),
00842 cpl_table_get_double(info_tbl, "Ripple" ,i ,NULL));
00843
00844
00845 sprintf(key_name, "QC ORD%d OBJ SN", order);
00846 check_nomsg(uves_qclog_add_double(qclog,
00847 key_name,
00848 cpl_table_get_double(info_tbl,"ObjSnBlzCentre",i, NULL),
00849 "Av. S/N at order center",
00850 "%8.4f"));
00851
00852 sprintf(key_name, "QC ORD%d OBJ POS", order);
00853 check_nomsg(uves_qclog_add_double(qclog,
00854 key_name,
00855 cpl_table_get_double(info_tbl,"ObjPosOnSlit",i, NULL),
00856 "Av. OBJ POS at order center",
00857 "%8.4f"));
00858
00859 sprintf(key_name, "QC ORD%d OBJ FWHM", order);
00860 check_nomsg(uves_qclog_add_double(qclog,
00861 key_name,
00862 cpl_table_get_double(info_tbl,"ObjFwhmAvg",i, NULL),
00863 "Av. FWHM on order",
00864 "%8.4f"));
00865
00866 sprintf(key_name, "QC ORD%d OBJ RPLPAR", order);
00867 check_nomsg(uves_qclog_add_double(qclog,
00868 key_name,
00869 cpl_table_get_double(info_tbl,"Ripple",i, NULL),
00870 "Av. relative ripple amplitude",
00871 "%8.4f"));
00872 }
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884 norder = maxorder - minorder + 1;
00885 check_nomsg(uves_qclog_add_int(qclog,
00886 "QC EX NORD",
00887 norder,
00888 "No. of orders extracted",
00889 "%d"));
00890
00891 check_nomsg(uves_qclog_add_int(qclog,
00892 "QC EX XSIZE",
00893 cpl_image_get_size_x(raw_image),
00894 "Input image width (pixels)",
00895 "%d"));
00896
00897 check_nomsg(uves_qclog_add_int(qclog,
00898 "QC EX YSIZE",
00899 uves_round_double(slit),
00900 "Extraction slit (pixels)",
00901 "%d"));
00902 }
00903
00904 {
00905 double barycor, helicor;
00906
00907 check( uves_baryvel(raw_header,
00908 &barycor,
00909 &helicor),
00910 "Could not compute velocity corrections");
00911
00912 check_nomsg(uves_qclog_add_double(qclog,
00913 "QC VRAD BARYCOR",
00914 barycor,
00915 "Barycentric radial velocity correction ",
00916 "%13.6f"));
00917
00918 check_nomsg(uves_qclog_add_double(qclog,
00919 "QC VRAD HELICOR",
00920 helicor,
00921 "Heliocentric radial velocity correction ",
00922 "%13.6f"));
00923 }
00924
00925 cleanup:
00926 return;
00927 }
00928
00929
00939
00940
00941 void
00942 uves_qclog_add_common_wave(const uves_propertylist *raw_header,
00943 enum uves_chip chip,
00944 cpl_table *qclog)
00945 {
00946
00947 check_nomsg(uves_qclog_add_double(qclog,
00948 uves_remove_string_prefix(UVES_SLITWIDTH(chip),"ESO "),
00949 uves_pfits_get_slitwidth(raw_header,chip),
00950 "Slit width (arcsec) [arcsec] (hs).",
00951 "%.1f"));
00952
00953 check_nomsg(uves_qclog_add_double(qclog,
00954 uves_remove_string_prefix(UVES_GRATWLEN(chip),"ESO "),
00955 uves_pfits_get_gratwlen(raw_header,chip),
00956 "Grating central wavelength [nm] (hs).",
00957 "%.1f"));
00958
00959
00960
00961
00962 check_nomsg(uves_qclog_add_double(qclog,
00963 uves_remove_string_prefix(UVES_TEMPCAM(chip),"ESO "),
00964 uves_pfits_get_tempcam(raw_header,chip),
00965 "Average temperature [C] (ho).",
00966 "%.1f"));
00967
00968
00969
00970 cleanup:
00971 return;
00972 }
00973
00974
00982
00983
00984 const char *
00985 uves_qclog_get_qc_name(const char *name,
00986 bool flames, int trace_number)
00987 {
00988 if (flames)
00989 {
00990 return uves_sprintf("QC FIB%d %s", trace_number + 1, name);
00991 }
00992 else
00993 {
00994 return uves_sprintf("QC %s", name);
00995 }
00996 }
00997
00998
01006
01007
01008 int
01009 uves_qclog_dump_common(const uves_propertylist *plist,
01010 enum uves_chip chip,
01011 cpl_table* qclog)
01012
01013 {
01014
01015
01016 int binx=0;
01017 int biny=0;
01018 const char* read_speed=NULL;
01019 const char* dpr_type=NULL;
01020 const char* tpl_id=NULL;
01021 const char* arcfile=NULL;
01022 const char* pro_catg=NULL;
01023 const char* pipefile=NULL;
01024 const char* ins_path=NULL;
01025 const char* ins_mode=NULL;
01026 const char* name_cross=NULL;
01027 const char* name_ccd=NULL;
01028
01029
01030 check_nomsg(binx=uves_pfits_get_binx(plist));
01031 check_nomsg(biny=uves_pfits_get_biny(plist));
01032 check_nomsg(read_speed=uves_pfits_get_readspeed(plist));
01033 check_nomsg(dpr_type=uves_pfits_get_dpr_catg(plist));
01034 check_nomsg(tpl_id=uves_pfits_get_templateid(plist));
01035 check_nomsg(arcfile=uves_pfits_get_arcfile(plist));
01036 check_nomsg(pro_catg=uves_pfits_get_pro_catg(plist));
01037 check_nomsg(pipefile=uves_pfits_get_pipefile(plist));
01038 check_nomsg(ins_path=uves_pfits_get_inspath(plist));
01039 check_nomsg(ins_mode=uves_pfits_get_insmode(plist));
01040 check_nomsg(name_cross=uves_pfits_get_gratname(plist,chip));
01041 check_nomsg(name_ccd=uves_pfits_get_chipid(plist,chip));
01042
01043 ck0_nomsg(uves_qclog_add_string(qclog,
01044 "PRO REC1 PIPE ID",
01045 PACKAGE_VERSION,
01046 "Pipeline (unique) identifier",
01047 "%s"));
01048
01049 ck0_nomsg(uves_qclog_add_string(qclog,
01050 "DPR TYPE",
01051 dpr_type,
01052 "Data Processing Type",
01053 "%s"));
01054
01055 ck0_nomsg(uves_qclog_add_string(qclog,
01056 "TPL ID",
01057 tpl_id,
01058 "Template Id",
01059 "%s"));
01060
01061 ck0_nomsg(uves_qclog_add_string(qclog,
01062 "ARCFILE",
01063 arcfile,
01064 "Archive file name",
01065 "%s"));
01066
01067 ck0_nomsg(uves_qclog_add_string(qclog,
01068 "PRO CATG",
01069 pro_catg,
01070 "Product Category",
01071 "%s"));
01072
01073
01074 ck0_nomsg(uves_qclog_add_string(qclog,
01075 "PIPEFILE",
01076 pipefile,
01077 "Pipeline file name",
01078 "%s"));
01079
01080
01081 ck0_nomsg(uves_qclog_add_string(qclog,
01082 "INS PATH",
01083 ins_path,
01084 "Instrument Path",
01085 "%s"));
01086
01087
01088 ck0_nomsg(uves_qclog_add_string(qclog,
01089 "INS MODE",
01090 ins_mode,
01091 "Instrument mode",
01092 "%s"));
01093
01094 ck0_nomsg(uves_qclog_add_string(qclog,
01095 "NAME CROSS",
01096 name_cross,
01097 "Grating common name",
01098 "%s"));
01099
01100 ck0_nomsg(uves_qclog_add_string(qclog,
01101 "NAME CCD",
01102 name_ccd,
01103 "Detector chip name",
01104 "%s"));
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126 ck0_nomsg(uves_qclog_add_string(qclog,
01127 "DET READ SPEED",
01128 read_speed,
01129 "Readout speed",
01130 "%8.4f"));
01131
01132
01133 ck0_nomsg(uves_qclog_add_double(qclog,
01134 "DET BINX",
01135 binx,
01136 "Binning factor along X",
01137 "%8.4f"));
01138
01139
01140 ck0_nomsg(uves_qclog_add_double(qclog,
01141 "DET BINY",
01142 biny,
01143 "Binning factor along Y",
01144 "%8.4f"));
01145
01146
01147
01148 return 0;
01149 cleanup:
01150 return -1;
01151
01152 }
01153
01154
01155
01163
01164
01165 int
01166 uves_qclog_dump_common_wave(const uves_propertylist *plist,
01167 enum uves_chip chip,
01168 cpl_table* qclog)
01169 {
01170 double slit_width=0;
01171 double temp_cam=0;
01172 double wave_len=0;
01173 check_nomsg(wave_len=uves_pfits_get_gratwlen(plist,chip));
01174 check_nomsg(temp_cam=uves_pfits_get_tempcam(plist,chip));
01175 check_nomsg(slit_width=uves_pfits_get_slitwidth(plist,chip));
01176
01177
01178 ck0_nomsg(uves_qclog_add_double(qclog,
01179 "DET SLIT WIDTH",
01180 slit_width,
01181 "Slit width (arcsec) [arcsec] (hs).",
01182 "%8.4f"));
01183
01184
01185 ck0_nomsg(uves_qclog_add_double(qclog,
01186 "DET WCENT",
01187 wave_len,
01188 "Grating central wavelength [nm] (hs).",
01189 "%8.4f"));
01190
01191
01192 ck0_nomsg(uves_qclog_add_double(qclog,
01193 "TEMP CAM",
01194 temp_cam,
01195 "Average temperature [c] (ho).",
01196 "%8.4f"));
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207 return 0;
01208
01209 cleanup:
01210 return -1;
01211
01212 }
01213