Changeset 20037 for trunk/FACT++/src


Ignore:
Timestamp:
01/13/21 20:09:08 (4 years ago)
Author:
tbretz
Message:
Minor fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fixfits.cc

    r20036 r20037  
    4141    str.str("");
    4242
    43     str << setfill(' ') << left;
    44     str << setw(8) << keyword;
     43    str << setfill(' ');
     44    str << left << setw(8) << keyword;
    4545
    4646    str << "= ";
    4747
    48     str << setw(20) << value << " / " << comment;
     48    str << right << setw(20) << value << " / " << comment;
    4949
    5050    str << setw(80-str.str().size()) << ' ';
     
    8686        "fixfits - Fix the header of a none closed raw-data file\n"
    8787        "\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"
    8892        "Usage: fixfits input-file-name [output-file-name]\n"
    8993        "\n"
     
    9599int main(int argc, const char* argv[])
    96100{
    97     Time start;
    98 
    99101    Configuration conf(argv[0]);
    100102    conf.SetPrintUsage(PrintUsage);
     
    114116    cout << "\nReading: " << input_name << endl;
    115117
     118    Time start_read;
     119
    116120    ifstream input(input_name.c_str(), ios_base::binary);
    117121    if (!input)
     
    140144        if (input.eof())
    141145        {
    142             cout << "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;
    143147            return 2;
    144148        }
     
    161165        if (input.eof())
    162166        {
    163             cout << "\nData table header was not closed properly. Aborting." << endl;
     167            cerr << "Data table header was not closed properly. Aborting." << endl;
    164168            return 3;
    165169        }
     
    207211
    208212    input.seekg(num_bytes-4);
    209     cout << "\nFound start of first compressed tile," << endl;
     213    cout << "\nFound start of first compressed tile." << endl;
    210214
    211215    // ------------------------------------------------------------
     
    238242        if (input.eof())
    239243        {
    240             cout << "First tile seems broken unable to recover anything." << endl;
     244            cerr << "First tile seems broken unable to recover anything." << endl;
    241245            return 4;
    242246        }
     
    245249    if (size_t(input.tellg()) != byte_where_tile_start+tile_head.size)
    246250    {
    247         cout << "Discrepancy between tile size and sum of blocks size." << endl;
     251        cerr << "Discrepancy between tile size and sum of blocks size." << endl;
    248252        return 1;
    249253    }
     
    321325    output_heap_end = previous_heap_end;
    322326
     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
    323338    const uint64_t num_cols = num_blocks+1;//+1 because of not-used drs-time-marker column
    324339    const uint64_t output_catalog_end = output_catalog_start + num_tiles*num_cols*16;
     
    327342    const uint64_t theap    = output_catalog_end - output_catalog_start;
    328343
    329     //Now we have everything that we need. Go again through the input file and write the output, fixed file
    330     cout << "Recovery finished!\n\nWriting: " << output_name << endl;
    331 
    332     // ============================================================
    333344
    334345    if (!dry_run)
     
    431442    else
    432443        cout << " ... skipped ...\n";
     444
     445    const auto time_write = Time().UnixTime()-start_write.UnixTime();
    433446
    434447    cout << "File recovered!\n";
     
    452465        cout << "\nOutput file size : " << setw(12) << fs::file_size(output_name);
    453466        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
    456474    cout << "\n\nYou should now:\n";
    457475    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.