Changeset 17166 for trunk/FACT++


Ignore:
Timestamp:
09/15/13 22:08:28 (11 years ago)
Author:
tbretz
Message:
There must be a cast to size -- I missed that last time; fixed a bug in DumpStats which effected files with less rows than columns; added a sanity check for the calculation of the rms.
File:
1 edited

Legend:

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

    r17147 r17166  
    764764
    765765        avg /= num;
    766         rms  = sqrt(rms/num - avg*avg);
     766        rms /= num;
     767        rms += avg*avg;
     768        rms  = rms<0 ? 0 : sqrt(rms);
    767769
    768770        fout << "Min: " << statsIt->min << '\n';
     
    805807
    806808    avg /= numElems;
    807     rms  = sqrt(rms/numElems - avg*avg);
     809    rms /= numElems;
     810    rms -= avg*avg;
     811    rms  = rms<0 ? 0 : sqrt(rms);
     812
    808813
    809814    out << "Avg: " << avg << '\n';
    810815    out << "Rms: " << rms << endl;
    811 
    812816}
    813817
     
    823827    vector<vector<char>> statData;
    824828
    825     const size_t num = limit==0 || GetNumRows()<limit ? GetNumRows() : limit;
     829    const size_t rows = limit==0 || GetNumRows()<limit ? GetNumRows() : limit;
    826830
    827831    for (auto it=cols.begin(); it!=cols.end(); it++)
    828         statData.emplace_back(vector<char>(it->col.size*num*(it->last-it->first+1)));
    829 
    830 #ifdef HAVE_ROOT
     832        statData.emplace_back(vector<char>(it->col.size*rows*(it->last-it->first+1)));
     833
     834#ifdef HAVE_ROOT
     835    size_t num = 0;
     836    for (auto it=cols.begin(); it!=cols.end(); it++)
     837        num += it->last-it->first+1;
     838
    831839    vector<Double_t> data(num+1);
    832840#endif
     
    10991107        ("%,%",         vars<string>(),         "Format for the output (currently not available in root-mode)")
    11001108        ("force",       po_switch(),            "Force reading the fits file even if END key is missing")
    1101         ("first",       var<size_t>(0),        "First number of row to read")
    1102         ("limit",       var<size_t>(0),        "Limit for the maximum number of rows to read (0=unlimited)")
     1109        ("first",       var<size_t>(size_t(0)), "First number of row to read")
     1110        ("limit",       var<size_t>(size_t(0)), "Limit for the maximum number of rows to read (0=unlimited)")
    11031111        ("tablename,t", var<string>(""),        "Name of the table to open. If not specified, first binary table is opened")
    11041112#ifdef HAVE_ROOT
Note: See TracChangeset for help on using the changeset viewer.