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

proceeding step by step

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: 1423
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent d8c62469
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.3 2003-12-22 14:14:23 tforb Exp $
# $Id: Makefile,v 1.4 2003-12-22 17:18:02 tforb Exp $
#
# Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
#
......@@ -48,7 +48,7 @@ clean: ;
# library part
# ------------
LIBSRC=sffxx.cc
LIBSRC=sffxx.cc
INCSRC=sffxx.h
-include $(patsubst %.cc,%.d,$(LIBSRC))
......@@ -85,7 +85,7 @@ doxyfull: doc/html/index.html
doxydoc: doxybrief doxyfull
doxyfullview: doxyfull; mozilla file:$(DOXYWWWPATH)/html/index.html &
doxybriefview: doxybrief; mozilla file:/docbrief/html/index.html &
doxybriefview: doxybrief; mozilla file:$(shell pwd)/docbrief/html/index.html &
doxyview: doxyfullview doxybrief
#======================================================================
......
......@@ -47,10 +47,8 @@ WARN_LOGFILE =
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./
FILE_PATTERNS = README \
gsexx.h \
gsexx_T*cc \
gsexxcc
FILE_PATTERNS = *.h \
*.cc
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
......
/*! \file operators.cc
* \brief operators defined for libsffxx (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: operators.cc,v 1.1 2003-12-22 14:14:24 tforb Exp $
* \author Thomas Forbriger
* \date 22/12/2003
*
* operators defined for libsffxx (implementation)
*
* Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 22/12/2003 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_OPERATORS_CC_VERSION \
"TF_OPERATORS_CC V1.0 "
#define TF_OPERATORS_CC_CVSID \
"$Id: operators.cc,v 1.1 2003-12-22 14:14:24 tforb Exp $"
#include <operators.h>
namespace tf {
}
/* ----- END OF operators.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sfftest.cc,v 1.2 2003-12-22 14:14:24 tforb Exp $
* $Id: sfftest.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -19,7 +19,7 @@
#define SFFTEST_VERSION \
"SFFTEST V1.0 test library modules"
#define SFFTEST_CVSID \
"$Id: sfftest.cc,v 1.2 2003-12-22 14:14:24 tforb Exp $"
"$Id: sfftest.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $"
#include <iostream>
#include <sffxx.h>
......@@ -67,9 +67,56 @@ void test_line_functions()
} // test_line_functions()
/*----------------------------------------------------------------------*/
void test_write_wrappers()
{
cout << "test write wrappers" << endl
<< "-------------------" << endl;
sff::SRCE mysrce;
sff::INFO myinfo;
sff::FREE myfree;
myfree.lines.push_back("auch ein text");
{ cout << sff::FileHeader(); }
cout << endl << "next:" << endl;
{ cout << sff::FileHeader(mysrce); }
cout << endl << "next:" << endl;
{ cout << sff::FileHeader(myfree); }
cout << endl << "next:" << endl;
{ cout << sff::FileHeader(mysrce, myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo, myfree); }
cout << endl << "next:" << endl;
{ cout << sff::TraceHeader(myinfo,true); }
}
/*----------------------------------------------------------------------*/
void test_waveform_normalizer()
{
cout << "test waveform normalizer" << endl
<< "------------------------" << endl;
cout << "limit: " << sff::WaveformNormalizer::limit << " ";
cout << "2^23: " << std::pow(2.,23.) << endl;
}
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
{
test_line_functions();
test_write_wrappers();
test_waveform_normalizer();
}
/* ----- END OF sfftest.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.cc,v 1.2 2003-12-22 14:14:25 tforb Exp $
* $Id: sffxx.cc,v 1.3 2003-12-22 17:18:04 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.2 2003-12-22 14:14:25 tforb Exp $"
"$Id: sffxx.cc,v 1.3 2003-12-22 17:18:04 tforb Exp $"
#include <sffxx.h>
#include <gsexx.h>
......@@ -205,6 +205,67 @@ namespace sff {
return(retval);
} // INFO::line()
/*----------------------------------------------------------------------*/
// FileHeader
// ----------
void FileHeader::write(std::ostream& os) const
{
os << Mstat.line();
if (Mstat.hasfree) { Mfree.write(os); }
if (Mstat.hassrce) { os << Msrce.line(); }
}
/*----------------------------------------------------------------------*/
// TraceHeader
// -----------
void TraceHeader::write(std::ostream& os) const
{
os << Mdast.line();
os << Mwid2.line();
if (Mdast.hasfree) { Mfree.write(os); }
if (Mdast.hasinfo) { os << Minfo.line(); }
}
/*----------------------------------------------------------------------*/
// WaveformNormalizer
// ------------------
const int WaveformNormalizer::limit=0x800000;
WaveformNormalizer::WaveformNormalizer(const Enormmode& nm,
const double& maxval):
Mnorm(nm), Mmaxval(maxval)
{
if (Mnorm == NM_one)
{
Mampfac=1.;
Mscale=false;
if (Mmaxval > double(WaveformNormalizer::limit)) throw
GSE2::Terror("ERROR (sff::WaveformNormalizer::scan): "
"dynamic range to large for non-normalizing mode");
}
else if (Mnorm == NM_ifneeded)
{
Mampfac=1.;
Mscale=false;
if (Mmaxval > double(WaveformNormalizer::limit))
{
Mampfac=Mmaxval/double(WaveformNormalizer::limit);
Mscale=true;
}
}
else if (Mnorm == NM_maxdyn)
{
Mampfac=Mmaxval/double(WaveformNormalizer::limit);
Mscale=true;
}
else throw
GSE2::Terror("ERROR (sff::WaveformNormalizer::scan): "
"library inconsistency!");
}
} // namespace sff
/* ----- END OF sffxx.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.h,v 1.2 2003-12-22 14:14:25 tforb Exp $
* $Id: sffxx.h,v 1.3 2003-12-22 17:18:04 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -23,12 +23,13 @@
#define TF_SFFXX_H_VERSION \
"TF_SFFXX_H V1.0 "
#define TF_SFFXX_H_CVSID \
"$Id: sffxx.h,v 1.2 2003-12-22 14:14:25 tforb Exp $"
"$Id: sffxx.h,v 1.3 2003-12-22 17:18:04 tforb Exp $"
#include<string>
#include<list>
#include<iostream>
#include<libtime++.h>
#include<aff/iterator.h>
/*! \brief all SFF modules
*/
......@@ -50,8 +51,9 @@ namespace sff {
/*----------------------------------------------------------------------*/
enum Enormmode {
NM_one, //!< do not scale
NM_maxdyn //!< scale for maximum dynamic range
NM_one, //!< do not scale
NM_maxdyn, //!< scale for maximum dynamic range
NM_ifneeded //!< scale if dynamic range larger than limit
}; // enum Enormmode
/*======================================================================*/
......@@ -137,54 +139,90 @@ namespace sff {
class FileHeader {
public:
FileHeader(): MuseSRCE(false), MuseFREE(false) { }
FileHeader(const FREE& free): MuseSRCE(false), MuseFREE(true),
Mfree(free) { }
FileHeader(const SRCE& srce): MuseSRCE(true), MuseFREE(false),
Msrce(srce) { }
FileHeader()
{ Mstat.hasfree=false; Mstat.hassrce=false; }
FileHeader(const FREE& free):
Mfree(free)
{ Mstat.hasfree=true; Mstat.hassrce=false; }
FileHeader(const SRCE& srce):
Msrce(srce)
{ Mstat.hasfree=false; Mstat.hassrce=true; }
FileHeader(const SRCE& srce, const FREE& free):
MuseSRCE(true), MuseFREE(true),
Mfree(free), Msrce(srce) { }
Mfree(free), Msrce(srce)
{ Mstat.hasfree=true; Mstat.hassrce=true; }
void write(std::ostream&) const;
private:
bool MuseSRCE;
bool MuseFREE;
STAT Mstat;
FREE Mfree;
SRCE Msrce;
}; // class FileHeader
class TraceHeader {
/*! \brief class to normalize waveforms
*/
class WaveformNormalizer {
public:
static const int limit;
WaveformNormalizer(const Enormmode& nm, const double& maxval);
const double& maxval() const { return(Mmaxval); }
const double& ampfac() const { return(Mampfac); }
const bool& scale() const { return(Mscale); }
private:
double Mampfac;
double Mmaxval;
bool Mscale;
Enormmode Mnorm;
}; // class WaveformNormalizer
class TraceHeader {
public:
TraceHeader(const bool& last=false):
MuseINFO(false), MuseFREE(false), Mislast(last) { }
TraceHeader(const FREE& free, const bool& last=false):
MuseINFO(false), MuseFREE(true), Mislast(last),
Mfree(free) { }
TraceHeader(const INFO& info, const bool& last=false):
MuseINFO(true), MuseFREE(false), Mislast(last),
Minfo(info) { }
TraceHeader(const INFO& info, const FREE& free, const bool& last=false):
MuseINFO(true), MuseFREE(true), Mislast(last),
Mfree(free), Minfo(info) { }
bool last() const { return(Mislast); }
TraceHeader(const WID2& wid2, const bool& last=false): Mwid2(wid2)
{ Mdast.hasfree=false; Mdast.hasinfo=false; Mdast.last=last; }
TraceHeader(const WID2& wid2, const FREE& free, const bool& last=false):
Mwid2(wid2), Mfree(free)
{ Mdast.hasfree=true; Mdast.hasinfo=false; Mdast.last=last; }
TraceHeader(const WID2& wid2, const INFO& info, const bool& last=false):
Mwid2(wid2), Minfo(info)
{ Mdast.hasfree=false; Mdast.hasinfo=true; Mdast.last=last; }
TraceHeader(const WID2& wid2, const INFO& info,
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;
bool last() const { return(Mdast.last); }
template<class C> void scanseries(const C&,
const Enormmode& nm=NM_maxdyn);
const WID2& wid2() const { return(Mwid2); }
const DAST& dast() const { return(Mdast); }
const FREE& free() const { return(Mfree); }
const INFO& info() const { return(Minfo); }
const bool& scale() const { return(Mscale); }
private:
bool MuseINFO;
bool MuseFREE;
bool Mislast;
WID2 Mwid2;
DAST Mdast;
FREE Mfree;
INFO Minfo;
bool Mscale;
}; // class TraceHeader
/*! \brief class to normalize waveforms
*/
class WaveformNormalizer {
}; // class WaveformNormalizer
class Waveform {
}; // class Waveform
template<class C>
class OutputWaveform {
public:
typedef typename C::Tcoc Tcoc;
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.
}
void write(std::ostream& os) const;
private:
Tcoc Mseries;
TraceHeader Mheader;
WaveformNormalizer Mnorm;
}; // class Waveform
class SkipWaveform {
}; // class SkipWaveform
......@@ -193,14 +231,69 @@ namespace sff {
// I/O operators
// -------------
std::istream& operator >> (std::istream&, FileHeader&);
std::istream& operator >> (std::istream&, TraceHeader&);
std::istream& operator >> (std::istream&, Waveform&);
std::istream& operator >> (std::istream&, SkipWaveform&);
std::ostream& operator << (std::ostream&, FileHeader&);
std::ostream& operator << (std::ostream&, TraceHeader&);
std::ostream& operator << (std::ostream&, Waveform&);
inline std::istream& operator >> (std::istream& is, FileHeader& fh)
{ return(is); }
inline std::istream& operator >> (std::istream& is, TraceHeader& th)
{ return(is); }
inline std::istream& operator >> (std::istream& is, Waveform& 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); }
template<class C>
inline std::ostream& operator << (std::ostream& os, const
OutputWaveform<C>& wf)
{ wf.write(os); return(os); }
/*======================================================================*/
// WaveformNormalizer template functions
// -------------------------------------
template<class C>
void TraceHeader::scanseries(const C& c,
const Enormmode& nm=NM_maxdyn);
{
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)
{
Mwid2.nsamples++;
value= *i;
absval= (value < null) ? -value : value;
maxval= (maxval < absval) ? absval : maxval;
}
double dmaxval=double((maxval==0) ? WaveformNormalizer::limit : maxval);
WaveformNormalizer normalizer(nm, dmaxval);
Mdast.ampfac=normalizer.ampfac();
Mscale=normalizer.scale();
}
/*----------------------------------------------------------------------*/
// template OutputWaveform functions
// ---------------------------------
template<class C>
void OutputWaveform::write(std::ostream& os)
{
os << Mheader;
GSE2::waveform::TDAT2writeCM6 fwriter(Mwid2.nsamples);
int idata;
C::Tvalue data;
for(aff::Iterator<C> i(c); i.valid(); ++i)
{
data= *i;
if (Mheader.scale())
{ idata=int(std::nearbyint(data*Mheader.dast().ampfac)); }
else
{ idata=int(std::nearbyint(data)); }
os << fwriter(idata);
}
}
} // namespace sff
#endif // TF_SFFXX_H_VERSION (includeguard)
......
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