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

reading refract taper files is implemented and tested

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: 4487
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f1c8bbab
/*! \file debug.h
* \brief debug macro (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 28/01/2012
*
* debug macro (prototypes)
*
* Copyright (c) 2012 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 28/01/2012 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TSXX_DEBUG_H_VERSION
#define TSXX_DEBUG_H_VERSION \
"TSXX_DEBUG_H V1.0 "
#define TSXX_DEBUG_H_CVSID \
"$Id$"
/*! \brief produce debug output
* \ingroup group_util
*
* \param C output will be generated if C == true
* \param N name of function
* \param M message to print
*/
#define TSXX_debug(C,N,M) \
if (C) { \
std::cerr << "DEBUG (" << N << ", " \
<< __FILE__ << " line #" << __LINE__ << "):" << std::endl \
<< " " << M << std::endl; \
std::cerr.flush(); \
}
/*! \brief report value
* \ingroup group_util
*
* \param V expression variable to report
*
* The macro can be used in the argument \par M of DATRW_debug
*/
#define TSXX_value(V) #V << ": " << V
#endif // TSXX_DEBUG_H_VERSION (includeguard)
/* ----- END OF debug.h ----- */
......@@ -39,12 +39,64 @@
"$Id$"
#include <fstream>
#include <tfxx/error.h>
#include <sstream>
#include <tsxx/tsxx.h>
#include <tsxx/debug.h>
#include <tsxx/ovtaper.h>
namespace ts {
namespace tapers {
namespace ovtaper {
//! read from file in refract taper file format
void Picks::read(std::istream& is)
{
std::string line;
do {
TSXX_assert(getline(is, line),
"Picks::read: error while reading taper definition");
} while (line.substr(0,9)!="taper set");
TSXX_debug(Mdebug, "Picks::read",
"found data line:\n" << line);
std::istringstream iss(line.substr(17,4));
int n;
iss >> n;
TSXX_debug(Mdebug, "Picks::read",
"read " << n << " picks");
// skip one line
TSXX_assert(getline(is, line),
"Picks::read: error while reading taper definition");
for (int i=0; i<n; ++i)
{
Pick p;
TSXX_assert(is >> p.x >> p.t,
"Picks::read: error while reading taper definition");
Mpicks.push_back(p);
TSXX_debug(Mdebug, "Picks::read",
"#" << i << " x=" << p.x << ", t=" << p.t);
}
Mpicks.sort();
} // void Picks::read(std::istream& is)
/*----------------------------------------------------------------------*/
double Picks::time(const double& offset) const
{
double retval=0.;
TSXX_abort("not yet implemented");
return retval;
} // double Picks::time(const double& offset) const
} // namespace ovtaper
/*======================================================================*/
ts::tapers::FourPoint OffsetVariableTaper::taper(const double& offset,
const double& T0,
......
......@@ -62,6 +62,10 @@ namespace ts {
/*----------------------------------------------------------------------*/
bool operator<(const Pick& p1, const Pick& p2) { return (p1.x<p2.x); }
/*----------------------------------------------------------------------*/
//! a sequence of picks
class Picks {
public:
......@@ -95,7 +99,7 @@ namespace ts {
typedef ts::TDtimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
typedef Ttimeseries::Theader Theader;
OffsetVariableTaper(const bool& debug)
OffsetVariableTaper(const bool& debug=false)
: Mdebug(debug), Mvalid(false),
Mt1(debug), Mt2(debug), Mt3(debug), Mt4(debug)
{ }
......
......@@ -41,6 +41,7 @@
#define TSTEST_CVSID \
"$Id$"
#include <tfxx/commandline.h>
#include <iostream>
#include <tsxx/tsxx.h>
#include <aff/dump.h>
......@@ -48,6 +49,7 @@
#include <tsxx/random.h>
#include <tsxx/dropcontainer.h>
#include <tsxx/tapers.h>
#include <tsxx/ovtaper.h>
using std::cout;
using std::cerr;
......@@ -239,6 +241,14 @@ int main(int iargc, char* argv[])
}
}
/*======================================================================*/
if (opt.ovtapertest)
{
ts::tapers::OffsetVariableTaper ovt(true);
ovt.read(opt.ovtaperfile);
}
}
/* ----- END OF tstest.cc ----- */
......@@ -210,7 +210,6 @@ namespace ts {
} // namespace error
/* ----- END OF error.h ----- */
} // namespace ts
/*======================================================================*/
......
Markdown is supported
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