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

moved functions to separate files

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: 5131
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f50a87dc
......@@ -78,7 +78,8 @@ EDITSRC=$(wildcard *.cc *.h *.c *.f *.txt *.gpt *.inc)
EDITTESTS=$(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
$(TESTCASEMAKE) $(wildcard testcases/*.gpt)
flist: $(wildcard *.txt *.c *.f *.inc Makefile *.cc *.gpt) doxydoc.cfg README \
flist: $(wildcard *.txt *.c *.f *.h *.inc Makefile *.cc *.gpt) \
doxydoc.cfg README \
$(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
$(TESTCASEMAKE) $(wildcard testcases/*.gpt) $(TF_EDIT)
echo $(filter $(EDITFILES),$^) | tr ' ' '\n' | sort > $@
......@@ -144,7 +145,9 @@ siggenx: %x: %.o
lisousi.cc: lisousi_description_text.h
lisousi.cc: lisousi_help_text.h
lisousi: \
%: %_description_text.o %_help_text.o %.o
%: %_description_text.o %_help_text.o %.o \
%_filterresponse.o \
%_applytaper.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lfourierxx -lfftw3 -lm \
-lsffxx -ldatrwxx -llinearxx -lgsl -lgslcblas \
-ltsxx -ltfxx -lsffxx -lgsexx -ltime++ -laff \
......
......@@ -61,153 +61,10 @@
#define LISOUSI_CVSID \
"$Id$"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <gsl/gsl_sf_bessel.h>
#include <tfxx/commandline.h>
#include <tfxx/xcmdline.h>
#include <tfxx/error.h>
#include <tfxx/stringfunc.h>
#include <tfxx/rangestring.h>
#include <tfxx/rangelist.h>
#include <tfxx/misc.h>
#include <tsxx/anyfilter.h>
#include <tsxx/convolve.h>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <sffxx.h>
#include <sffostream.h>
#include <aff/dump.h>
#include <aff/seriesoperators.h>
#include <aff/subarray.h>
#include <tsxx/ovtaper.h>
#include <fourier/fftwaff.h>
#include "lisousi.h"
#include "lisousi_help_text.h"
#include "lisousi_description_text.h"
using std::cout;
using std::cerr;
using std::endl;
typedef ts::filter::Ttimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
/*----------------------------------------------------------------------*/
// type of Fourier domain solution
enum Efdtype {
Ffdfarfield,
Ffdexplosion,
Ffdzforce,
Ffdlamb
};
struct Options {
bool verbose, debug;
bool overwrite, taperfirst, sqrttaper, limitlength;
bool fredomain, fdfilter, tdfilter, nointeg, transition, tapsloset;
double tfac, tshift, tlim, integshift, tapdel;
double tapslo, transition1, transition2;
int npad;
std::string inputformat, outputformat;
// single-velocity switches:
Efdtype fdtype;
// propagation parameters:
double velocity, vpvsratio, pquality, squality;
// trapezoid integration:
double tzedgefactor, tzedgetaper;
int tznsteps;
}; // struct Options
/*======================================================================*/
/* functions */
/* create a 1/sqrt(t) filter response */
Tseries filterresponse(const int& size, const double& dt, const Options& opt)
{
if (opt.verbose)
{
cout << " construct 1/sqrt(t); ";
if (opt.nointeg)
{
cout << "tshift: " << opt.tshift << "; "
<< "tlim: " << opt.tlim << "; "
<< "tfac: " << opt.tfac << endl;
}
else
{
cout << "integshift: " << opt.integshift << " means "
<< opt.integshift*dt << "s time shift" << endl;
}
}
Tseries retval=Tseries(0,size-1);
aff::Iterator<Tseries> I(retval);
for (unsigned int i=0; i<retval.size(); ++i)
{
if (opt.nointeg)
{
double t=dt*(double(i)+opt.tshift);
if (t < (opt.tlim*dt)) { t=opt.tfac*dt; }
*I=sqrt(1./t);
}
else
{
if (i == 0)
{
double tref=1.-opt.integshift;
*I=2.*sqrt(tref/dt);
}
else
{
double tref=(double(i)-opt.integshift);
*I=2.*(sqrt(tref+1)-sqrt(tref))/sqrt(dt);
}
}
++I;
}
return(retval);
}
/*----------------------------------------------------------------------*/
Tseries applytaper(const Tseries::Tcoc& input, const Tseries::Tcoc& taper,
const double& factor, const double& dt,
const double& offset, const Options& opt)
{
if (opt.verbose)
{
cout << " apply taper function"
<< " with delay: " << dt*int(opt.tapdel/dt) << "s"
<< endl;
}
// calculate taper delay
double taperdelay=opt.tapdel;
if (opt.tapsloset)
{
taperdelay=taperdelay<opt.tapslo*offset ? taperdelay : opt.tapslo*offset;
}
// prepare return value
Tseries retval(0,input.size()-1);
retval=0.;
// prepare iterators
aff::Browser<Tseries::Tcoc> IT(taper);
aff::Browser<Tseries::Tcoc> II(input);
aff::Iterator<Tseries> IS(retval);
unsigned int i=0;
// apply taper
while (IT.valid() && IS.valid() && II.valid())
{
double t=i*dt;
(*IS) = (*II) * (*IT) * factor;
++IS;
++II;
if (t >= taperdelay) { ++IT; }
++i;
}
return(retval);
}
/*======================================================================*/
int main(int iargc, char* argv[])
......
/*! \file lisousi.h
* \brief prototypes and structs for lisousi (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 17/04/2013
*
* prototypes and structs for lisousi (prototypes)
*
* Copyright (c) 2013 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 17/04/2013 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_LISOUSI_H_VERSION
#define TF_LISOUSI_H_VERSION \
"TF_LISOUSI_H V1.0 "
#define TF_LISOUSI_H_CVSID \
"$Id$"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <gsl/gsl_sf_bessel.h>
#include <tfxx/commandline.h>
#include <tfxx/xcmdline.h>
#include <tfxx/error.h>
#include <tfxx/stringfunc.h>
#include <tfxx/rangestring.h>
#include <tfxx/rangelist.h>
#include <tfxx/misc.h>
#include <tsxx/anyfilter.h>
#include <tsxx/convolve.h>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <sffxx.h>
#include <sffostream.h>
#include <aff/dump.h>
#include <aff/seriesoperators.h>
#include <aff/subarray.h>
#include <tsxx/ovtaper.h>
#include <fourier/fftwaff.h>
using std::cout;
using std::cerr;
using std::endl;
typedef ts::filter::Ttimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
/*----------------------------------------------------------------------*/
// type of Fourier domain solution
enum Efdtype {
Ffdfarfield,
Ffdexplosion,
Ffdzforce,
Ffdlamb
};
struct Options {
bool verbose, debug;
bool overwrite, taperfirst, sqrttaper, limitlength;
bool fredomain, fdfilter, tdfilter, nointeg, transition, tapsloset;
double tfac, tshift, tlim, integshift, tapdel;
double tapslo, transition1, transition2;
int npad;
std::string inputformat, outputformat;
// single-velocity switches:
Efdtype fdtype;
// propagation parameters:
double velocity, vpvsratio, pquality, squality;
// trapezoid integration:
double tzedgefactor, tzedgetaper;
int tznsteps;
}; // struct Options
/*======================================================================*/
/* functions */
#endif // TF_LISOUSI_H_VERSION (includeguard)
Tseries applytaper(const Tseries::Tcoc& input, const Tseries::Tcoc& taper,
const double& factor, const double& dt,
const double& offset, const Options& opt);
Tseries filterresponse(const int& size, const double& dt, const Options& opt);
/* ----- END OF lisousi.h ----- */
/*! \file lisousi_applytaper.cc
* \brief apply a taper to the time series (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 17/04/2013
*
* apply a taper to the time series (implementation)
*
* Copyright (c) 2013 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 17/04/2013 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_LISOUSI_APPLYTAPER_CC_VERSION \
"TF_LISOUSI_APPLYTAPER_CC V1.0 "
#define TF_LISOUSI_APPLYTAPER_CC_CVSID \
"$Id$"
#include "lisousi.h"
Tseries applytaper(const Tseries::Tcoc& input, const Tseries::Tcoc& taper,
const double& factor, const double& dt,
const double& offset, const Options& opt)
{
if (opt.verbose)
{
cout << " apply taper function"
<< " with delay: " << dt*int(opt.tapdel/dt) << "s"
<< endl;
}
// calculate taper delay
double taperdelay=opt.tapdel;
if (opt.tapsloset)
{
taperdelay=taperdelay<opt.tapslo*offset ? taperdelay : opt.tapslo*offset;
}
// prepare return value
Tseries retval(0,input.size()-1);
retval=0.;
// prepare iterators
aff::Browser<Tseries::Tcoc> IT(taper);
aff::Browser<Tseries::Tcoc> II(input);
aff::Iterator<Tseries> IS(retval);
unsigned int i=0;
// apply taper
while (IT.valid() && IS.valid() && II.valid())
{
double t=i*dt;
(*IS) = (*II) * (*IT) * factor;
++IS;
++II;
if (t >= taperdelay) { ++IT; }
++i;
}
return(retval);
}
/* ----- END OF lisousi_applytaper.cc ----- */
/*! \file lisousi_filterresponse.cc
* \brief create a 1/sqrt(t) filter response for given parameters (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 17/04/2013
*
* create a 1/sqrt(t) filter response for given parameters (implementation)
*
* Copyright (c) 2013 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 17/04/2013 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_LISOUSI_FILTERRESPONSE_CC_VERSION \
"TF_LISOUSI_FILTERRESPONSE_CC V1.0 "
#define TF_LISOUSI_FILTERRESPONSE_CC_CVSID \
"$Id$"
#include "lisousi.h"
/* create a 1/sqrt(t) filter response */
Tseries filterresponse(const int& size, const double& dt, const Options& opt)
{
if (opt.verbose)
{
cout << " construct 1/sqrt(t); ";
if (opt.nointeg)
{
cout << "tshift: " << opt.tshift << "; "
<< "tlim: " << opt.tlim << "; "
<< "tfac: " << opt.tfac << endl;
}
else
{
cout << "integshift: " << opt.integshift << " means "
<< opt.integshift*dt << "s time shift" << endl;
}
}
Tseries retval=Tseries(0,size-1);
aff::Iterator<Tseries> I(retval);
for (unsigned int i=0; i<retval.size(); ++i)
{
if (opt.nointeg)
{
double t=dt*(double(i)+opt.tshift);
if (t < (opt.tlim*dt)) { t=opt.tfac*dt; }
*I=sqrt(1./t);
}
else
{
if (i == 0)
{
double tref=1.-opt.integshift;
*I=2.*sqrt(tref/dt);
}
else
{
double tref=(double(i)-opt.integshift);
*I=2.*(sqrt(tref+1)-sqrt(tref))/sqrt(dt);
}
}
++I;
}
return(retval);
}
/* ----- END OF lisousi_filterresponse.cc ----- */
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