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

now converts PDAS data of any length

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: 1515
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 4247c67a
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: pdas.cc,v 1.4 2004-04-07 11:11:58 tforb Exp $
* $Id: pdas.cc,v 1.5 2004-04-07 13:22:49 tforb Exp $
* \author Thomas Forbriger
* \date 30/03/2004
*
......@@ -19,7 +19,7 @@
#define DATREAD_PDAS_CC_VERSION \
"DATREAD_PDAS_CC V1.0 "
#define DATREAD_PDAS_CC_CVSID \
"$Id: pdas.cc,v 1.4 2004-04-07 11:11:58 tforb Exp $"
"$Id: pdas.cc,v 1.5 2004-04-07 13:22:49 tforb Exp $"
#include <algorithm>
#include <iterator>
......@@ -76,6 +76,9 @@ namespace datread {
void ipdasstream::readheader()
{
Mwid2set=false;
Mtracefreeset=false;
Mlast=false;
datread::pdas::Header hd=datread::pdas::readheader(Mis);
Mfilefreeset=true;
std::copy(hd.lines.begin(), hd.lines.end(),
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.cc,v 1.8 2004-02-23 14:36:59 tforb Exp $
* $Id: sffxx.cc,v 1.9 2004-04-07 13:22:49 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -15,13 +15,16 @@
* - 21/12/2003 V1.0 Thomas Forbriger
* - 23/02/2004 V1.1 changed DAST and STAT reading code
* there are not necessarily any flag characters
* - 07/04/2004 V1.2
* - provide debug output
* - correct reading of FREE block
*
* ============================================================================
*/
#define TF_SFFXX_CC_VERSION \
"TF_SFFXX_CC V1.0 "
"TF_SFFXX_CC V1.2"
#define TF_SFFXX_CC_CVSID \
"$Id: sffxx.cc,v 1.8 2004-02-23 14:36:59 tforb Exp $"
"$Id: sffxx.cc,v 1.9 2004-04-07 13:22:49 tforb Exp $"
#include<sstream>
#include <sffxx.h>
......@@ -224,7 +227,7 @@ namespace sff {
return(retval);
} // DAST::line()
void DAST::read(std::istream& fis)
void DAST::read(std::istream& fis, const bool& debug)
{
std::string theline("");
const int bufsize=81;
......@@ -240,6 +243,11 @@ namespace sff {
is >> ampfac;
std::string code;
is >> code;
if (debug)
{
std::cerr << "DEBUG (DAST): read nchar=" << nchar
<< " ampfac=" << ampfac << " code=" << code << std::endl;
}
this->hasinfo=(code.find('I')!=std::string::npos);
this->hasfree=(code.find('F')!=std::string::npos);
this->last=(code.find('D')==std::string::npos);
......@@ -260,23 +268,22 @@ namespace sff {
os << FREE::LINEID << " " << std::endl;
} // FREE::write
void FREE::read(std::istream& is)
void FREE::read(std::istream& is, const bool& debug)
{
std::string lineID;
// getline(is,lineID);
is >> lineID;
if (!helper::IDmatch<FREE>(lineID)) throw
if (debug)
{ std::cerr << "DEBUG (FREE): lineID=" << lineID << std::endl; }
if (!helper::IDmatch<FREE>(lineID.substr(0,4))) throw
GSE2::Terror("ERROR (FREE::read): missing FREE ID!");
lines.clear();
std::string theline("");
const int bufsize=81;
char inputline[bufsize];
is.getline(inputline,bufsize);
theline=inputline;
while (!helper::IDmatch<FREE>(theline))
is.ignore(10,'\n');
getline(is,lineID);
while (!helper::IDmatch<FREE>(lineID.substr(0,4)))
{
lines.push_back(theline);
is.getline(inputline,bufsize);
theline=inputline;
lines.push_back(lineID);
getline(is,lineID);
}
} // FREE::read
......@@ -392,26 +399,48 @@ namespace sff {
void TraceHeader::writeheader(std::ostream& os) const
{
if (Mdebug) { std::cerr << "DEBUG: write DAST line" << std::endl; }
os << Mdast.line();
if (Mdebug) { std::cerr << "DEBUG: write WID2 line" << std::endl; }
os << Mwid2.line();
}
void TraceHeader::writetrailer(std::ostream& os) const
{
if (Mdast.hasfree) { Mfree.write(os); }
if (Mdast.hasinfo) { os << Minfo.line(); }
if (Mdast.hasfree)
{
if (Mdebug) { std::cerr << "DEBUG: write FREE block" << std::endl; }
Mfree.write(os);
}
if (Mdast.hasinfo)
{
if (Mdebug) { std::cerr << "DEBUG: write INFO line" << std::endl; }
os << Minfo.line();
}
}
void TraceHeader::readheader(std::istream& is)
{
Mdast.read(is);
if (Mdebug) { std::cerr << "DEBUG: read DAST line" << std::endl; }
Mdast.read(is,Mdebug);
if (Mdebug) { std::cerr << "DEBUG: read WID2 line" << std::endl; }
Mwid2.read(is);
}
void TraceHeader::readtrailer(std::istream& is)
{
if (Mdast.hasfree) { Mfree.read(is); }
if (Mdast.hasinfo) { Minfo.read(is); }
if (Mdebug) { std::cerr << "DEBUG: read trace trailer" << std::endl; }
if (Mdast.hasfree)
{
if (Mdebug) { std::cerr << "DEBUG: read FREE block" << std::endl; }
Mfree.read(is, Mdebug);
if (Mdebug) { Mfree.write(std::cerr); }
}
if (Mdast.hasinfo)
{
if (Mdebug) { std::cerr << "DEBUG: read INFO line" << std::endl; }
Minfo.read(is);
}
}
/*----------------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.h,v 1.16 2004-03-16 21:14:56 tforb Exp $
* $Id: sffxx.h,v 1.17 2004-04-07 13:22:50 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -29,7 +29,7 @@
#define TF_SFFXX_H_VERSION \
"TF_SFFXX_H V1.2 "
#define TF_SFFXX_H_CVSID \
"$Id: sffxx.h,v 1.16 2004-03-16 21:14:56 tforb Exp $"
"$Id: sffxx.h,v 1.17 2004-04-07 13:22:50 tforb Exp $"
#include<string>
#include<cmath>
......@@ -98,7 +98,7 @@ namespace sff {
FREE();
FREE(std::istream& is) { read(is); }
void write(std::ostream& os) const;
void read(std::istream& is);
void read(std::istream& is, const bool& debug=false);
void append(const std::string& line) { lines.push_back(line); }
Tlines lines;
}; // struct FREE
......@@ -121,7 +121,7 @@ namespace sff {
DAST();
DAST(std::istream& is) { read(is); }
std::string line() const;
void read(std::istream& is);
void read(std::istream& is, const bool& debug=false);
public:
int nchar;
double ampfac;
......@@ -219,18 +219,19 @@ namespace sff {
class TraceHeader {
public:
TraceHeader() { }
TraceHeader(const WID2& wid2, const bool& last=false): Mwid2(wid2)
TraceHeader(): Mdebug(false) { }
TraceHeader(const WID2& wid2, const bool& last=false):
Mwid2(wid2), Mdebug(false)
{ Mdast.hasfree=false; Mdast.hasinfo=false; Mdast.last=last; }
TraceHeader(const WID2& wid2, const FREE& free, const bool& last=false):
Mwid2(wid2), Mfree(free)
Mwid2(wid2), Mfree(free), Mdebug(false)
{ Mdast.hasfree=true; Mdast.hasinfo=false; Mdast.last=last; }
TraceHeader(const WID2& wid2, const INFO& info, const bool& last=false):
Mwid2(wid2), Minfo(info)
Mwid2(wid2), Minfo(info), Mdebug(false)
{ 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)
Mwid2(wid2), Mfree(free), Minfo(info), Mdebug(false)
{ Mdast.hasfree=true; Mdast.hasinfo=true; Mdast.last=last; }
void writeheader(std::ostream&) const;
void writetrailer(std::ostream&) const;
......@@ -247,6 +248,7 @@ namespace sff {
const bool& hasinfo() const { return(Mdast.hasinfo); }
const bool& hasfree() const { return(Mdast.hasfree); }
void setlast(const bool& flag) { Mdast.last=flag; }
void setdebug(const bool& flag) { Mdebug=flag; }
void setwid2(const WID2& wid2line) { Mwid2=wid2line; }
void setnsamples(const long int& n) { Mwid2.nsamples=n; }
void setinfo(const INFO& infoline)
......@@ -261,6 +263,7 @@ namespace sff {
FREE Mfree;
INFO Minfo;
bool Mscale;
bool Mdebug;
}; // class TraceHeader
template<class C>
......@@ -282,7 +285,8 @@ namespace sff {
public:
typedef C Tcontainer;
InputWaveform(): Mvalid(false) { }
InputWaveform(std::istream& is) { this->read(is); }
InputWaveform(std::istream& is, const bool& debug=false):
Mdebug(debug) { this->read(is); }
void read(std::istream& is);
const bool& valid() const { return(Mvalid); }
Tcontainer series() const { return(Mseries); }
......@@ -292,6 +296,7 @@ namespace sff {
bool Mvalid;
Tcontainer Mseries;
TraceHeader Mheader;
bool Mdebug;
}; // class InputWaveform
class SkipWaveform {
......@@ -392,7 +397,8 @@ namespace sff {
void InputWaveform<C>::read(std::istream& is)
{
typedef typename C::Tvalue Tvalue;
Mheader.readheader(is);;
Mheader.setdebug(Mdebug);
Mheader.readheader(is);
int nsamples=Mheader.wid2().nsamples;
GSE2::waveform::TDAT2readCM6 freader(nsamples);
try {
......
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