Changeset 20037 for trunk/FACT++
- Timestamp:
- 01/13/21 20:09:08 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fixfits.cc
r20036 r20037 41 41 str.str(""); 42 42 43 str << setfill(' ') << left;44 str << setw(8) << keyword;43 str << setfill(' '); 44 str << left << setw(8) << keyword; 45 45 46 46 str << "= "; 47 47 48 str << setw(20) << value << " / " << comment;48 str << right << setw(20) << value << " / " << comment; 49 49 50 50 str << setw(80-str.str().size()) << ' '; … … 86 86 "fixfits - Fix the header of a none closed raw-data file\n" 87 87 "\n" 88 "The goal of this tool is to touch the data as less as possible. " 89 "This, however, might result in a few more bytes being lost than " 90 "strictly necessary.\n" 91 "\n" 88 92 "Usage: fixfits input-file-name [output-file-name]\n" 89 93 "\n" … … 95 99 int main(int argc, const char* argv[]) 96 100 { 97 Time start;98 99 101 Configuration conf(argv[0]); 100 102 conf.SetPrintUsage(PrintUsage); … … 114 116 cout << "\nReading: " << input_name << endl; 115 117 118 Time start_read; 119 116 120 ifstream input(input_name.c_str(), ios_base::binary); 117 121 if (!input) … … 140 144 if (input.eof()) 141 145 { 142 c out<< "Reached end-of-file but could not find start of data table." << endl;146 cerr << "Reached end-of-file but could not find start of data table." << endl; 143 147 return 2; 144 148 } … … 161 165 if (input.eof()) 162 166 { 163 c out << "\nData table header was not closed properly. Aborting." << endl;167 cerr << "Data table header was not closed properly. Aborting." << endl; 164 168 return 3; 165 169 } … … 207 211 208 212 input.seekg(num_bytes-4); 209 cout << "\nFound start of first compressed tile ," << endl;213 cout << "\nFound start of first compressed tile." << endl; 210 214 211 215 // ------------------------------------------------------------ … … 238 242 if (input.eof()) 239 243 { 240 c out<< "First tile seems broken unable to recover anything." << endl;244 cerr << "First tile seems broken unable to recover anything." << endl; 241 245 return 4; 242 246 } … … 245 249 if (size_t(input.tellg()) != byte_where_tile_start+tile_head.size) 246 250 { 247 c out<< "Discrepancy between tile size and sum of blocks size." << endl;251 cerr << "Discrepancy between tile size and sum of blocks size." << endl; 248 252 return 1; 249 253 } … … 321 325 output_heap_end = previous_heap_end; 322 326 327 cout << "Recovery finished!\n"; 328 329 const auto time_read = Time().UnixTime()-start_read.UnixTime(); 330 331 // ============================================================ 332 //Now we have everything that we need. Go again through the input file and write the output, fixed file 333 334 cout << "\nWriting: " << output_name << endl; 335 336 Time start_write; 337 323 338 const uint64_t num_cols = num_blocks+1;//+1 because of not-used drs-time-marker column 324 339 const uint64_t output_catalog_end = output_catalog_start + num_tiles*num_cols*16; … … 327 342 const uint64_t theap = output_catalog_end - output_catalog_start; 328 343 329 //Now we have everything that we need. Go again through the input file and write the output, fixed file330 cout << "Recovery finished!\n\nWriting: " << output_name << endl;331 332 // ============================================================333 344 334 345 if (!dry_run) … … 431 442 else 432 443 cout << " ... skipped ...\n"; 444 445 const auto time_write = Time().UnixTime()-start_write.UnixTime(); 433 446 434 447 cout << "File recovered!\n"; … … 452 465 cout << "\nOutput file size : " << setw(12) << fs::file_size(output_name); 453 466 cout << "\nLost bytes : " << setw(12) << fs::file_size(input_name)-fs::file_size(output_name); 454 cout << "\nLost fraction : " << setw(12) << 1.-fs::file_size(output_name)/fs::file_size(input_name); 455 } 467 cout << "\nLost fraction : " << setw(12) << 1-double(fs::file_size(output_name))/fs::file_size(input_name); 468 } 469 cout << "\n"; 470 471 cout << "\nExecution [read] : " << time_read << "s, " << fs::file_size(input_name)/1024./1024/time_read << "Mb/s"; 472 cout << "\nExecution [write] : " << time_write << "s, " << fs::file_size(output_name)/1024./1024/time_write << "Mb/s"; 473 456 474 cout << "\n\nYou should now:\n"; 457 475 cout << "- update TSTOPI and TSTOPF using \"fitsdump -c UnixTimeUTC --minmax --nozero\" and then fv\n";
Note:
See TracChangeset
for help on using the changeset viewer.