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

proceeding

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: 1278
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent bdd20218
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.2 2002-12-30 16:04:32 forbrig Exp $
# $Id: Makefile,v 1.3 2003-01-04 21:49:37 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -54,7 +54,7 @@ HEADERS=$(shell find . -name \*.h)
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=polymodel.cc
SRC=polymodel.cc greenspec.cc srcires.cc
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: greenspec.cc,v 1.1 2003-01-04 20:05:19 forbrig Exp $
* $Id: greenspec.cc,v 1.2 2003-01-04 21:49:37 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
......@@ -19,11 +19,12 @@
#define TF_GREENSPEC_CC_VERSION \
"TF_GREENSPEC_CC V1.0 "
#define TF_GREENSPEC_CC_CVSID \
"$Id: greenspec.cc,v 1.1 2003-01-04 20:05:19 forbrig Exp $"
"$Id: greenspec.cc,v 1.2 2003-01-04 21:49:37 forbrig Exp $"
#include <gremlin1/greenspec.h>
#include <tfxx/fortranio.h>
#include <tfxx/complexio.h>
#include <tfxx/error.h>
#include <aff/array.h>
namespace gremlin1 {
......@@ -35,7 +36,7 @@ namespace gremlin1 {
using tfxx::fortranio::FortranBinInput;
// check magic number
tfxx::ioswap::Emagic_type magic=
tfxx::ioswap::file_magic_test(is, GreenSpectrum::Mmagic, true);
tfxx::ioswap::file_magic_test(is, GreenSpectrum::Mcmagic, true);
TFXX_assert(((magic==tfxx::ioswap::magic_match)||
(magic==tfxx::ioswap::magic_swap)),
"Green data contains incorrect magic number");
......@@ -52,13 +53,13 @@ namespace gremlin1 {
for (int i=slow.f(0); i<=slow.l(0); ++i)
{ fis >> slow(i); }
const double pi2=3.141592653589793115997;
const double pi2=2.*3.141592653589793115997;
double fmin=omega(omega.f(0))/pi2;
double fmax=omega(omega.l(0))/pi2;
double pmin=slow(slow.f(0));
double pmax=slow(slow.l(0));
green=GreenSpectrum(fmin,fmax,nf,pmin,pmax,np);
green=GreenSpectrum(fmin,fmax,nfre,pmin,pmax,nslo);
GreenSpectrum::Tcarray values=green.green();
......@@ -75,7 +76,7 @@ namespace gremlin1 {
/*----------------------------------------------------------------------*/
std::ostream& operator<<(std::ostream& is, const GreenSpectrum& green)
std::ostream& operator<<(std::ostream& os, const GreenSpectrum& green)
{
// attach to stream
tfxx::fortranio::FortranBinOutput fos(os);
......@@ -88,18 +89,18 @@ namespace gremlin1 {
GreenSpectrum::Tcarray::Tcoc values=green.green();
const double pi2=3.141592653589793115997;
const double pi2=2.*3.141592653589793115997;
for (int i=values.f(1); i<=values.l(1); ++i)
{ fos << green.f(i)*pi2; }
for (int i=values.f(0); i<=values.l(0); ++i)
{ fos << green.p(i); }
fos.end_block();
for (int i=green.f(0); i<=green.l(0); ++i)
for (int i=values.f(0); i<=values.l(0); ++i)
{
for (int j=green.f(1); j<=green.l(1); ++j)
for (int j=values.f(1); j<=values.l(1); ++j)
{
fos << green(i,j);
fos << values(i,j);
}
}
fos.end_block();
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: greenspec.h,v 1.1 2003-01-04 20:05:19 forbrig Exp $
* $Id: greenspec.h,v 1.2 2003-01-04 21:49:37 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
......@@ -23,10 +23,11 @@
#define TF_GREENSPEC_H_VERSION \
"TF_GREENSPEC_H V1.0 "
#define TF_GREENSPEC_H_CVSID \
"$Id: greenspec.h,v 1.1 2003-01-04 20:05:19 forbrig Exp $"
"$Id: greenspec.h,v 1.2 2003-01-04 21:49:37 forbrig Exp $"
#include<aff/array.h>
#include<iostream>
#include<complex>
namespace gremlin1 {
......@@ -35,18 +36,21 @@ namespace gremlin1 {
typedef std::complex<float> Tcvalue;
typedef aff::Array<Tcvalue> Tcarray;
static const char Mcmagic[]="1234";
GreenSpectrum(): Mdp(0.), Mpmin(0.), Mdf(0.), Mfmin(0.), Mgreen(1,1)
{ Mgreen=Tcvalue(0.); }
GreenSpectrum(const double& fmin, const double& fmax, const int& nf,
const double& pmin, const double& pmax, const int& np):
Mdp((pmax-pmin)/(np-1)), Mpmin(pmin),
Mdf((fmax-fmin)/(nf-1)), Mfmin(fmin),
Mgreen(np,nf) { Mgreen=Tcvalue(0.); }
const int& nf() const { return(Mnf); }
const int& np() const { return(Mnp); }
int nf() const { return(Mgreen.size(1)); }
int np() const { return(Mgreen.size(0)); }
const double& fmin() const { return(Mfmin); }
const double& pmin() const { return(Mpmin); }
double f(const int& i) const { return((i-1)*df+fmin); }
double p(const int& i) const { return((i-1)*dp+pmin); }
const double& df() const { return(Mdf); }
const double& dp() const { return(Mdp); }
double f(const int& i) const { return((i-1)*Mdf+Mfmin); }
double p(const int& i) const { return((i-1)*Mdp+Mpmin); }
Tcarray green() { return(Mgreen); }
Tcarray::Tcoc green() const { return(Mgreen); }
......@@ -64,7 +68,7 @@ namespace gremlin1 {
}; // GreenSpectrum
std::istream& operator>>(std::istream& is, GreenSpectrum& green);
std::ostream& operator<<(std::ostream& is, const GreenSpectrum& green);
std::ostream& operator<<(std::ostream& os, const GreenSpectrum& green);
}
......
/*! \file srcires.cc
* \brief source wavelet impulse response (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: srcires.cc,v 1.1 2003-01-04 21:49:37 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
* source wavelet impulse response (implementation)
*
* Copyright (c) 2003 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 04/01/2003 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_SRCIRES_CC_VERSION \
"TF_SRCIRES_CC V1.0 "
#define TF_SRCIRES_CC_CVSID \
"$Id: srcires.cc,v 1.1 2003-01-04 21:49:37 forbrig Exp $"
#include <cmath>
#include <stdio.h>
#include <gremlin1/srcires.h>
#include <tfxx/error.h>
#include <aff/array.h>
#include <aff/subarray.h>
namespace gremlin1 {
std::istream& operator>>(std::istream& is, GremlinIres& ires)
{
const int maxskip=500;
is.ignore(maxskip,'\n');
is.ignore(maxskip,'\n');
is.ignore(maxskip,'\n');
is.ignore(maxskip,'\n');
is.ignore(maxskip,'\n');
double df;
is >> df;
is.ignore(maxskip,'\n');
int nf;
is >> nf;
is.ignore(maxskip,'\n');
GremlinIres::Tcarray inarray(nf);
aff::Array<double> inomega(nf);
const double pi2=2.*3.141592653589793115997;
for (int i=inarray.f(0); i<=inarray.l(0); ++i)
{
double omega, realpart, imagpart;
is >> omega >> realpart >> imagpart;
inomega(i)=omega;
inarray(i)=GremlinIres::Tcvalue(realpart,imagpart);
}
int n1=static_cast<int>(inomega(1)/(df*pi2))+1;
int n2=n1+nf-1;
GremlinIres inires(df,n1,n2);
GremlinIres::Tcarray iresarray=inires.ires();
iresarray.copyin(inarray);
TFXX_assert((std::abs(1.-pi2*inires.f(n1)/inomega(1))<1.e-4),
"ERROR: frequency range mismatch in gremlin ires");
ires=inires;
return(is);
}
/*----------------------------------------------------------------------*/
std::ostream& operator<<(std::ostream& os, const GremlinIres& ires)
{
// get copy including frequency zero
GremlinIres::Tcarray outires(ires.n2());
GremlinIres::Tcarray
subires(aff::subarray(outires)(ires.n1(),ires.n2()));
subires.copyin(ires.ires());
os << "C++ version of gremlin ires" << std::endl;
os << "columns below row number 7:" << std::endl;
os << " 1: angular frequency (1/s)" << std::endl;
os << " 2: real part" << std::endl;
os << " 3: imaginary part" << std::endl;
os << ires.df() << " angular frequency step width" << std::endl;
os << outires.size() << " number of frequency samples" << std::endl;
const double pi2=2.*3.141592653589793115997;
const int bufsize=20;
char buffer[bufsize];
for (int i=outires.f(0); i<=outires.l(0); ++i)
{
double angfreq=pi2*ires.f(i);
double realpart=real(outires(i));
double imagpart=imag(outires(i));
std::snprintf(buffer, bufsize, "%15.10f %15.10f %15.10f",
angfreq, realpart, imagpart);
os << buffer << std::endl;
}
return(os);
}
}
/* ----- END OF srcires.cc ----- */
/*! \file srcires.h
* \brief source wavelet impulse response (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: srcires.h,v 1.1 2003-01-04 21:49:38 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
* source wavelet impulse response (prototypes)
*
* Copyright (c) 2003 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 04/01/2003 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_SRCIRES_H_VERSION
#define TF_SRCIRES_H_VERSION \
"TF_SRCIRES_H V1.0 "
#define TF_SRCIRES_H_CVSID \
"$Id: srcires.h,v 1.1 2003-01-04 21:49:38 forbrig Exp $"
#include<complex>
#include<iostream>
#include<aff/array.h>
#include<aff/shaper.h>
namespace gremlin1 {
class GremlinIres {
public:
typedef std::complex<float> Tcvalue;
typedef aff::Array<Tcvalue> Tcarray;
GremlinIres(): Mdf(0.), Mires(1) { Mires=Tcvalue(0.); }
GremlinIres(const double& df, const int& n1, const int& n2):
Mdf(df), Mires(aff::Shaper(n1,n2)) { Mires=Tcvalue(0.); }
int nf() const { return(Mires.size(0)); }
int n1() const { return(Mires.f(0)); }
int n2() const { return(Mires.l(0)); }
const double& df() const { return(Mdf); }
double f(const int& i) const { return((i-1)*Mdf); }
Tcarray ires() { return(Mires); }
Tcarray::Tcoc ires() const { return(Mires); }
private:
// frequency step
double Mdf;
// coefficients
Tcarray Mires;
}; // GremlinIres
std::istream& operator>>(std::istream& is, GremlinIres& green);
std::ostream& operator<<(std::ostream& os, const GremlinIres& green);
}
#endif // TF_SRCIRES_H_VERSION (includeguard)
/* ----- END OF srcires.h ----- */
#
# Makefile for src/green/gremlin1/tools
#
# $Id: Makefile,v 1.12 2002-12-30 18:08:29 forbrig Exp $
# $Id: Makefile,v 1.13 2003-01-04 21:49:38 forbrig Exp $
#
# 26/05/2000 - thof - new dependency generator (fdep.sh)
# 19/01/2001 reactivated them all
......@@ -27,7 +27,7 @@ CXXFLAGS=-Wall $(FLAGS)
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR)
CXXSRC=mocox.cc
CXXSRC=mocox.cc grestf.cc
.f.o:
f2c $(F2CFLAGS) $<
......
/*! \file grestf.cc
* \brief source time function from Green
*
* ----------------------------------------------------------------------------
*
* $Id: grestf.cc,v 1.1 2003-01-04 21:49:38 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
* source time function from Green
*
* Copyright (c) 2003 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 04/01/2003 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define GRESTF_VERSION \
"GRESTF V1.0 source time function from Green"
#define GRESTF_CVSID \
"$Id: grestf.cc,v 1.1 2003-01-04 21:49:38 forbrig Exp $"
#include <iostream>
#include <fstream>
#include <cmath>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <aff/slice.h>
#include <gremlin1/greenspec.h>
using std::cout;
using std::cerr;
using std::endl;
typedef gremlin1::GreenSpectrum::Tcarray Tcarray;
/*======================================================================*/
// functions
gremlin1::GreenSpectrum::Tcarray
resortarray(const gremlin1::GreenSpectrum::Tcarray::Tcoc& inarray)
{
gremlin1::GreenSpectrum::Tcarray result(inarray.size(1),
inarray.size(0));
for (int i=inarray.f(0); i<=inarray.l(0); ++i)
{
gremlin1::GreenSpectrum::Tcarray spec=aff::slice(result)()(i);
spec.copyin(aff::slice(inarray)(i));
}
return(result);
}
/*======================================================================*/
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
GRESTF_VERSION "\n"
"usage: grestf ires data [-v]" "\n"
" or: grestf --help|-h" "\n"
};
// define full help text
char help_text[]=
{
"-v verbose" "\n"
"\n"
"ires impulse response Green" "\n"
"data Green from data" "\n"
"\n"
GRESTF_CVSID
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
exit(0);
}
bool opt_verbose=cmdline.optset(1);
const char missing_argument[]="ERROR: missing command line argument!";
TFXX_assert(cmdline.extra(), missing_argument);
std::string ires_file=cmdline.next();
TFXX_assert(cmdline.extra(), missing_argument);
std::string data_file=cmdline.next();
/*----------------------------------------------------------------------*/
// read synthetics
if (opt_verbose) cout << GRESTF_VERSION << endl;
if (opt_verbose) cout << "reading impulse response Green from "
<< ires_file << endl;
gremlin1::GreenSpectrum iresgreen;
{
std::ifstream ifs(ires_file.c_str());
ifs >> iresgreen;
}
if (opt_verbose)
{
cout << " " << iresgreen.nf() << " frequencies, "
<< iresgreen.np() << " slowness values" << endl;
cout << " frequency range: "
<< iresgreen.fmin() << " to "
<< iresgreen.f(iresgreen.nf()) << " Hz" << endl;
cout << " slowness range: "
<< iresgreen.pmin()*1.e3 << " to "
<< iresgreen.p(iresgreen.np())*1.e3 << " s/km" << endl;
}
/*----------------------------------------------------------------------*/
// read data
if (opt_verbose) cout << "reading field data Green from "
<< data_file << endl;
gremlin1::GreenSpectrum datagreen;
{
std::ifstream ifs(data_file.c_str());
ifs >> datagreen;
}
if (opt_verbose)
{
cout << " " << datagreen.nf() << " frequencies, "
<< datagreen.np() << " slowness values" << endl;
cout << " frequency range: "
<< datagreen.fmin() << " to "
<< datagreen.f(datagreen.nf()) << " Hz" << endl;
cout << " slowness range: "
<< datagreen.pmin() << " to "
<< datagreen.p(datagreen.np())*1.e3 << " s/km" << endl;
}
/*----------------------------------------------------------------------*/
// consistency checks
const char inconsistent_data[]="ERROR: files are not consistent!";
TFXX_assert((iresgreen.nf()==datagreen.nf()),inconsistent_data);
TFXX_assert((iresgreen.np()==datagreen.np()),inconsistent_data);
TFXX_assert((std::abs(iresgreen.fmin()-datagreen.fmin())<=
1.e-5*iresgreen.fmin()), inconsistent_data);
TFXX_assert((std::abs(iresgreen.pmin()-datagreen.pmin())<=
1.e-5*iresgreen.pmin()), inconsistent_data);
TFXX_assert((std::abs(1.-iresgreen.df()/datagreen.df())<1.e-5),
inconsistent_data);
TFXX_assert((std::abs(1.-iresgreen.dp()/datagreen.dp())<1.e-5),
inconsistent_data);
/*----------------------------------------------------------------------*/
// create resorted arrays (rows are frequencies then)
Tcarray rsrtires=resortarray(iresgreen.green());
Tcarray rsrtdata=resortarray(datagreen.green());
}
/* ----- END OF grestf.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: mocox.cc,v 1.6 2003-01-04 19:17:37 forbrig Exp $
* $Id: mocox.cc,v 1.7 2003-01-04 21:49:38 forbrig Exp $
* \author Thomas Forbriger
* \date 30/12/2002
*
......@@ -23,7 +23,7 @@
#define MOCOX_VERSION \
MOCOX_SHORT_VERSION " convert gremlin1 model (modversion2)"
#define MOCOX_CVSID \
"$Id: mocox.cc,v 1.6 2003-01-04 19:17:37 forbrig Exp $"
"$Id: mocox.cc,v 1.7 2003-01-04 21:49:38 forbrig Exp $"
#include <iostream>
#include <stdio.h>
......@@ -144,7 +144,7 @@ void write_flnode(const std::string& filename,
{
Tarray flnodes=convert_flnode(nodes, verbose);
std::ofstream ofs(filename.c_str());
ofs << flnode_id;
ofs << flnode_id << endl;
ofs << "converted by " << MOCOX_SHORT_VERSION
<< " from " << sourcefile << endl;
const double reference_frequency=0.;
......
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