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