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

proceeding; I'm almost there

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: 2886
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 4c8436ce
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tsoft.h,v 1.4 2009-11-11 16:21:45 tforb Exp $
* $Id: tsoft.h,v 1.5 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 16/09/2009
*
......@@ -39,7 +39,7 @@
#define DATREAD_TSOFT_H_VERSION \
"DATREAD_TSOFT_H V1.0 "
#define DATREAD_TSOFT_H_CVSID \
"$Id: tsoft.h,v 1.4 2009-11-11 16:21:45 tforb Exp $"
"$Id: tsoft.h,v 1.5 2009-11-11 17:41:22 tforb Exp $"
#include<datreadxx/datread.h>
#include<datreadxx/tsoftsffcontainer.h>
......@@ -57,7 +57,6 @@ namespace datread {
virtual ~itsoftstream() { }
virtual Tdseries dseries();
virtual Tfseries fseries();
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
private:
......@@ -68,11 +67,7 @@ namespace datread {
//! index of next trace to be passed
aff::Tsubscript Mitrace;
//! read file to buffer
Tdseries read(std::istream& is)
{
Mfile=datread::tsoft::readfile(is);
Mitrace=this->Mfile.Mtraces.first();
}
void read(std::istream& is);
}; // class itsoftstream
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: channeltranslation.cc,v 1.1 2009-11-11 16:21:45 tforb Exp $
* $Id: channeltranslation.cc,v 1.2 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 11/11/2009
*
......@@ -35,7 +35,7 @@
#define DATREAD_CHANNELTRANSLATION_CC_VERSION \
"DATREAD_CHANNELTRANSLATION_CC V1.0 "
#define DATREAD_CHANNELTRANSLATION_CC_CVSID \
"$Id: channeltranslation.cc,v 1.1 2009-11-11 16:21:45 tforb Exp $"
"$Id: channeltranslation.cc,v 1.2 2009-11-11 17:41:22 tforb Exp $"
#include <iomanip>
#include <datreadxx/error.h>
......@@ -248,6 +248,37 @@ namespace datread {
return(retval);
} // bool translationisunique(const bool& verbose)
/*----------------------------------------------------------------------*/
SFFchannelid translate(const TSOFTchannelid& ci)
{
SFFchannelid retval;
retval.station=NSP;
retval.channel=NSP;
retval.instrument=NSP;
retval.auxid=NSP;
const Channel* pc=translationtable;
bool hot=true;
while (hot && (pc->TSOFTname != NULL))
{
DATREAD_assert(pc->TSOFTname != NULL, "UUPS");
TSOFTchannelid tci=tchannelid(*pc);
if ((tci.location==ci.location)
&& (tci.instrument==ci.instrument)
&& (tci.datatype==ci.datatype))
{
SFFchannelid sci=schannelid(*pc);
retval.station=sci.station;
retval.channel=sci.channel;
retval.instrument=sci.instrument;
retval.auxid=sci.auxid;
hot=false;
}
++pc;
}
return(retval);
} // SFFchannelid translate(const TSOFTchannelid& ci)
} // namespace tsoft
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: channeltranslation.h,v 1.1 2009-11-11 16:21:45 tforb Exp $
* $Id: channeltranslation.h,v 1.2 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 11/11/2009
*
......@@ -42,7 +42,7 @@
#define DATREAD_CHANNELTRANSLATION_H_VERSION \
"DATREAD_CHANNELTRANSLATION_H V1.0 "
#define DATREAD_CHANNELTRANSLATION_H_CVSID \
"$Id: channeltranslation.h,v 1.1 2009-11-11 16:21:45 tforb Exp $"
"$Id: channeltranslation.h,v 1.2 2009-11-11 17:41:22 tforb Exp $"
namespace datread {
......@@ -114,6 +114,13 @@ namespace datread {
*/
bool translationisunique(const bool& verbose=true);
/*----------------------------------------------------------------------*/
/*! \brief check uniqueness of translation table
* \ingroup tsoft
*/
SFFchannelid translate(const TSOFTchannelid& ci);
} // namespace tsoft
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tsoft.cc,v 1.2 2009-11-11 16:21:45 tforb Exp $
* $Id: tsoft.cc,v 1.3 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 11/11/2009
*
......@@ -35,12 +35,73 @@
#define DATREAD_TSOFT_CC_VERSION \
"DATREAD_TSOFT_CC V1.0 "
#define DATREAD_TSOFT_CC_CVSID \
"$Id: tsoft.cc,v 1.2 2009-11-11 16:21:45 tforb Exp $"
"$Id: tsoft.cc,v 1.3 2009-11-11 17:41:22 tforb Exp $"
#include <datreadxx/tsoft.h>
#include <datreadxx/util.h>
#include <datreadxx/channeltranslation.h>
namespace datread {
itsoftstream::itsoftstream(std::istream& is, const bool& debug):
Tbase(is, true, true, false),
Mdebug(debug)
{
this->read(is);
} // itsoftstream::itsoftstream(std::istream& is, const bool& debug)
/*----------------------------------------------------------------------*/
void itsoftstream::read(std::istream& is)
{
Mfile=datread::tsoft::readfile(is);
Mitrace=this->Mfile.Mtraces.first();
this->setfilefree(Mfile.Mfree);
if (Mitrace>=this->Mfile.Mtraces.last())
{ this->setlast(); }
} // void itsoftstream::read(std::istream& is)
/*----------------------------------------------------------------------*/
Tdseries itsoftstream::dseries()
{
DATREAD_assert(Mitrace<=this->Mfile.Mtraces.last(),
"reading beyond end of file");
if (Mitrace==this->Mfile.Mtraces.last()) { this->setlast(); }
datread::tsoft::Trace trace=Mfile.Mtraces(Mitrace);
this->setwid2(trace.Mwid2);
this->settracefree(trace.Mfree);
++Mitrace;
return(trace.Mseries);
} // Tdseries itsoftstream::dseries()
/*----------------------------------------------------------------------*/
Tfseries itsoftstream::fseries()
{ return(datread::util::convert<Tdseries, Tfseries>(this->dseries())); }
/*----------------------------------------------------------------------*/
void itsoftstream::skipseries()
{
DATREAD_assert(Mitrace<=this->Mfile.Mtraces.last(),
"reading beyond end of file");
if (Mitrace==this->Mfile.Mtraces.last()) { this->setlast(); }
datread::tsoft::Trace trace=Mfile.Mtraces(Mitrace);
this->setwid2(trace.Mwid2);
this->settracefree(trace.Mfree);
++Mitrace;
} // void itsoftstream::skipseries()
/*----------------------------------------------------------------------*/
void itsoftstream::help(std::ostream& os)
{
datread::tsoft::reporttranslation(os);
DATREAD_assert(datread::tsoft::translationisunique(),
"TSOFT translation table is not unique");
} // void itsoftstream::help(std::ostream& os)
} // namespace datread
/* ----- END OF tsoft.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tsoftsffcontainer.cc,v 1.1 2009-11-11 16:21:46 tforb Exp $
* $Id: tsoftsffcontainer.cc,v 1.2 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 11/11/2009
*
......@@ -35,14 +35,80 @@
#define DATREAD_TSOFTSFFCONTAINER_CC_VERSION \
"DATREAD_TSOFTSFFCONTAINER_CC V1.0 "
#define DATREAD_TSOFTSFFCONTAINER_CC_CVSID \
"$Id: tsoftsffcontainer.cc,v 1.1 2009-11-11 16:21:46 tforb Exp $"
"$Id: tsoftsffcontainer.cc,v 1.2 2009-11-11 17:41:22 tforb Exp $"
#include <datreadxx/tsoftsffcontainer.h>
#include <datreadxx/tsoftreader.h>
#include <datreadxx/channeltranslation.h>
#include <aff/iterator.h>
namespace datread {
namespace tsoft {
File readfile(std::istream& is)
{
TSOFTfile infile(is);
File outfile;
outfile.Mfree.append(infile.free());
const Datacontainer& dc=infile.dc();
// count traces
int ntraces=0;
for (int ich=0; ich<infile.nchannels(); ++ich)
{
const Channeldata& cd=dc[ich];
ntraces += cd.nsequences();
}
// reserve space for n traces
outfile.Mtraces=Ttraceseries(ntraces);
// cycle trough all input traces
aff::Iterator<Ttraceseries> I(outfile.Mtraces);
for (int ich=0; ich<infile.nchannels(); ++ich)
{
const Channeldata& cd=dc[ich];
const Channelinfo& ci=cd.chinfo();
sff::FREE channelfree;
channelfree.append(channelinfofree(ci));
for (int iseq=0; iseq<cd.nsequences(); ++iseq)
{
I->Mfree=channelfree;
const Datasequence& ds=cd.sequence(iseq);
// extract samples
I->Mseries=Tdseries(ds.nsamples());
aff::Iterator<Tdseries> IS(I->Mseries);
for (int isa=0; isa<ds.nsamples(); ++isa)
{
*IS = ds.sample(isa);
++IS;
}
// extract header
I->Mwid2.date=ds.date();
I->Mwid2.dt=libtime::time2double(ds.interval());
I->Mwid2.nsamples=ds.nsamples();
TSOFTchannelid tci;
tci.location=ci.thelocation();
tci.instrument=ci.theinstrument();
tci.datatype=ci.thedatatype();
SFFchannelid sci=translate(tci);
I->Mwid2.station=sci.station;
I->Mwid2.channel=sci.channel;
I->Mwid2.instype=sci.instrument;
I->Mwid2.auxid=sci.auxid;
++I;
}
}
return(outfile);
} // File readfile(const std::istream& is)
} // namespace tsoft
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tsoftsffcontainer.h,v 1.1 2009-11-11 16:21:46 tforb Exp $
* $Id: tsoftsffcontainer.h,v 1.2 2009-11-11 17:41:22 tforb Exp $
* \author Thomas Forbriger
* \date 11/11/2009
*
......@@ -39,7 +39,7 @@
#define DATREAD_TSOFTSFFCONTAINER_H_VERSION \
"DATREAD_TSOFTSFFCONTAINER_H V1.0 "
#define DATREAD_TSOFTSFFCONTAINER_H_CVSID \
"$Id: tsoftsffcontainer.h,v 1.1 2009-11-11 16:21:46 tforb Exp $"
"$Id: tsoftsffcontainer.h,v 1.2 2009-11-11 17:41:22 tforb Exp $"
#include<iostream>
#include<sffxx.h>
......@@ -85,7 +85,7 @@ namespace datread {
/*! \brief function to read a complete TSOFT file
* \ingroup tsoft
*/
File readfile(const std::istream& is);
File readfile(std::istream& is);
} // namespace tsoft
......
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