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

add stuff of the discontinued branch branches/any2matlab0.2

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/branches/libdatreadxx.tfascii
SVN Revision: 3259
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent ba589af7
......@@ -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
......
......@@ -35,6 +35,7 @@
* - 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
*
* ============================================================================
*/
......@@ -44,14 +45,15 @@
"$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
*
* ============================================================================
*/
......@@ -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
*
* ----------------------------------------------------------------------------
*
* $Id: $
* \author Daniel Armbruster
* \date 14/10/2010
*
* Purpose:
*
* ----
* 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
*
* ============================================================================
*/
/* ----- END OF tfasciitest.cc ----- */
\ No newline at end of file
/*! \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
*
* \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;
//typedef aff::Series<double> Tseries;
//! constructor
/*!
\param is the input stream
*/
itfasciistream(std::istream& is);
//! 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
//! DANGER only set the header data
virtual void skipseries() { set_header(); }
//! print some info about data conversion
/*!
\param os the output stream
*/
static void help(std::ostream& os=std::cout)
{ Tbase::help(os, const_cast<char*>("itfasciistream")); }
private:
//! pointer to a tfascii trace
datread::tfascii::TfasciiContainer *tfasciitrace;
//! set the header data
void set_header();
}; // 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>
#include<datreadxx/util.h>
namespace datread {
namespace tfascii {
/*----------------------------------------------------------------------*/
//! constructor
TfasciiContainer::TfasciiContainer() : Mheaderset(false) {
Mheader = new datread::tfascii::Header;
}
//! destructor
TfasciiContainer::~TfasciiContainer() {
delete Mheader;
}
/*----------------------------------------------------------------------*/
// public functions
tfascii::Header TfasciiContainer::get_header(std::istream& is) {
readheader(is);
return *Mheader;
}
template<class T>
T TfasciiContainer::get_series(std::istream& is) {
if(Mheaderset) {
return datread::util::readany<T>(is, Mheader->wid2.nsamples);
}
else
{
throw;
}
}
/*---------------------------------------------------------------------*/
// private functions
void TfasciiContainer::detectblocks(std::istream& is, const bool& verbose) {
std::string line;
int countFREE = 0;
int mandatory = 0;
// set all values to false
Mheader->hastracefree = false;
Mheader->hasfilefree = false;
Mheader->hasinfo = false;
Mheader->hassrce = false;
Mheader->haswid2 = false;
// check
while (is.good())
{
getline(is, line);
if (line == "contents of SFF SRCE line:")
{
Mheader->hassrce = true;
mandatory++;
} else
if (line == "file header contains no SRCE line")
{
Mheader->hassrce = false;
mandatory++;
} else
if ((line == "contents of SFF FREE block:") && (countFREE == 0))
{
Mheader->hasfilefree = true;
countFREE++;
mandatory++;
} else
if ((line == "file header contains no FREE block") && (countFREE == 0))
{
Mheader->hasfilefree = false;
countFREE++;
mandatory++;
} else
if (line == "contents of SFF WID2 line:")
{
Mheader->haswid2 = true;
mandatory++;
} else
if (line == "contents of SFF INFO line:")
{
Mheader->hasinfo = true;
mandatory++;
} else
if (line == "trace header contains no INFO line")
{
Mheader->hasinfo = false;
mandatory++;
} else
if ((line == "contents of SFF FREE block:") && (countFREE == 1))
{
Mheader->hastracefree = true;
mandatory++;
} else
if ((line == "trace header contains no FREE block") && (countFREE == 1))
{
Mheader->hastracefree = false;
mandatory++;
}
if (mandatory > 5) { break; }
}
if (mandatory < 5) throw;
if(verbose)
{
if(Mheader->hassrce)
{
std::cout << "SFF SRCE line detected." << std::endl;
}
if(Mheader->hasfilefree)
{
std::cout << "file FREE block detected." << std::endl;
}
if(Mheader->haswid2)
{
std::cout << "SFF WID2 line detected." << std::endl;
}
if(Mheader->hasinfo)
{
std::cout << "SFF INFO line detected." << std::endl;
}
if(Mheader->hastracefree)
{
std::cout << "trace FREE block detected." << std::endl;
}
}
}
void TfasciiContainer::extractvalue(std::string& line, bool unit)
{
if (unit)
{
std::string tmp = line.substr(0,line.rfind(" "));
line = tmp.substr(tmp.rfind(" ")+1);
}
else
{
line = line.substr(line.rfind(" ")+1);
}
}
void TfasciiContainer::readheader(std::istream& is, const bool& verbose)
{
std::string line;
int countFREE = 0;
std::pair<std::string, std::string> tmp;
detectblocks(is, verbose);
// get SRCE line if available
if(Mheader->hassrce) {
bool hot = true;
while (hot && is.good())
{
getline(is, line);
if (line == "contents of SFF SRCE line:")
{
int cnt = 0;
while (getline(is, line))
{
switch (cnt)
{
case 0:
extractvalue(line);
Mheader->srce.type = line;
break;
case 1:
extractvalue(line);
if (line == "cartesian")
{
Mheader->srce.cs = sff::Ecoosys(0);
}
else
{
Mheader->srce.cs = sff::Ecoosys(1);
}
break;
case 2:
extractvalue(line, true);
Mheader->srce.cx = std::atof(line.c_str());
break;
case 3:
extractvalue(line, true);
Mheader->srce.cy = std::atof(line.c_str());
break;
case 4:
extractvalue(line, true);
Mheader->srce.cz = std::atof(line.c_str());
break;
case 5:
{
extractvalue(line);
std::istringstream iss(line);
char c;
int doy, day, month, year, hour, minute;
double seconds;
iss >> doy;
iss >> day >> c >> month >> c >> year;
iss >> hour >> c >> minute >> c >> seconds;
Mheader->srce.date=libtime::TAbsoluteTime(year,month,day,hour,minute);
Mheader->srce.date+=libtime::double2time(seconds);
Mheader->srce.date.setdoy(doy);
break;
}
default:
throw;
}
++cnt;
if (cnt > 5)
{
hot = false;
break;
}
}