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

proceeding

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: 1606
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent b252d37d
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: datread.h,v 1.5 2004-09-17 10:06:13 tforb Exp $
* $Id: datread.h,v 1.6 2004-12-23 12:38:25 tforb Exp $
* \author Thomas Forbriger
* \date 30/03/2004
*
......@@ -15,6 +15,8 @@
* - 30/03/2004 V1.0 Thomas Forbriger
* - 21/04/2004 V1.1 some improvements - provide definition of use
* - 17/09/2004 V1.2 make most fields private
* - 23/12/2004 V1.3 user of datstream::good() does not want to know
* anything about Mis state
*
* ============================================================================
*/
......@@ -23,9 +25,9 @@
#ifndef DATREAD_DATREAD_H_VERSION
#define DATREAD_DATREAD_H_VERSION \
"DATREAD_DATREAD_H V1.2 "
"DATREAD_DATREAD_H V1.3"
#define DATREAD_DATREAD_H_CVSID \
"$Id: datread.h,v 1.5 2004-09-17 10:06:13 tforb Exp $"
"$Id: datread.h,v 1.6 2004-12-23 12:38:25 tforb Exp $"
#include<iostream>
#include<sffxx.h>
......@@ -71,7 +73,7 @@ namespace datread {
bool providesf() const { return(Mprovidesf); }
bool providesi() const { return(Mprovidesi); }
bool last() const { return(Mlast); }
bool good() const { return(Mis.good() && (!Mlast)); }
bool good() const { return(!Mlast); }
/*! return FREE block
*
* if no WID2 ist set (prior to reading first trace)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmo.h,v 1.8 2004-12-23 12:02:34 tforb Exp $
* $Id: hpmo.h,v 1.9 2004-12-23 12:38:25 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -23,7 +23,7 @@
#define DATREAD_HPMO_H_VERSION \
"DATREAD_HPMO_H V1.0 "
#define DATREAD_HPMO_H_CVSID \
"$Id: hpmo.h,v 1.8 2004-12-23 12:02:34 tforb Exp $"
"$Id: hpmo.h,v 1.9 2004-12-23 12:38:25 tforb Exp $"
#include<datreadxx/datread.h>
#include<datreadxx/hpmodata.h>
......@@ -55,7 +55,6 @@ namespace datread {
int Mnblocks; //<! number of contiguous blocks
int Mnextblock; //<! next block to extract
int Mnextchannel; //<! next channel to extract
int Mnblocksread; //<! total number of blocks read
}; // class ihpmostream
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmo.cc,v 1.6 2004-12-23 12:02:34 tforb Exp $
* $Id: hpmo.cc,v 1.7 2004-12-23 12:38:26 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -19,7 +19,7 @@
#define DATREAD_HPMO_CC_VERSION \
"DATREAD_HPMO_CC V1.0 "
#define DATREAD_HPMO_CC_CVSID \
"$Id: hpmo.cc,v 1.6 2004-12-23 12:02:34 tforb Exp $"
"$Id: hpmo.cc,v 1.7 2004-12-23 12:38:26 tforb Exp $"
#include <datreadxx/datread.h>
#include <datreadxx/util.h>
......@@ -53,6 +53,7 @@ namespace datread {
void ihpmostream::skipseries()
{
set_next_header();
}
/*----------------------------------------------------------------------*/
......@@ -66,15 +67,15 @@ namespace datread {
std::cout << "(ihpmostream::read): read "
<< blocks.size() << " blocks of data" << std::endl;
}
Mnblocksread=blocks.size();
DATREAD_assert((Mnblocksread <= datread::hpmo::nminutes),
int nblocksread=blocks.size();
DATREAD_assert((nblocksread <= datread::hpmo::nminutes),
"ERROR (ihpmostream::read): "
"illegal number of minute blocks in file!" "\n"
" Use ihpmostream only together with original HPMO data");
// extract the stuff now
if (verbose) { std::cout << "(ihpmostream::read): copy block #"; }
libtime::TRelativeTime length(datread::hpmo::dt()*datread::hpmo::nsamples);
for (int iblock=0; iblock<Mnblocksread; iblock++)
for (int iblock=0; iblock<nblocksread; iblock++)
{
this->Mdatafile[iblock]=blocks[iblock];
datread::hpmo::MinuteBlock& block=this->Mdatafile[iblock];
......@@ -109,18 +110,20 @@ namespace datread {
std::cout << "(ihpmostream::read): extracted "
<< Mnblocks << " contiguous data block(s)" << std::endl;
}
// marks last block
Mindex[Mnblocks]=nblocksread+1;
// init reading pointers
Mnextblock=0;
Mnextchannel=1;
// prepare file FREE block
std::ostringstream oss;
oss << Mnblocksread;
oss << nblocksread;
sff::FREE filefree;
filefree.append("ihpmostream read " + oss.str() + " blocks from file");
oss.str("");
oss << Mnblocks;
filefree.append("found " + oss.str() + " contiguous sets of blocks");
filefree.append(qualityreports(Mdatafile, Mnblocksread));
filefree.append(qualityreports(Mdatafile, nblocksread));
this->setfilefree(filefree);
} // void ihpmostream::read(std::istream& is, const bool& verbose)
......@@ -128,6 +131,46 @@ namespace datread {
void ihpmostream::set_next_header()
{
const int& firstblock=Mindex[Mnextblock];
const int& lastblock=Mindex[Mnextblock+1]-1;
// DEBUG
std::cout << firstblock << " " << lastblock << " "
<< Mnextblock << " " << Mnextchannel << std::endl;
this->newtrace();
// set WID2 header
sff::WID2 wid2line;
wid2line.station="BFO";
wid2line.auxid="HPMO";
wid2line.dt=datread::hpmo::sampling_interval;
std::ostringstream oss;
oss << "K";
oss.width(2);
oss.fill('0');
oss << Mnextchannel;
wid2line.channel=oss.str();
// calculate time of first sample for this channel
wid2line.date=Mdatafile[firstblock].Mtime;
wid2line.date -= libtime::TRelativeTime(0,0,0,57);
wid2line.date += datread::hpmo::toffset(Mnextchannel);
this->setwid2(wid2line);
// set FREE block of header
oss.str("");
oss << "channel " << Mnextchannel << " extracted from "
<< lastblock-firstblock+1 << " contiguous minute blocks";
sff::FREE tracefree;
tracefree.append(oss.str());
this->settracefree(tracefree);
// proceed pointers to next trace
++Mnextchannel;
if (Mnextchannel > datread::hpmo::nchannels)
{
Mnextchannel=1;
++Mnextblock;
if (Mnextblock >= Mnblocks)
{
this->setlast();
}
}
} // void ihpmostream::set_next_header()
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmodata.h,v 1.5 2004-12-23 09:54:05 tforb Exp $
* $Id: hpmodata.h,v 1.6 2004-12-23 12:38:26 tforb Exp $
* \author Thomas Forbriger
* \date 22/12/2004
*
......@@ -23,7 +23,7 @@
#define DATREAD_HPMODATA_H_VERSION \
"DATREAD_HPMODATA_H V1.0 "
#define DATREAD_HPMODATA_H_CVSID \
"$Id: hpmodata.h,v 1.5 2004-12-23 09:54:05 tforb Exp $"
"$Id: hpmodata.h,v 1.6 2004-12-23 12:38:26 tforb Exp $"
#include<datreadxx/datread.h>
#include<string>
......@@ -38,6 +38,8 @@ namespace datread {
const int nsamples=12;
//! number of minute blocks per file (1h)
const int nminutes=60;
//! sampling interval in seconds
const double sampling_interval=5.;
//! hold samples of one minute-block
struct SampleBlock {
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: readhpmo.cc,v 1.12 2004-12-23 12:02:35 tforb Exp $
* $Id: readhpmo.cc,v 1.13 2004-12-23 12:38:26 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -19,7 +19,7 @@
#define DATREAD_READHPMO_CC_VERSION \
"DATREAD_READHPMO_CC V1.0 "
#define DATREAD_READHPMO_CC_CVSID \
"$Id: readhpmo.cc,v 1.12 2004-12-23 12:02:35 tforb Exp $"
"$Id: readhpmo.cc,v 1.13 2004-12-23 12:38:26 tforb Exp $"
#include <datreadxx/error.h>
#include <datreadxx/readhpmo.h>
......@@ -68,7 +68,7 @@ namespace datread {
libtime::TRelativeTime dt()
{
return(libtime::double2time(5.));
return(libtime::double2time(datread::hpmo::sampling_interval));
} // libtime::TRelativeTime dt()
/*----------------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmotest.cc,v 1.8 2004-12-23 12:02:35 tforb Exp $
* $Id: hpmotest.cc,v 1.9 2004-12-23 12:38:26 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2004
*
......@@ -19,7 +19,7 @@
#define HPMOTEST_VERSION \
"HPMOTEST V1.0 test hpmo reading functions"
#define HPMOTEST_CVSID \
"$Id: hpmotest.cc,v 1.8 2004-12-23 12:02:35 tforb Exp $"
"$Id: hpmotest.cc,v 1.9 2004-12-23 12:38:26 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -206,6 +206,17 @@ int main(int iargc, char* argv[])
sff::FREE filefree;
is >> filefree;
cout << filefree;
while (is.good())
{
is.skipseries();
sff::WID2 wid2line;
cout << std::endl << "next trace: " << std::endl;
is >> wid2line;
cout << wid2line;
sff::FREE tracefree;
is >> tracefree;
cout << tracefree;
}
}
}
......
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