Commit f6868d6f authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

reintegrate merge of branches/libdatreadxx.tfascii into trunk

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: 3327
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b688c168
......@@ -35,6 +35,7 @@
# - copy headers (no symbolic links)
# - new doxygen definitions
# - package creation not yet implemented
# 14/10/2010 V1.5 included tfascii reading
#
# ============================================================================
#
......@@ -50,10 +51,10 @@ CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)
$(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR)
LIBHEADERS=$(wildcard *.h sff/*.h tsoft/*.h)
LIBHEADERS=$(wildcard *.h sff/*.h tsoft/*.h tfascii/*.h)
LIBHEADERS+=$(wildcard bonjer/*.h pdas/*.h mseed/*.h hpmo/*.h sac/*.h gse/*.h)
LIBSRC=$(wildcard *.cc sff/*.cc tsoft/*.cc)
LIBSRC=$(wildcard *.cc sff/*.cc tsoft/*.cc tfascii/*.cc)
LIBSRC+=$(wildcard bonjer/*.cc pdas/*.cc mseed/*.cc hpmo/*.cc sac/*.cc gse/*.cc)
TESTHEADERS=$(wildcard tests/*.h)
......@@ -100,6 +101,7 @@ clean: ;
-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.hd | xargs --no-run-if-empty /bin/rm -v
-find . -name \*.strip | xargs --no-run-if-empty /bin/rm -v
-/bin/rm -vf flist
......@@ -209,7 +211,7 @@ PACKAGE=libdatreadxx
# test code
# ---------
sactest hpmotest mseedtest pdastest \
sactest hpmotest mseedtest pdastest tfasciitest\
tsofttest sfftest: %: tests/%.o libdatreadxx.a
$(CXX) $(FLAGS) -o $@ $< -I$(LOCINCLUDEDIR) \
-ldatreadxx -lsffxx -lgsexx -ltsxx -ltfxx -laff -ltime++ \
......
......@@ -69,6 +69,7 @@ $Id$
- hpmo: HP-MO data format defined by W. Grossmann (BFO)
- bonjer: K2 ASCII data format (defined by K. Bonjer?)
- tsoft: TSOFT format (http://seismologie.oma.be/TSOFT/tsoft.html)
- tfascii: output data of T. Forbriger's any2ascii
Each format specific module will be placed into its own namespace, like
datread::hpmo.
......
......@@ -35,23 +35,25 @@
* - 19/09/2007 V1.4 added raw GSE format
* - 12/11/2009 V1.5 added TSOFT format
* - 03/05/2010 V1.6 sac provides debugging
* - 06/10/2010 V1.7 added ASCII format of T. Forbrigers any2ascii
*
* ============================================================================
*/
#define DATREAD_READANY_CC_VERSION \
"DATREAD_READANY_CC V1.6"
"DATREAD_READANY_CC V1.7"
#define DATREAD_READANY_CC_CVSID \
"$Id$"
#include <datreadxx/readany.h>
#include<datreadxx/sff.h>
#include<datreadxx/pdas.h>
#include<datreadxx/hpmo.h>
#include<datreadxx/mseed.h>
#include<datreadxx/bonjer.h>
#include<datreadxx/sac.h>
#include<datreadxx/gse.h>
#include<datreadxx/tsoft.h>
#include <datreadxx/sff.h>
#include <datreadxx/pdas.h>
#include <datreadxx/hpmo.h>
#include <datreadxx/mseed.h>
#include <datreadxx/bonjer.h>
#include <datreadxx/sac.h>
#include <datreadxx/gse.h>
#include <datreadxx/tsoft.h>
#include <datreadxx/tfascii.h>
#include <datreadxx/error.h>
namespace datread {
......@@ -59,18 +61,19 @@ namespace datread {
ianystream::ianystream(std::istream& is, const Eformat& format,
const bool& debug):
Mformat(format)
{
if (Mformat==Fbonjer) { Mis=new ibonjerstream(is); }
else if (Mformat==Fpdas) { Mis=new ipdasstream(is); }
else if (Mformat==Fsff) { Mis=new isffstream(is, debug); }
else if (Mformat==Fhpmo) { Mis=new ihpmostream(is); }
else if (Mformat==Fmseed) { Mis=new imseedstream(is, debug); }
else if (Mformat==Fsac) { Mis=new isacstream(is, debug); }
else if (Mformat==Fgse) { Mis=new igsestream(is); }
else if (Mformat==Ftsoft) { Mis=new itsoftstream(is); }
else
{ DATREAD_abort("ERROR (ianystream): unknown format!"); }
}
{
if (Mformat==Fbonjer) { Mis=new ibonjerstream(is); }
else if (Mformat==Fpdas) { Mis=new ipdasstream(is); }
else if (Mformat==Fsff) { Mis=new isffstream(is, debug); }
else if (Mformat==Fhpmo) { Mis=new ihpmostream(is); }
else if (Mformat==Fmseed) { Mis=new imseedstream(is, debug); }
else if (Mformat==Fsac) { Mis=new isacstream(is, debug); }
else if (Mformat==Fgse) { Mis=new igsestream(is); }
else if (Mformat==Ftsoft) { Mis=new itsoftstream(is); }
else if (Mformat==Ftfascii) { Mis=new itfasciistream(is); }
else
{ DATREAD_abort("ERROR (ianystream): unknown format!"); }
}
/*----------------------------------------------------------------------*/
......@@ -101,6 +104,8 @@ namespace datread {
{ retval=Fgse; }
else if (id=="tsoft")
{ retval=Ftsoft; }
else if (id=="tfascii")
{ retval=Ftfascii; }
else { DATREAD_abort("unknown data type identifier!"); }
return(retval);
}
......@@ -110,14 +115,15 @@ namespace datread {
{
std::string retval="NSP";
switch(id) {
case Fpdas: retval="pdas"; break;
case Fsff: retval="sff"; break;
case Fhpmo: retval="hpmo"; break;
case Fmseed: retval="mseed"; break;
case Fbonjer: retval="bonjer"; break;
case Fsac: retval="sac"; break;
case Fgse: retval="gse"; break;
case Ftsoft: retval="tsoft"; break;
case Fpdas: retval="pdas"; break;
case Fsff: retval="sff"; break;
case Fhpmo: retval="hpmo"; break;
case Fmseed: retval="mseed"; break;
case Fbonjer: retval="bonjer"; break;
case Fsac: retval="sac"; break;
case Fgse: retval="gse"; break;
case Ftsoft: retval="tsoft"; break;
case Ftfascii: retval="tfascii"; break;
default: DATREAD_abort("unknown data type ID#!");
}
return(retval);
......@@ -129,16 +135,17 @@ namespace datread {
void supported_data_types(std::ostream& os)
{
os << "data formats supported by ianystream:" << std::endl;
os << " sff: Stuttgart File Format" << std::endl;
os << " hpmo: HP-MO data format defined by W. Grossmann (BFO)"
os << " sff: Stuttgart File Format" << std::endl;
os << " hpmo: HP-MO data format defined by W. Grossmann (BFO)"
<< std::endl;
os << " pdas: PDAS100 (i.e. DaDisp)" << std::endl;
os << " mseed: MiniSEED (SeisComP, EDL, etc.)" << std::endl;
os << " bonjer: K2 ASCII data format (defined by K. Bonjer?)"
os << " pdas: PDAS100 (i.e. DaDisp)" << std::endl;
os << " mseed: MiniSEED (SeisComP, EDL, etc.)" << std::endl;
os << " bonjer: K2 ASCII data format (defined by K. Bonjer?)"
<< std::endl;
os << " sac: SAC binary format" << std::endl;
os << " gse: raw GSE format" << std::endl;
os << " tsoft: TSOFT format" << std::endl;
os << " sac: SAC binary format" << std::endl;
os << " gse: raw GSE format" << std::endl;
os << " tsoft: TSOFT format" << std::endl;
os << " tfascii: ASCII format of T. Forbrigers any2ascii" << std::endl;
os << DATREAD_READANY_CC_CVSID << std::endl;
}
......@@ -147,8 +154,8 @@ namespace datread {
void online_help(std::ostream& os)
{
os << std::endl
<< "Online help obtained from data extraction facilities:"
<< std::endl;
<< "Online help obtained from data extraction facilities:"
<< std::endl;
os << "SFF data: "; isffstream::help(os);
os << std::endl;
os << "HPMO data: "; ihpmostream::help(os);
......@@ -164,6 +171,8 @@ namespace datread {
os << "GSE data: "; igsestream::help(os);
os << std::endl;
os << "TSOFT data: "; itsoftstream::help(os);
os << std::endl;
os << "TFASCII data: "; itfasciistream::help(os);
}
} // namespace datread
......
......@@ -32,6 +32,7 @@
* - 29/06/2007 V1.1 added SAC binary format
* - 19/09/2007 V1.2 added raw GSE format
* - 12/11/2009 V1.3 added TSOFT data
* - 06/10/2010 V1.4 added ASCII format of T. Forbrigers any2ascii
*
* ============================================================================
*/
......@@ -40,7 +41,7 @@
#ifndef DATREAD_READANY_H_VERSION
#define DATREAD_READANY_H_VERSION \
"DATREAD_READANY_H V1.3"
"DATREAD_READANY_H V1.4"
#define DATREAD_READANY_H_CVSID \
"$Id$"
......@@ -49,14 +50,15 @@
namespace datread {
enum Eformat {
Fsff, //<! SFF data
Fpdas, //<! PDAS data
Fhpmo, //<! BFO HP-MO data (Grossmann format)
Fmseed, //<! MiniSEED data
Fbonjer,//<! Format specified by K. Bonjer
Fsac, //<! SAC binary data
Fgse, //<! raw GSE data
Ftsoft //<! TSOFT data
Fsff, //<! SFF data
Fpdas, //<! PDAS data
Fhpmo, //<! BFO HP-MO data (Grossmann format)
Fmseed, //<! MiniSEED data
Fbonjer, //<! Format specified by K. Bonjer
Fsac, //<! SAC binary data
Fgse, //<! raw GSE data
Ftsoft, //<! TSOFT data
Ftfascii //<! ASCII format of T. Forbrigers any2ascii
}; // enum Eformat
#define ANYDELEGATE( function ) function() const { return(Mis->function()); }
......
/*! \file tfasciitest.cc
* \brief test tfascii reading
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Daniel Armbruster
* \date 14/10/2010
*
* Purpose: test tfascii reading
*
* ----
* This file is part of libdatreadxx.
*
* libdatreadxx 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 3 of the License, or
* (at your option) any later version.
*
* libdatreadxx 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 libdatreadxx. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* Copyright (c) 2010 by Daniel Armbruster
*
* REVISIONS and CHANGES
* 14/10/2010 V0.1 Daniel Armbruster
*
* ============================================================================
*/
#define TFASCIITEST_VERSION \
"TFASCIITEST V1.0 test tfascii reading"
#define TFASCIITEST_CVSID \
"$Id$"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <tfxx/commandline.h>
#include <datreadxx/error.h>
#include <datreadxx/tfascii.h>
#include <datreadxx/readany.h>
using std::cout;
using std::cerr;
using std::endl;
struct Options {
bool verbose, dseries, fseries, iseries, skip, micsecs;
}; // struct Options
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
TFASCIITEST_VERSION "\n"
"usage: tfasciitest [-v] [-dseries] [-fseries] [-iseries] [-skip]" "\n"
" [-micsecs] filename" "\n"
" or: tfasciitest --help" "\n"
};
// define full help text
char help_text[]=
{
TFASCIITEST_CVSID "\n"
"filename file to read" "\n"
"-v be verbose" "\n"
"-dseries test reading a double series" "\n"
"-fseries test reading a float series" "\n"
"-iseries test reading a integer series" "\n"
"-skip test to skip a series and read only the header data" "\n"
"-micsecs test the output of the microseconds in the date values" "\n"
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: read double series
{"dseries",arg_no,"-"},
// 3: read float series
{"fseries",arg_no,"-"},
// 4: read integer series
{"iseries",arg_no,"-"},
// 5: skip trace and read only header
{"skip",arg_no,"-"},
// 6: print date values including microseconds
{"micsecs",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);
}
Options opt;
opt.verbose=cmdline.optset(1);
opt.dseries=cmdline.optset(2);
opt.fseries=cmdline.optset(3);
opt.iseries=cmdline.optset(4);
opt.skip=cmdline.optset(5);
opt.micsecs=cmdline.optset(6);
DATREAD_assert(cmdline.extra(), "missing filename!");
/*----------------------------------------------------------------------*/
while (cmdline.extra())
{
std::string infile=cmdline.next();
std::ifstream ifs(infile.c_str());
DATREAD_assert(ifs.good(), "invalid file!");
datread::itfasciistream is(ifs, opt.verbose);
if (opt.verbose)
{
cout << "Reading file " << infile << endl;
if (opt.dseries)
{
cout << endl << "TEST: double reading" << endl;
} else
if (opt.fseries)
{
cout << endl << "TEST: float reading" << endl;
} else
if (opt.iseries)
{
cout << endl << "TEST: integer reading" << endl;
}
cout << "=====================" << endl;
if (is.hassrce())
{
cout << is.srce().line();
if (opt.micsecs)
{
cout << "Test micsecs in SRCE date: "
<< is.srce().date.timestring() << endl;
}
}
if (is.hasfree()) { is.free().write(cout); }
}
datread::Tdseries dseries;
datread::Tfseries fseries;
datread::Tiseries iseries;
if (opt.skip) { is.skipseries(); } else
if (opt.dseries) { is >> dseries; } else
if (opt.fseries) { is >> fseries; } else
if (opt.iseries) { is >> iseries; }
if (opt.verbose)
{
cout << endl;
// print traceheader
cout << is.wid2().line();
if (opt.micsecs)
{
cout << "Test micsecs in WID2 date: "
<< is.wid2().date.timestring() << endl;
}
if (is.hasinfo()) { cout << is.info().line(); }
if (is.hasfree()) { is.free().write(cout); }
cout << endl;
// print series
if (opt.dseries && !opt.skip)
{
cout << "data:" << endl;
for (int isample=dseries.first(); isample<=dseries.last();
++isample)
{
cout << std::setprecision(7) << std::scientific << std::showpos
<< dseries(isample) << endl;
}
} else
if (opt.fseries && !opt.skip)
{
cout << "data:" << endl;
for (int isample=fseries.first(); isample<=fseries.last();
++isample)
{
cout << std::setprecision(7) << std::scientific << std::showpos
<< fseries(isample) << endl;
}
} else
if (opt.iseries && !opt.skip)
{
cout << "data:" << endl;
for (int isample=iseries.first(); isample<=iseries.last();
++isample)
{
cout << iseries(isample) << endl;
}
}
}
}
}
/* ----- END OF tfasciitest.cc ----- */
/*! \file tfascii.h
* \brief read Thomas Forbrigers ASCII data (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: tfascii.h 3242 2010-10-12 03:36:59Z damb $
* \author Daniel Armbruster
* \date 05/10/2010
*
* Purpose: read Thomas Forbrigers ASCII data (prototypes)
*
* ----
* This file is part of libdatreadxx.
*
* libdatreadxx 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 3 of the License, or
* (at your option) any later version.
*
* libdatreadxx 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 libdatreadxx. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* Copyright (c) 2010 by Daniel Armbruster
*
* REVISIONS and CHANGES
* 05/10/2010 V0.1 Daniel Armbruster
*
* ============================================================================
*/
#ifndef DATREAD_TFASCII_H_VERSION
#define DATREAD_TFASCII_H_VERSION \
"DATREAD_TFASCII_H V1.0 "
#define DATREAD_TFASCII_H_SVNID \
"$Id: tfascii.h 3242 2010-10-12 03:36:59Z damb $"
#include <datreadxx/datread.h>
#include <datreadxx/readtfascii.h>
namespace datread {
/*! \brief input stream to read seismic data provided by T. Forbriger's
* \brief any2ascii
*
* \ingroup tfascii
*
* The concept is based on SFF data contents and we will make use of SFF
* structures.
*/
class itfasciistream: public idatstream {
public:
typedef idatstream Tbase;
//! constructor
/*!
\param is the input stream
\param verbose for verbose output
*/
itfasciistream(std::istream& is, const bool& verbose = false);
//! destructor
virtual ~itfasciistream();
//! to read the data as double
/*!
\return the timeseries (double)
*/
virtual Tdseries dseries();
//! to read the data as float
/*!
\return the timeseries (float)
*/
virtual Tfseries fseries();
//! to read the data as integer
/*!
\return the timeseries (integer)
*/
virtual Tiseries iseries();
//! reads only the header of the data
virtual void skipseries() { set_traceheader(); }
//! print some info about data conversion
/*!
\param os the output stream
*/
static void help(std::ostream& os=std::cout);
private:
//! for verbose output
const bool Mverbose;
//! set the file header data
void set_fileheader();
//! set the trace header data
void set_traceheader();
//! member function
/*!
\return if verbose output is decided
*/
bool get_verbose() const;
}; // class itfasciistream
} // namespace datread
#endif // DATREAD_TFASCII_H_VERSION (includeguard)
/* ----- END OF tfascii.h ----- */
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-03-01. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
/*! \file readtfascii.cc
* \brief read data obtained in ASCII (any2ascii) from T. Forbriger
* \brief (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: readtfascii.cc 3242 2010-10-12 03:36:59Z damb $
* \author Daniel Armbruster
* \date 05/10/2010
*
* Purpose: read data obtained in ASCII (any2ascii) from T. Forbriger
* (implementation)
* ----
* This file is part of libdatreadxx.
*
* libdatreadxx 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 3 of the License, or
* (at your option) any later version.
*
* libdatreadxx 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 libdatreadxx. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* Copyright (c) 2010 by Daniel Armbruster
*
* REVISIONS and CHANGES
* 05/10/2010 V0.1 Daniel Armbruster
*
* ============================================================================
*/
#define DATREAD_READTFASCII_CC_VERSION \
"DATREAD_READTFASCII_CC V1.0 "
#define DATREAD_READTFASCII_CC_CVSID \
"$Id: readtfascii.cc 3242 2010-10-12 03:36:59Z damb $"
#include<cstdlib>
#include<sstream>
#include<libtime++.h>
#include<datreadxx/readtfascii.h>