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

first compiling version of GSE reading

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: 2401
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent fbc17d22
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.33 2007-06-29 13:20:52 tforb Exp $
# $Id: Makefile,v 1.34 2007-09-19 10:51:01 tforb Exp $
#
# Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
#
......@@ -28,6 +28,7 @@
# REVISIONS and CHANGES
# 30/03/2004 V1.0 Thomas Forbriger
# 29/06/2007 V1.1 included SAC binary reading
# 19/09/2007 V1.2 included raw GSE reading
#
# ============================================================================
#
......@@ -37,7 +38,7 @@ HEADERS=datread.h bonjer.h bonjer/readbonjer.h readany.h error.h \
pdas.h pdas/pdasread.h pdas/pdasflags.h mseed/seedstructdump.h \
sff.h mseed.h mseed/mseedread.h mseed/seedstructs.h \
hpmo.h hpmo/readhpmo.h hpmo/hpmodata.h util.h sac.h sac/sacread.h \
bytesex.h debug.h
bytesex.h debug.h gse.h gse/gseread.h
#SRC=misc/fortranio.cc misc/commandline.cc misc/ioswap.cc misc/error.cc \
# misc/blitzfortranio.cc hacks/hack_blitztogrepg.cc
......@@ -46,7 +47,7 @@ LIBSRC=datread.cc bonjer/bonjer.cc bonjer/readbonjer.cc readany.cc error.cc \
pdas/pdas.cc pdas/pdasread.cc mseed/seedstructdump.cc \
sff/sff.cc mseed/mseedread.cc mseed/mseed.cc mseed/seedstructs.cc \
hpmo/hpmo.cc hpmo/readhpmo.cc hpmo/hpmodata.cc \
util.cc sac/sac.cc sac/sacread.cc bytesex.cc
util.cc sac/sac.cc sac/sacread.cc bytesex.cc gse/gseread.cc gse/gse.cc
TESTSRC=tests/hpmotest.cc tests/pdastest.cc tests/mseedtest.cc \
tests/sfftest.cc tests/sactest.cc
......
/*! \file gse.h
* \brief read raw GSE data (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: gse.h,v 1.1 2007-09-19 10:51:02 tforb Exp $
* \author Thomas Forbriger
* \date 19/09/2007
*
* read raw GSE data (prototypes)
*
* Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_GSE_H_VERSION
#define TF_GSE_H_VERSION \
"TF_GSE_H V1.0 "
#define TF_GSE_H_CVSID \
"$Id: gse.h,v 1.1 2007-09-19 10:51:02 tforb Exp $"
#include<datreadxx/datread.h>
namespace datread {
/*! \brief class to read raw GSE data
* \ingroup gse
*/
class igsestream: public idatstream {
public:
typedef idatstream Tbase;
igsestream(std::istream& is);
virtual ~igsestream() { }
virtual Tdseries dseries();
virtual Tfseries fseries();
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
private:
void readheader();
}; // class igsestream
} // namespace datread
#endif // TF_GSE_H_VERSION (includeguard)
/* ----- END OF gse.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 gse.cc
* \brief read raw GSE data (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: gse.cc,v 1.1 2007-09-19 10:51:02 tforb Exp $
* \author Thomas Forbriger
* \date 19/09/2007
*
* read raw GSE data (implementation)
*
* Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_GSE_CC_VERSION \
"TF_GSE_CC V1.0 "
#define TF_GSE_CC_CVSID \
"$Id: gse.cc,v 1.1 2007-09-19 10:51:02 tforb Exp $"
#include <string>
#include <sstream>
#include <datreadxx/gse.h>
#include <datreadxx/gseread.h>
#include <datreadxx/error.h>
#include <datreadxx/util.h>
namespace datread {
igsestream::igsestream(std::istream& is): Tbase(is, true, true, true)
{ }
/*----------------------------------------------------------------------*/
Tdseries igsestream::dseries()
{
return(datread::util::convert<Tiseries, Tdseries>(this->iseries()));
}
/*----------------------------------------------------------------------*/
Tiseries igsestream::iseries()
{
this->readheader();
DATREAD_assert(Mis.good(), "input stream is not good");
return(datread::gse::read_gse_data(this->Mis, this->wid2().nsamples));
}
/*----------------------------------------------------------------------*/
Tfseries igsestream::fseries()
{
return(datread::util::convert<Tiseries, Tfseries>(this->iseries()));
}
/*----------------------------------------------------------------------*/
void igsestream::skipseries()
{
this->readheader();
}
/*----------------------------------------------------------------------*/
void igsestream::readheader()
{
this->newtrace();
this->setwid2(datread::gse::next_wid2(this->Mis));
this->setlast();
}
/*----------------------------------------------------------------------*/
void igsestream::help(std::ostream& os)
{ datread::gse::help(os); }
} // namespace datread
/* ----- END OF gse.cc ----- */
/*! \file gseread.cc
* \brief raw GSE reading module (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: gseread.cc,v 1.1 2007-09-19 10:51:03 tforb Exp $
* \author Thomas Forbriger
* \date 19/09/2007
*
* raw GSE reading module (implementation)
*
* Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_GSEREAD_CC_VERSION \
"TF_GSEREAD_CC V1.0 "
#define TF_GSEREAD_CC_CVSID \
"$Id: gseread.cc,v 1.1 2007-09-19 10:51:03 tforb Exp $"
#include <datreadxx/gseread.h>
#include <datreadxx/error.h>
#include <sffxx.h>
#include <gsexx.h>
#include <sstream>
namespace datread {
namespace gse {
// find next WID2 line
sff::WID2 next_wid2(std::istream& is)
{
sff::WID2 retval;
std::string theline;
bool hot=true;
while (hot)
{
DATREAD_assert(is.good(), "input stream is not good");
std::getline(is, theline);
std::istringstream iss(theline);
hot=false;
try
{
retval.read(iss);
}
catch (...)
{
hot=true;
}
}
return(retval);
} // sff::WID2 next_wid2(std::istream& is)
/*----------------------------------------------------------------------*/
// print info about GSE reading
void help(std::ostream& os)
{
os <<
std::endl <<
"GSE reading functions" << std::endl <<
"---------------------" << std::endl <<
TF_GSEREAD_CC_VERSION << std::endl <<
TF_GSEREAD_CC_CVSID << std::endl <<
std::endl <<
"This module is designed to read raw GSE files." << std::endl <<
"Only one trace per file can be handled." << std::endl <<
"All additional line (prior to WID2 and after CHK2) are ignored."
<< std::endl;
} // void help(std::ostream& os)
/*----------------------------------------------------------------------*/
//! read samples from file
Tiseries read_gse_data(std::istream& is, const int& nsamples)
{
Tiseries retval;
typedef Tiseries::Tvalue Tvalue;
try
{
retval=Tiseries(nsamples);
}
catch(...)
{
std::cerr << "ERROR (datread::gse::read_gse_data): "
<< "allocating series for "
<< nsamples << " samples!" << std::endl;
throw;
}
// WID2 reading checks for CM6 subformat
// (only subformat supported so far)
GSE2::waveform::TDAT2readCM6 freader(nsamples);
for(aff::Iterator<Tiseries> i(retval); i.valid(); ++i)
{ (*i) = Tvalue(freader(is)); }
return(retval);
}
} // namespace gse
} // namespace datread
/* ----- END OF gseread.cc ----- */
/*! \file gseread.h
* \brief raw GSE reading module (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: gseread.h,v 1.1 2007-09-19 10:51:03 tforb Exp $
* \author Thomas Forbriger
* \date 19/09/2007
*
* raw GSE reading module (prototypes)
*
* Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* ----
*
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_GSEREAD_H_VERSION
#define TF_GSEREAD_H_VERSION \
"TF_GSEREAD_H V1.0 "
#define TF_GSEREAD_H_CVSID \
"$Id: gseread.h,v 1.1 2007-09-19 10:51:03 tforb Exp $"
#include<istream>
#include<aff/series.h>
#include<gsexx.h>
#include<sffxx.h>
namespace datread {
/*! \brief all the stuff to read raw GSE data.
* \defgroup gse Read raw GSE data
*/
/*! \brief all the stuff to read raw GSE data
*
* \ingroup gse
*/
namespace gse {
/*! \brief default return type for GSE waveforms
* \ingroup gse
*/
typedef GSE2::waveform::intT Tivalue;
typedef aff::Series<Tivalue> Tiseries;
/*! \brief print info about GSE reading
* \ingroup gse
*/
void help(std::ostream& os);
/*! \brief find next WID2 line
* \ingroup gse
*/
sff::WID2 next_wid2(std::istream& is);
/*! \brief read samples from file
* \ingroup gse
*/
Tiseries read_gse_data(std::istream& is, const int& nsamples);
} // namespace gse
} // namespace datread
#endif // TF_GSEREAD_H_VERSION (includeguard)
/* ----- END OF gseread.h ----- */
Supports Markdown
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