Commit 04d632f6 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

trace time delay now is properly propagated

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 3838
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 308c3fff
......@@ -30,11 +30,12 @@
*
* REVISIONS and CHANGES
* - 11/04/2006 V1.0 Thomas Forbriger
* - 01/04/2011 V1.1 do not clear Mhassrce upon writing the file header
*
* ============================================================================
*/
#define DATRW_DATWRITE_CC_VERSION \
"DATRW_DATWRITE_CC V1.0"
"DATRW_DATWRITE_CC V1.1"
#define DATRW_DATWRITE_CC_CVSID \
"$Id$"
......@@ -155,7 +156,13 @@ namespace datrw {
writefileheader();
}
Mheaderflushed=true;
Msrceset=false;
/*
* 1.4.2011: I see no reason to clear Msrceset here. Keeping this flag
* provides the trace writing functions with information on the source
* which relates to the trace. This is of particular value for writer like
* osustream, which have to calculate delay times.
*/
// Msrceset=false;
Mfreeset=false;
}
......
......@@ -382,6 +382,16 @@ namespace datrw {
//! set time values
void SUheader::settimes()
{
DATRW_debug(Mdebug,
"ERROR SUheader::settimes: ",
"set times: Mhaswid2 " << Mhaswid2
<< " Mhassrce " << Mhassrce);
DATRW_debug(Mdebug && Mhaswid2,
"ERROR SUheader::settimes: ",
"WID2 time: " << Mwid2date.timestring());
DATRW_debug(Mdebug && Mhassrce,
"ERROR SUheader::settimes: ",
"SRCE time: " << Msrcedate.timestring());
DATRW_assert(Mhaswid2 || Mhassrce,
"ERROR SUheader::settimes: "
"function called at wrong instance");
......
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 19/11/2010 V1.0 Thomas Forbriger
* - 29/03/2011 V1.1 test of ScalCoo::power()
* - 01/04/2011 V1.2 write test
*
* ============================================================================
*/
#define SUTEST_VERSION \
"SUTEST V1.0 test Seismic Unix reading module"
"SUTEST V1.2 test Seismic Unix reading module"
#define SUTEST_CVSID \
"$Id$"
......@@ -51,8 +52,8 @@ using std::endl;
struct Options {
bool verbose, debug, streamfile, scanfile, doscaletest;
bool docootest;
std::string filename, sfilename;
bool docootest, dowritetest;
std::string filename, sfilename, ofilename;
short scale;
double coordinate;
}; // struct Options
......@@ -67,7 +68,7 @@ int main(int iargc, char* argv[])
{
SUTEST_VERSION "\n"
"usage: sutest [-v] [-D] [-file filename] [-stream filename]" "\n"
" [-scale s] [-coordinate v]" "\n"
" [-scale s] [-coordinate v] [-write filename]" "\n"
" or: sutest --help|-h" "\n"
};
......@@ -95,6 +96,8 @@ int main(int iargc, char* argv[])
{"scale",arg_yes,"-"},
// 6: test coordinate scaling for coordinate value
{"coordinate",arg_yes,"-"},
// 7: write a test file
{"write",arg_yes,"-"},
{NULL}
};
......@@ -127,12 +130,60 @@ int main(int iargc, char* argv[])
opt.scale=cmdline.int_arg(5);
opt.docootest=cmdline.optset(6);
opt.coordinate=cmdline.double_arg(6);
opt.dowritetest=cmdline.optset(7);
opt.ofilename=cmdline.string_arg(7);
cout << "size of TraceHeaderStruct " <<
sizeof(datrw::su::TraceHeaderStruct) << endl;
/*----------------------------------------------------------------------*/
if (opt.dowritetest)
{
cout << "Write test file\n"
<< "---------------" << endl;
if (opt.verbose)
{
cout << "write to file " << opt.ofilename << endl;
}
std::ofstream ofs(opt.ofilename.c_str(),
datrw::osustream::openmode);
datrw::osustream os(ofs, opt.debug);
::sff::WID2 wid2;
wid2.dt=1.e-4;
wid2.station="stat";
wid2.channel="chan";
wid2.auxid="auxid";
wid2.instype="inst";
::sff::SRCE srce;
::sff::INFO info;
::sff::verbose(cout, srce);
os << srce;
const int mtrace=3;
const int msamp=100;
::datrw::Tfseries series(0,msamp-1);
for (int itrace=0; itrace<mtrace; ++itrace)
{
cout << endl << "trace #" << itrace << endl;
wid2.date=srce.date+libtime::double2time(0.100002*itrace);
os << wid2;
info.cx=1.*(itrace+1);
os << info;
::sff::verbose(cout, wid2);
::sff::verbose(cout, info);
for (int isamp=0; isamp<msamp; ++isamp)
{
series(isamp)=std::sin(6*3.14159265358*
((static_cast<double>(isamp)/msamp)
+(static_cast<double>(itrace)/mtrace)));
}
os << series;
}
}
/*----------------------------------------------------------------------*/
if (opt.scanfile)
{
std::ifstream ifs(opt.filename.c_str(),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment