SFF++ library: reading and writing SFF from C++

◆ test_read_file()

void test_read_file ( const bool &  debug)

Definition at line 312 of file sfftest.cc.

References sff::FileHeader::free(), sff::InputWaveform< C >::header(), sff::InputWaveform< C >::last(), sff::WID2::line(), sff::NM_maxdyn, and sff::InputWaveform< C >::series().

Referenced by main().

313 {
314  char infile[]="junk.sff";
315  char outfile[]="junk2.sff";
316  cout << "test reading from file: " << infile << endl
317  << "-----------------------" << endl;
318 
319  {
320  char c;
321  std::cerr << "manipulate " << infile
322  << " - if you like to..." << std::endl;
323  std::cin.get(c);
324  }
325 
326  std::ifstream is(infile);
327  sff::FileHeader fhd(is);
328 
329  std::ofstream os(outfile);
330  os << fhd;
331 
332  if (fhd.hasfree())
333  {
334  cout << "FREE: " << std::endl << fhd.free() << endl;
335  }
336  if (fhd.hassrce())
337  {
338  cout << "SRCEtime: " << fhd.srce().date.timestring() << endl;
339  }
340 
341  bool last=false;
342  while (!last)
343  {
344  sff::InputWaveform<Tseries> iwf(debug);
345  try {
346  is >> iwf;
347  } catch (GSE2::Terror) {
348  cerr << "UUpppsss" << endl;
349  sff::WID2 wid2line(iwf.header().wid2());
350  cerr << wid2line.line();
351  Tseries series(iwf.series());
352  cerr << series.size() << " samples" << endl;
353  throw;
354  }
355  cerr << iwf.header().wid2().line() << endl;
356  last=iwf.last();
357  os << sff::OutputWaveform<Tseries>(iwf.series(),
358  iwf.header(),
360  }
361  cout << "you will find the data in " << outfile << endl;
362 }
aff::Series< double > Tseries
Definition: sfftest.cc:206
std::string line() const
Definition: sffxx.cc:657
Waveform Header.
Definition: sffxx.h:209
scale for maximum dynamic range
Definition: sffxx.h:116
SFF file header elements.
Definition: sffxx.h:232
Here is the call graph for this function:
Here is the caller graph for this function: