FACT++  1.0
void FitsDumper::DumpMinMax ( ostream &  fout,
const vector< MyColumn > &  cols,
size_t  first,
size_t  limit,
bool  fNoZeroPlease 
)
private

Definition at line 732 of file fitsdump.cc.

References GetDouble(), zfits::GetNumRows(), fits::GetRow(), and i.

Referenced by Exec().

733 {
734  vector<minMaxStruct> statData(cols.size());
735 
736  // Loop over all columns in our list of requested columns
737  const size_t last = limit ? first + limit : size_t(-1);
738 
739  while (GetRow(first++))
740  {
741  const size_t row = GetRow();
742  if (row==GetNumRows() || row==last)
743  break;
744 
745  auto statsIt = statData.begin();
746 
747  for (auto it=cols.begin(); it!=cols.end(); it++, statsIt++)
748  {
749  if ((it->name=="UnixTimeUTC" || it->name=="PCTime") && it->first==0 && it->last==1)
750  {
751  const uint32_t *val = reinterpret_cast<const uint32_t*>(it->ptr);
752  if (fNoZeroPlease && val[0]==0 && val[1]==0)
753  continue;
754 
755  statsIt->add(Time(val[0], val[1]).Mjd());
756  continue;
757  }
758 
759  for (uint32_t i=it->first; i<=it->last; i++)
760  {
761  const double cValue = GetDouble(*it, i);
762 
763  if (fNoZeroPlease && cValue == 0)
764  continue;
765 
766  statsIt->add(cValue);
767  }
768  }
769  }
770 
771  // okay. So now I've got ALL the data, loaded.
772  // let's do the summing and averaging in a safe way (i.e. avoid overflow
773  // of variables as much as possible)
774  auto statsIt = statData.begin();
775  for (auto it=cols.begin(); it!=cols.end(); it++, statsIt++)
776  {
777  fout << "\n[" << it->name << ':' << it->first;
778  if (it->first!=it->last)
779  fout << ':' << it->last;
780  fout << "]\n";
781 
782  if (statsIt->numValues == 0)
783  {
784  fout << "Min: -\nMax: -\nAvg: -\nRms: -" << endl;
785  continue;
786  }
787 
788  const long &num = statsIt->numValues;
789 
790  long double &avg = statsIt->average;
791  long double &rms = statsIt->squared;
792 
793  avg /= num;
794  rms /= num;
795  rms += avg*avg;
796  rms = rms<0 ? 0 : sqrt(rms);
797 
798  fout << "Min: " << statsIt->min << '\n';
799  fout << "Max: " << statsIt->max << '\n';
800  fout << "Avg: " << avg << '\n';
801  fout << "Rms: " << rms << endl;
802  }
803 }
int i
Definition: db_dim_client.c:21
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
size_t GetNumRows() const
Definition: zfits.h:57
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
size_t GetRow() const
Definition: fits.h:1019
double GetDouble(const MyColumn &, size_t) const
Definition: fitsdump.cc:275

+ Here is the call graph for this function:

+ Here is the caller graph for this function: