FACT++  1.0
int main ( int  argc,
const char **  argv 
)

Definition at line 397 of file zfits.cc.

References Compress(), Decompress(), Configuration::DoParse(), Configuration::Get(), Configuration::Has(), PrintUsage(), ReplaceExt(), Configuration::SetPrintUsage(), and SetupConfiguration().

398 {
399  Configuration conf(argv[0]);
400  conf.SetPrintUsage(PrintUsage);
401  SetupConfiguration(conf);
402 
403  if (!conf.DoParse(argc, argv))
404  return 127;
405 
406  const bool decomp = conf.Get<bool>("decompress");
407 
408  const string ifile = conf.Get<string>("in");
409  const string ofile = conf.Has("out") ? conf.Get<string>("out") : ReplaceExt(ifile, decomp);
410 
411  return decomp ? Decompress(ifile, ofile) : Compress(ifile, ofile);
412 
413  /*
414  // reading and writing files which just contain the binary data
415  // For simplicity I assume ROI=300
416 
417  ifstream finx( "20130117_082.fits.pu");
418  ofstream foutx("20130117_082.fits.puz");
419 
420  while (1)
421  {
422  string str;
423  str.resize(432000*2);
424 
425  finx.read((char*)str.c_str(), 432000*2);
426  if (!finx)
427  break;
428 
429  // Preprocess the data, e.g. subtract median pixelwise
430  for (int i=0; i<1440; i++)
431  {
432  int16_t *chunk = (int16_t*)str.c_str()+i*300;
433  sort(chunk, chunk+300);
434 
435  int16_t med = chunk[149];
436 
437  for (int j=0; j<300; j++)
438  chunk[j] -= med;
439  }
440 
441  // do huffman encoding on shorts
442  string buf;
443  int len = huffmans_encode(buf, (uint16_t*)str.c_str(), 432000);
444 
445  // if the result is smaller than the original data write
446  // the result, otherwise the original data
447  if (buf.size()<432000*2)
448  foutx.write(buf.c_str(), buf.size());
449  else
450  foutx.write(str.c_str(), 432000);
451  }
452 
453  return 0;
454  */
455 }
void SetupConfiguration(Configuration &conf)
Definition: zfits.cc:16
int Compress(const string &ifile, const string &ofile)
Definition: zfits.cc:66
void PrintUsage()
Definition: zfits.cc:34
string ReplaceExt(const string &name, bool decomp)
Definition: zfits.cc:57
Commandline parsing, resource file parsing and database access.
Definition: Configuration.h:9
int Decompress(const string &ifile, const string &ofile)
Definition: zfits.cc:246

+ Here is the call graph for this function: