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

scaling works

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: 1425
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent d35a2ef7
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2003-12-22 17:18:02 tforb Exp $
# $Id: Makefile,v 1.5 2003-12-23 13:59:59 tforb Exp $
#
# Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
#
......@@ -93,7 +93,7 @@ doxyview: doxyfullview doxybrief
# ---------
sfftest: sfftest.cc
$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) -lsffxx -ltime++ -lgsexx \
$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) -lsffxx -ltime++ -lgsexx -laff \
-L$(LOCLIBDIR)
tests: sfftest; $<; rm -fv $<
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sfftest.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $
* $Id: sfftest.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -19,10 +19,11 @@
#define SFFTEST_VERSION \
"SFFTEST V1.0 test library modules"
#define SFFTEST_CVSID \
"$Id: sfftest.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $"
"$Id: sfftest.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $"
#include <iostream>
#include <sffxx.h>
#include <aff/series.h>
using std::cout;
using std::cerr;
......@@ -78,6 +79,12 @@ void test_write_wrappers()
sff::INFO myinfo;
sff::FREE myfree;
myfree.lines.push_back("auch ein text");
sff::WID2 mywid2;
mywid2.station="BFO";
mywid2.channel="UGZ";
mywid2.instype="ET-19";
mywid2.nsamples=2048;
mywid2.dt=10.;
{ cout << sff::FileHeader(); }
cout << endl << "next:" << endl;
......@@ -88,19 +95,36 @@ void test_write_wrappers()
{ cout << sff::FileHeader(mysrce, myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(); }
{ cout << sff::TraceHeader(mywid2); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo); }
{ cout << sff::TraceHeader(mywid2, myinfo); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myfree); }
{ cout << sff::TraceHeader(mywid2, myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo, myfree); }
{ cout << sff::TraceHeader(mywid2, myinfo, myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo,true); }
{ cout << sff::TraceHeader(mywid2, myinfo,true); }
}
/*----------------------------------------------------------------------*/
typedef aff::Series<double> Tseries;
void scale_series(Tseries& s, const double& f)
{
for (int i=s.first(); i<=s.last(); i++)
{ s(i) *= f; }
cout << "scale by " << f << endl;
}
void scaling(const sff::TraceHeader& hd)
{
if (hd.scale())
{ cout << "will be scaled with ampfac "; }
else
{ cout << "will not be scaled and ampfac is "; }
cout << hd.dast().ampfac << endl;
}
void test_waveform_normalizer()
{
cout << "test waveform normalizer" << endl
......@@ -108,15 +132,47 @@ void test_waveform_normalizer()
cout << "limit: " << sff::WaveformNormalizer::limit << " ";
cout << "2^23: " << std::pow(2.,23.) << endl;
const int msamp=100;
Tseries series(msamp);
for (int i=series.first(); i<=series.last(); i++)
{ series(i)=sin(3.1415926*i*5/msamp); }
sff::WID2 wid2;
sff::TraceHeader hd(wid2);
hd.scanseries(series);
scaling(hd);
scale_series(series, 1.e10);
hd.scanseries(series);
scaling(hd);
scale_series(series, 1.e-4);
hd.scanseries(series, sff::NM_ifneeded);
scaling(hd);
scale_series(series, 1.e4);
hd.scanseries(series, sff::NM_ifneeded);
scaling(hd);
scale_series(series, 1.e-4);
hd.scanseries(series, sff::NM_one);
scaling(hd);
#ifdef ILLEGAL1
scale_series(series, 1.e4);
hd.scanseries(series, sff::NM_one);
scaling(hd);
#endif
}
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
{
test_line_functions();
test_write_wrappers();
test_waveform_normalizer();
test_line_functions(); cout << endl;
test_write_wrappers(); cout << endl;
test_waveform_normalizer(); cout << endl;
}
/* ----- END OF sfftest.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $
* $Id: sffxx.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -19,7 +19,7 @@
#define TF_SFFXX_CC_VERSION \
"TF_SFFXX_CC V1.0 "
#define TF_SFFXX_CC_CVSID \
"$Id: sffxx.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $"
"$Id: sffxx.cc,v 1.4 2003-12-23 14:00:00 tforb Exp $"
#include <sffxx.h>
#include <gsexx.h>
......@@ -220,10 +220,14 @@ namespace sff {
// TraceHeader
// -----------
void TraceHeader::write(std::ostream& os) const
void TraceHeader::writeheader(std::ostream& os) const
{
os << Mdast.line();
os << Mwid2.line();
}
void TraceHeader::writetrailer(std::ostream& os) const
{
if (Mdast.hasfree) { Mfree.write(os); }
if (Mdast.hasinfo) { os << Minfo.line(); }
}
......@@ -236,7 +240,7 @@ namespace sff {
WaveformNormalizer::WaveformNormalizer(const Enormmode& nm,
const double& maxval):
Mnorm(nm), Mmaxval(maxval)
Mmaxval(maxval), Mnorm(nm)
{
if (Mnorm == NM_one)
{
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.h,v 1.3 2003-12-22 17:18:04 tforb Exp $
* $Id: sffxx.h,v 1.4 2003-12-23 14:00:00 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -23,13 +23,14 @@
#define TF_SFFXX_H_VERSION \
"TF_SFFXX_H V1.0 "
#define TF_SFFXX_H_CVSID \
"$Id: sffxx.h,v 1.3 2003-12-22 17:18:04 tforb Exp $"
"$Id: sffxx.h,v 1.4 2003-12-23 14:00:00 tforb Exp $"
#include<string>
#include<list>
#include<iostream>
#include<libtime++.h>
#include<aff/iterator.h>
#include<gsexx.h>
/*! \brief all SFF modules
*/
......@@ -187,7 +188,8 @@ namespace sff {
const FREE& free, const bool& last=false):
Mwid2(wid2), Mfree(free), Minfo(info)
{ Mdast.hasfree=true; Mdast.hasinfo=true; Mdast.last=last; }
void write(std::ostream&) const;
void writeheader(std::ostream&) const;
void writetrailer(std::ostream&) const;
bool last() const { return(Mdast.last); }
template<class C> void scanseries(const C&,
const Enormmode& nm=NM_maxdyn);
......@@ -211,12 +213,7 @@ namespace sff {
OutputWaveform(const Tcoc& c, const TraceHeader& th,
const Enormmode& nm=NM_maxdyn):
Mseries(c), Mheader(th), Mnorm(nm)
{
))Achtung: hier stimmt allerhand nicht))
Mnorm.scan(Mseries);
Mheader.dast.ampfac=Mnorm.ampfac();
Mheader.
}
{ Mheader.scan(Mseries,Mnorm); }
void write(std::ostream& os) const;
private:
Tcoc Mseries;
......@@ -224,6 +221,9 @@ namespace sff {
WaveformNormalizer Mnorm;
}; // class Waveform
class InputWaveform {
}; // class InputWaveform
class SkipWaveform {
}; // class SkipWaveform
......@@ -235,14 +235,19 @@ namespace sff {
{ return(is); }
inline std::istream& operator >> (std::istream& is, TraceHeader& th)
{ return(is); }
inline std::istream& operator >> (std::istream& is, Waveform& wf)
inline std::istream& operator >> (std::istream& is, InputWaveform& wf)
{ return(is); }
inline std::istream& operator >> (std::istream& is, SkipWaveform& swf)
{ return(is); }
inline std::ostream& operator << (std::ostream& os, const FileHeader& fh)
{ fh.write(os); return(os); }
inline std::ostream& operator << (std::ostream& os, const TraceHeader& th)
{ th.write(os); return(os); }
{
th.writeheader(os);
os << "DATA!" << std::endl;
th.writetrailer(os);
return(os);
}
template<class C>
inline std::ostream& operator << (std::ostream& os, const
OutputWaveform<C>& wf)
......@@ -253,14 +258,15 @@ namespace sff {
// -------------------------------------
template<class C>
inline
void TraceHeader::scanseries(const C& c,
const Enormmode& nm=NM_maxdyn);
const Enormmode& nm)
{
Mwid2.nsamples=0;
typename C::Tvalue maxval=0.;
typename C::Tvalue absval, value;
typename C::Tvalue null(0);
for(aff::Iterator<C> i(c); i.valid(); ++i)
for(aff::Browser<C> i(c); i.valid(); ++i)
{
Mwid2.nsamples++;
value= *i;
......@@ -278,12 +284,13 @@ namespace sff {
// ---------------------------------
template<class C>
void OutputWaveform::write(std::ostream& os)
inline
void OutputWaveform<C>::write(std::ostream& os) const
{
os << Mheader;
Mheader.writeheader(os);;
GSE2::waveform::TDAT2writeCM6 fwriter(Mwid2.nsamples);
int idata;
C::Tvalue data;
typename C::Tvalue data;
for(aff::Iterator<C> i(c); i.valid(); ++i)
{
data= *i;
......@@ -293,6 +300,7 @@ namespace sff {
{ idata=int(std::nearbyint(data)); }
os << fwriter(idata);
}
Mheader.writetrailer(os);;
}
} // namespace sff
......
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