- Timestamp:
- 01/13/21 23:39:45 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fixfits.cc
r20037 r20038 16 16 #include <boost/filesystem.hpp> 17 17 18 #include " FITS.h"18 #include "factfits.h" 19 19 #include "Time.h" 20 20 #include "Configuration.h" … … 342 342 const uint64_t theap = output_catalog_end - output_catalog_start; 343 343 344 map<string, size_t> header; 344 345 345 346 if (!dry_run) … … 374 375 if (!rc) 375 376 return 5; 377 378 header[string(buffer, 8)] = size_t(output.tellp())+10; 376 379 } 377 380 … … 472 475 cout << "\nExecution [write] : " << time_write << "s, " << fs::file_size(output_name)/1024./1024/time_write << "Mb/s"; 473 476 474 cout << "\n\nYou should now:\n"; 475 cout << "- update TSTOPI and TSTOPF using \"fitsdump -c UnixTimeUTC --minmax --nozero\" and then fv\n"; 476 cout << "- update DATE-END using TSTOP given to the MjDtoISO program in ~fact_arc/ingestScripts and then fv again\n"; 477 cout << "- update the checksum of the file with \"fchecksum update+ <filename>\"\n" << endl; 477 if (0) 478 return 0; 479 480 factfits fits(output_name); 481 482 cout << "\nNew file contains " << fits.GetNumRows() << " events."; 483 cout << "\nChecking for raw data contents." << endl; 484 485 if (fits.GetStr("TELESCOP")!="FACT" || fits.GetStr("ORIGIN")!="FACT" || fits.GetStr("PACKAGE")!="FACT++" || fits.GetStr("EXTNAME")!="Events" || !fits.HasKey("DRSCALIB")) 486 { 487 cerr << "Header incomplete." << endl; 488 return 0; 489 } 490 491 if (!fits.HasColumn("UnixTimeUTC")) 492 { 493 cerr << "Column UnixTimeUTC missing." << endl; 494 return 0; 495 } 496 497 cout << "\nRaw data file detected."; 498 cout << "\nUpdating run-end with last event time." << endl; 499 500 vector<uint32_t> utime(2); 501 fits.SetVecAddress("UnixTimeUTC", utime); 502 fits.GetRow(fits.GetNumRows()-1); 503 504 const Time stop(utime[0], utime[1]); 505 506 const uint32_t tstopi = floor(stop.UnixDate()); 507 const double tstopf = fmod(stop.UnixDate(), 1); 508 509 fits.close(); 510 511 cout << setfill(' '); 512 cout << "\nTSTOPI = " << right << setw(20) << tstopi << " / Time when last event received (integral part)"; 513 cout << "\nTSTOPF = " << right << setw(20) << tstopf << " / Time when last event received (fractional part)"; 514 cout << "\nDATE-END= '" << stop.Iso() << "' / Time when last event received"; 515 516 fstream fout(output_name);//, ios::binary); 517 fout << setfill(' '); 518 519 fout.seekp(header["DATE-END"], ios::beg); 520 //fout.seekg(header["DATE-END"], ios::beg); 521 fout << left << setw(20) << string("'" + stop.Iso() + "'") << " / Time when last event received"; 522 523 fout.seekp(header["TSTOPI "], ios::beg); 524 //fout.seekg(header["TSTOPI "], ios::beg); 525 fout << right << setw(20) << tstopi; 526 527 fout.seekp(header["TSTOPF "], ios::beg); 528 //fout.seekg(header["TSTOPF "], ios::beg); 529 fout << right << setw(20) << tstopf; 530 fout.flush(); 531 532 cout << "\nUpdating checksum." << endl; 533 534 factfits fits2(output_name); 535 fout.seekp(header["CHECKSUM"], ios::beg); 536 //fout.seekg(header["CHECKSUM"], ios::beg); 537 fout << left << setw(20) << string("'" + fits2.GetChecksum().str() + "'"); 538 539 fout.close(); 540 fits2.close(); 541 542 factfits fits3(output_name); 543 if (!fits3.IsHeaderOk() || !fits3.IsFileOk()) 544 { 545 cerr << "\nFAILED: The checksum is still invalid! :(" << endl; 546 return 7; 547 } 548 549 cout << "\nFile header successfully updated!\n" << endl; 478 550 479 551 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.