FACT++  1.0
void FitsDumper::Dump ( ostream &  fout,
const vector< string > &  format,
const vector< MyColumn > &  cols,
const string &  ,
size_t  first,
size_t  limit,
const string &  filename 
)
private

Display the selected columns values VS time.

Perform the actual dump, based on the current parameters.

Definition at line 413 of file fitsdump.cc.

References data, fFilename, Format(), GetDouble(), fits::GetKeys(), zfits::GetNumRows(), fits::GetRow(), i, and ListKeywords().

Referenced by Exec(), and Format().

415 {
416  const fits::Table::Keys &fKeyMap = GetKeys();
417 
418 #ifdef HAVE_ROOT
419  TFormula select;
420  if (!filter.empty() && select.Compile(filter.c_str()))
421  throw runtime_error("Syntax Error: TFormula::Compile failed for '"+filter+"'");
422 #endif
423 
424  fout << "## --------------------------------------------------------------------------\n";
425  fout << "## Fits file: \t" << fFilename << '\n';
426  if (filename!="-")
427  fout << "## File: \t" << filename << '\n';
428  fout << "## Table: \t" << fKeyMap.find("EXTNAME")->second.value << '\n';
429  fout << "## NumRows: \t" << GetNumRows() << '\n';
430  fout << "## Comment: \t" << ((fKeyMap.find("COMMENT") != fKeyMap.end()) ? fKeyMap.find("COMMENT")->second.value : "") << '\n';
431 #ifdef HAVE_ROOT
432  if (!filter.empty())
433  fout << "## Selection: \t" << select.GetExpFormula() << '\n';
434 #endif
435  fout << "## --------------------------------------------------------------------------\n";
436  ListKeywords(fout);
437  fout << "## --------------------------------------------------------------------------\n";
438  fout << "#\n";
439 
440  size_t num = 0;
441  for (auto it=cols.begin(); it!=cols.end(); it++)
442  {
443  fout << "# " << it->name;
444 
445  if (it->first==it->last)
446  {
447  if (it->first!=0)
448  fout << "[" << it->first << "]";
449  }
450  else
451  fout << "[" << it->first << ":" << it->last << "]";
452 
453  if (!it->col.unit.empty())
454  fout << ": " << it->col.unit;
455  fout << '\n';
456 
457  num += it->last-it->first+1;
458  }
459  fout << "#" << endl;
460 
461  // -----------------------------------------------------------------
462 
463 #ifdef HAVE_ROOT
464  vector<Double_t> data(num+1);
465 #endif
466 
467  const size_t last = limit ? first + limit : size_t(-1);
468 
469  while (GetRow(first++))
470  {
471  const size_t row = GetRow();
472  if (row==GetNumRows() || row==last)
473  break;
474 
475  size_t p = 0;
476 
477 #ifdef HAVE_ROOT
478  data[p++] = first-1;
479 #endif
480 
481  ostringstream sout;
482  sout.precision(fout.precision());
483  sout.flags(fout.flags());
484 
485  uint32_t col = 0;
486  for (auto it=cols.begin(); it!=cols.end(); it++, col++)
487  {
488  string msg;
489  for (uint32_t i=it->first; i<=it->last; i++, p++)
490  {
491  if (col<format.size())
492  sout << Format("%"+format[col], *it, i) << " ";
493  else
494  {
495  switch (it->col.type)
496  {
497  case 'A':
498  msg += reinterpret_cast<const char*>(it->ptr)[i];
499  break;
500  case 'B':
501  sout << (unsigned int)reinterpret_cast<const unsigned char*>(it->ptr)[i] << " ";
502  break;
503  case 'L':
504  sout << reinterpret_cast<const bool*>(it->ptr)[i] << " ";
505  break;
506  case 'I':
507  sout << reinterpret_cast<const int16_t*>(it->ptr)[i] << " ";
508  break;
509  case 'J':
510  sout << reinterpret_cast<const int32_t*>(it->ptr)[i] << " ";
511  break;
512  case 'K':
513  sout << reinterpret_cast<const int64_t*>(it->ptr)[i] << " ";
514  break;
515  case 'E':
516  sout << reinterpret_cast<const float*>(it->ptr)[i] << " ";
517  break;
518  case 'D':
519  sout << reinterpret_cast<const double*>(it->ptr)[i] << " ";
520  break;
521  default:
522  ;
523  }
524  }
525 #ifdef HAVE_ROOT
526  if (!filter.empty())
527  data[p] = GetDouble(*it, i);
528 #endif
529  }
530 
531  if (it->col.type=='A')
532  sout << "'" << msg.c_str() << "' ";
533  }
534 #ifdef HAVE_ROOT
535  if (!filter.empty() && select.EvalPar(0, data.data())<0.5)
536  continue;
537 #endif
538  fout << sout.str() << endl;
539  }
540 }
string fFilename
Definition: fitsdump.cc:67
int i
Definition: db_dim_client.c:21
size_t GetNumRows() const
Definition: zfits.h:57
string Format(const string &fmt, const double &val) const
Definition: fitsdump.cc:372
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
size_t GetRow() const
Definition: fits.h:1019
const Table::Keys & GetKeys() const
Definition: fits.h:1006
void ListKeywords(ostream &)
Definition: fitsdump.cc:147
std::map< std::string, Entry > Keys
Definition: fits.h:112
float data[4 *1440]
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: