72 "usage: sutest [-v] [-D] [-file filename] [-stream filename]" "\n" 73 " [-scale s] [-coordinate v] [-write filename]" "\n" 74 " [-imodifier m] [-omodifier m]" "\n" 75 " or: sutest --help|-h" "\n" 84 "-D switch on DEBUG mode\n" 85 "-file filename scan file, using elementary SU structs and\n" 87 " input modifiers are effective\n" 88 "-stream filename use isustream to read an SU data file and\n" 90 " input modifiers are effective\n" 91 "-write filename write a synthetic SU data file containing\n" 93 " output modifiers are effective\n" 94 "-scale s test the ScalCoo struct, which is used to\n" 95 " hold scalco and scalel header values\n" 96 " input and output modifiers are effective\n" 97 "-coordinate v test modules ScalCoo, Coordinates, and\n" 99 " input and output modifiers are effective\n" 100 "-imodifier m set input stream modifiers\n" 101 "-omodifier m set output stream modifiers\n" 103 "If no option is selected, the program reports the size of the\n" 104 "TraceHeaderStruct and terminates.\n" 108 using namespace tfxx::cmdline;
109 static Declare options[]=
118 {
"file",arg_yes,
"-"},
120 {
"stream",arg_yes,
"-"},
122 {
"scale",arg_yes,
"-"},
124 {
"coordinate",arg_yes,
"-"},
126 {
"write",arg_yes,
"-"},
128 {
"imodifier",arg_yes,
""},
130 {
"omodifier",arg_yes,
""},
137 cerr << usage_text << endl;
142 Commandline cmdline(iargc, argv, options);
145 if (cmdline.optset(0))
147 cerr << usage_text << endl;
148 cerr << help_text << endl;
154 opt.
debug=cmdline.optset(2);
160 opt.
scale=cmdline.int_arg(5);
168 cout <<
"size of TraceHeaderStruct " <<
175 cout <<
"Write test file\n" 176 <<
"---------------" << endl;
179 cout <<
"write to file " << opt.
ofilename << endl;
192 ::sff::verbose(cout, srce);
197 for (
int itrace=0; itrace<mtrace; ++itrace)
199 cout << endl <<
"trace #" << itrace << endl;
200 wid2.date=srce.date+libtime::double2time(wid2.dt*msamp*itrace);
202 info.cx=1.*(itrace+1);
204 ::sff::verbose(cout, wid2);
205 ::sff::verbose(cout, info);
207 for (
int isamp=0; isamp<msamp; ++isamp)
209 series(isamp)=std::sin(6*3.14159265358*
210 ((static_cast<double>(isamp)/msamp)
211 +(static_cast<double>(itrace)/mtrace)));
221 std::ifstream ifs(opt.
filename.c_str(),
231 cout <<
"trid: " << header.Mheader.trid << endl;
232 cout <<
"ns: " << header.Mheader.ns << endl;
233 cout <<
"delrt: " << header.Mheader.delrt << endl;
234 cout <<
"scalco: " << header.Mheader.scalco << endl;
235 cout <<
"scalel: " << header.Mheader.scalel << endl;
237 char *ipointer=
reinterpret_cast<char *
>(series.pointer());
238 DATRW_Xassert(ifs.read(ipointer, series.size()*
sizeof(float)),
239 "ERROR: reading SU samples",
241 cout <<
"read " << series.size() <<
" samples" 242 <<
" which are " << series.size()*
sizeof(float)
243 <<
" characters" << endl;
244 cout << header.wid2().line() << endl;
245 cout <<
"srce date: " << header.dateofshot().timestring() << endl;
246 cout <<
"delay: " << header.delay().timestring() << endl;
247 cout <<
"time of data: " << header.dateoffirstsample().timestring() << endl;
248 cout << header.info().line() << endl;
249 cout << header.srce().line() << endl;
254 cout <<
"CAUGHT EXCEPTION" << endl;
272 ::sff::verbose(cout, srce);
276 cout << endl <<
"trace #" << itrace << endl;
280 ::sff::verbose(cout, wid2);
281 ::sff::verbose(cout, info);
283 l=series.l()>l ? l:series.l();
284 for (
int i=series.f(); i<=l; ++i)
286 cout <<
"s("<<i<<
")="<<series(i)<<
" ";
290 l=series.f()>l ? series.f():l;
291 for (
int i=l; i<=series.l(); ++i)
293 cout <<
"s("<<i<<
")="<<series(i)<<
" ";
308 cout <<
"scale value: " << opt.
scale << endl;
310 co.set(opt.
scale, 34500);
311 cout <<
"scale in ScalCoo: " << co.scale << endl;
312 cout <<
"coordinate in ScalCoo: " << co.coo << endl;
313 cout <<
"value from ScalCoo: " << co.value() << endl;
314 cout <<
"power from ScalCoo: " << co.power() << endl;
316 cout <<
"scale in ScalCoo after adjust: " << co.scale << endl;
317 cout <<
"coordinate in ScalCoo: " << co.coo << endl;
318 cout <<
"value from ScalCoo: " << co.value() << endl;
325 cout <<
"Test su coordinate manager\n" 326 <<
"==========================\n\n";
332 cout <<
"Test module ::datrw::su::ScalCoo\n" 333 <<
"--------------------------------\n" << endl;
334 cout <<
"check det function\n";
336 for (
int i=-4; i<5; ++i)
340 CODE( co.set(-std::pow(10, -i), 1); )
344 CODE( co.set(std::pow(10, i), 1); )
346 cout <<
"i: " << i <<
"; co.scale " << co.scale
347 <<
"; co.coo " << co.coo
348 <<
"; co.power() " << co.power()
349 <<
"; co.value() " << co.value()
362 CODE( co.scaletopower(-3); )
370 CODE( co.scaletopower(1); )
378 CODE( co.scaletopower(3); )
403 CODE( co.adjustscale(); )
421 <<
"Test module ::datrw::su::Coordinates\n" 422 <<
"------------------------------------\n" << endl;
427 <<
" sx: " << coo.sx.value()
428 <<
" sy: " << coo.sy.value()
429 <<
" sdepth: " << coo.sdepth.value()
430 <<
" gx: " << coo.gy.value()
431 <<
" gy: " << coo.gy.value()
432 <<
" gelev: " << coo.gelev.value()
434 cout <<
"call equalizescaling()" << endl;
435 coo.equalizescaling();
437 <<
" sx: " << coo.sx.value()
438 <<
" sy: " << coo.sy.value()
439 <<
" sdepth: " << coo.sdepth.value()
440 <<
" gx: " << coo.gy.value()
441 <<
" gy: " << coo.gy.value()
442 <<
" gelev: " << coo.gelev.value()
446 <<
"Test module ::datrw::su::SUheader\n" 447 <<
"---------------------------------\n" << endl;
451 cout <<
"SRCE data passed to su header:" << endl;
452 ::sff::verbose(cout, srce);
456 cout <<
"INFO data passed to su header:" << endl;
457 ::sff::verbose(cout, info);
459 cout <<
"INFO data returned from su header:" << endl;
460 ::sff::verbose(cout, suh.info());
full set of coordinates.This struct holds a full set of coordinates for a SEG-Y trace header...
aff::Series< float > Tfseries
scaled coordinate.This struct holds one coordinate together with a scale value. It provides functions...
bool bestrict
if true: strictly use header definition by SeismicUnix source
static const std::ios_base::openmode openmode
short scalco
preferred scalco value
options::SUHeaderControl inputmodifiers(const std::string &modifier, const bool &debug)
evaluate input stream format modifiers
#define DATRW_Xassert(C, M, E)
Check an assertion and report by throwing an exception.
static const std::ios_base::openmode openmode
class to read SeismicUnix data
options::SUHeaderControl outputmodifiers(const std::string &modifier, const bool &debug)
evaluate output stream format modifiers