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

file reading is complete

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: 1605
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent e2ec5fab
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmo.h,v 1.7 2004-12-23 10:50:06 tforb Exp $
* $Id: hpmo.h,v 1.8 2004-12-23 12:02:34 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.7 2004-12-23 10:50:06 tforb Exp $"
"$Id: hpmo.h,v 1.8 2004-12-23 12:02:34 tforb Exp $"
#include<datreadxx/datread.h>
#include<datreadxx/hpmodata.h>
......@@ -47,12 +47,15 @@ namespace datread {
private:
//! read one data file
void read(std::istream& is, const bool& verbose=false);
//! set header for next request
void set_next_header();
//! buffer to hold one data file
datread::hpmo::MinuteBlock Mdatafile[datread::hpmo::nminutes];
int Mindex[datread::hpmo::nminutes]; //<! index to contiguous blocks
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.5 2004-12-23 10:50:07 tforb Exp $
* $Id: hpmo.cc,v 1.6 2004-12-23 12:02:34 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -19,13 +19,15 @@
#define DATREAD_HPMO_CC_VERSION \
"DATREAD_HPMO_CC V1.0 "
#define DATREAD_HPMO_CC_CVSID \
"$Id: hpmo.cc,v 1.5 2004-12-23 10:50:07 tforb Exp $"
"$Id: hpmo.cc,v 1.6 2004-12-23 12:02:34 tforb Exp $"
#include <datreadxx/datread.h>
#include <datreadxx/util.h>
#include <datreadxx/hpmo.h>
#include <datreadxx/readhpmo.h>
#include <sffxx.h>
#include <iostream>
#include <sstream>
namespace datread {
......@@ -64,16 +66,15 @@ namespace datread {
std::cout << "(ihpmostream::read): read "
<< blocks.size() << " blocks of data" << std::endl;
}
// satisfy my compiler
int n_blocks_read=blocks.size();
DATREAD_assert((n_blocks_read <= datread::hpmo::nminutes),
Mnblocksread=blocks.size();
DATREAD_assert((Mnblocksread <= 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<n_blocks_read; iblock++)
for (int iblock=0; iblock<Mnblocksread; iblock++)
{
this->Mdatafile[iblock]=blocks[iblock];
datread::hpmo::MinuteBlock& block=this->Mdatafile[iblock];
......@@ -108,7 +109,26 @@ namespace datread {
std::cout << "(ihpmostream::read): extracted "
<< Mnblocks << " contiguous data block(s)" << std::endl;
}
}
// init reading pointers
Mnextblock=0;
Mnextchannel=1;
// prepare file FREE block
std::ostringstream oss;
oss << Mnblocksread;
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));
this->setfilefree(filefree);
} // void ihpmostream::read(std::istream& is, const bool& verbose)
/*----------------------------------------------------------------------*/
void ihpmostream::set_next_header()
{
} // void ihpmostream::set_next_header()
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: readhpmo.cc,v 1.11 2004-12-23 10:50:07 tforb Exp $
* $Id: readhpmo.cc,v 1.12 2004-12-23 12:02:35 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -19,11 +19,12 @@
#define DATREAD_READHPMO_CC_VERSION \
"DATREAD_READHPMO_CC V1.0 "
#define DATREAD_READHPMO_CC_CVSID \
"$Id: readhpmo.cc,v 1.11 2004-12-23 10:50:07 tforb Exp $"
"$Id: readhpmo.cc,v 1.12 2004-12-23 12:02:35 tforb Exp $"
#include <datreadxx/error.h>
#include <datreadxx/readhpmo.h>
#include<iostream>
#include<sstream>
namespace datread {
......@@ -105,6 +106,26 @@ namespace datread {
return(retval);
} // std::string quality(const int& flag)
/*----------------------------------------------------------------------*/
sff::FREE qualityreports(const MinuteBlock* blocks, const int& nblocks)
{
sff::FREE retval;
for (int i=0; i<nblocks; ++i)
{
const int& qf=blocks[i].Mquality_flag;
if (qf != 0)
{
std::ostringstream oss;
oss << qf;
retval.append("quality flag @ " + blocks[i].Mtime.timestring()
+ ": " + oss.str());
retval.append(" this means: " + quality(qf));
}
}
return(retval);
} // sff::FREE qualityreports(const MinuteBlock* blocks, const int& nblocks)
/*======================================================================*/
SampleBlock readdata(std::istream& is, const bool& verbose)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: readhpmo.h,v 1.10 2004-12-23 09:54:06 tforb Exp $
* $Id: readhpmo.h,v 1.11 2004-12-23 12:02:35 tforb Exp $
* \author Thomas Forbriger
* \date 31/03/2004
*
......@@ -23,12 +23,13 @@
#define DATREAD_READHPMO_H_VERSION \
"DATREAD_READHPMO_H V1.0 "
#define DATREAD_READHPMO_H_CVSID \
"$Id: readhpmo.h,v 1.10 2004-12-23 09:54:06 tforb Exp $"
"$Id: readhpmo.h,v 1.11 2004-12-23 12:02:35 tforb Exp $"
#include<iostream>
#include<string>
#include<vector>
#include<libtime++.h>
#include<sffxx.h>
#include<datreadxx/datread.h>
#include<datreadxx/hpmodata.h>
......@@ -108,6 +109,9 @@ namespace datread {
//! return meaning of quality flag
std::string quality(const int& flag);
//! prepare a report on unusual quality reports
sff::FREE qualityreports(const MinuteBlock* blocks, const int& nblocks);
/*----------------------------------------------------------------------*/
//! read header from C++ stream
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: hpmotest.cc,v 1.7 2004-12-23 10:50:07 tforb Exp $
* $Id: hpmotest.cc,v 1.8 2004-12-23 12:02:35 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.7 2004-12-23 10:50:07 tforb Exp $"
"$Id: hpmotest.cc,v 1.8 2004-12-23 12:02:35 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -203,6 +203,9 @@ int main(int iargc, char* argv[])
std::ifstream ifs(infile.c_str());
DATREAD_assert(ifs.good(), "invalid file!");
datread::ihpmostream is(ifs, opt.verbose);
sff::FREE filefree;
is >> filefree;
cout << filefree;
}
}
......
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