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

◆ test_write_file()

void test_write_file ( )

Definition at line 266 of file sfftest.cc.

References sff::WID2::channel, sff::SRCE::cx, sff::INFO::cx, sff::SRCE::cy, sff::SRCE::cz, sff::WID2::dt, sff::WID2::instype, sff::FREE::lines, sff::NM_ifneeded, sff::NM_maxdyn, sff::WID2::nsamples, sff::WID2::station, and sff::SRCE::type.

Referenced by main().

267 {
268  char filename[]="junk.sff";
269  cout << "test writing to file: " << filename << endl
270  << "---------------------" << endl;
271 
272  const int msamp=1000;
273  Tseries series(msamp);
274  for (int i=series.first(); i<=series.last(); i++)
275  { series(i)=10.*sin(3.1415926*i*5/msamp); }
276 
277  sff::SRCE mysrce;
278  mysrce.cx=1.;
279  mysrce.cy=2.;
280  mysrce.cz=3.;
281  mysrce.type="Quelle";
282 
283  sff::INFO myinfo;
284 
285  sff::FREE myfree;
286  myfree.lines.push_back("auch ein text");
287 
288  sff::WID2 mywid2;
289  mywid2.station="BFO";
290  mywid2.channel="UGZ";
291  mywid2.instype="ET-19";
292  mywid2.nsamples=2048;
293  mywid2.dt=10.;
294 
295  sff::FileHeader fhd(mysrce,myfree);
296  std::ofstream os(filename);
297  os << fhd;
298  {
299  sff::TraceHeader hd(mywid2,myinfo,myfree);
300  os << sff::OutputWaveform<Tseries>(series, hd, sff::NM_maxdyn);
301  }
302  {
303  myinfo.cx=10.;
304  sff::TraceHeader hd(mywid2,myinfo,myfree,true);
305  os << sff::OutputWaveform<Tseries>(series, hd, sff::NM_ifneeded);
306  }
307  cout << "you will find the data in " << filename << endl;
308 }
SFF trace header elements.
Definition: sffxx.h:282
aff::Series< double > Tseries
Definition: sfftest.cc:206
Tlines lines
Definition: sffxx.h:163
double cz
Definition: sffxx.h:176
std::string station
Station code.
Definition: sffxx.h:216
std::string instype
instrument type
Definition: sffxx.h:223
double cx
Definition: sffxx.h:202
std::string channel
FDSN channel code.
Definition: sffxx.h:217
int nsamples
number of samples
Definition: sffxx.h:219
std::string type
Definition: sffxx.h:173
scale if largest amplitude larger than limit
Definition: sffxx.h:117
Waveform Header.
Definition: sffxx.h:209
double cx
Definition: sffxx.h:176
double cy
Definition: sffxx.h:176
double dt
sampling interval (sec)
Definition: sffxx.h:220
scale for maximum dynamic range
Definition: sffxx.h:116
SFF file header elements.
Definition: sffxx.h:232
Here is the caller graph for this function: