DATRW++ library: seismic data I/O with multiple formats

◆ read()

void datrw::ihpmostream::read ( std::istream &  is,
const bool &  verbose = false 
)
private

read one data file

Definition at line 101 of file ihpmostream.cc.

References DATRW_assert, datrw::hpmo::dt(), Mdatafile, Mindex, Mnblocks, Mnextblock, Mnextchannel, datrw::hpmo::MinuteBlock::Mtime, datrw::hpmo::nminutes, datrw::hpmo::nsamples, datrw::hpmo::qualityreports(), datrw::hpmo::readfile(), and datrw::idatstream::setfilefree().

Referenced by ihpmostream().

102  {
103  // simply read the thing
105  if (verbose)
106  {
107  std::cout << "(ihpmostream::read): read "
108  << blocks.size() << " blocks of data" << std::endl;
109  }
110  int nblocksread=blocks.size();
111  DATRW_assert((nblocksread <= datrw::hpmo::nminutes),
112  "ERROR (ihpmostream::read): "
113  "illegal number of minute blocks in file!" "\n"
114  " Use ihpmostream only together with original HPMO data");
115  // extract the stuff now
116  if (verbose) { std::cout << "(ihpmostream::read): copy block #"; }
117  libtime::TRelativeTime length(datrw::hpmo::dt()*datrw::hpmo::nsamples);
118  for (int iblock=0; iblock<nblocksread; iblock++)
119  {
120  this->Mdatafile[iblock]=blocks[iblock];
121  datrw::hpmo::MinuteBlock& block=this->Mdatafile[iblock];
122  if (iblock > 0)
123  {
124  datrw::hpmo::MinuteBlock& prevblock=this->Mdatafile[iblock-1];
125  if (prevblock.Mtime+length != block.Mtime)
126  {
127  Mindex[Mnblocks]=iblock;
128  ++Mnblocks;
129  if (verbose) {
130  std::cout << std::endl
131  << "(ihpmostream::read): found gap" << std::endl;
132  std::cout << " between block # " << iblock-1 << " @ "
133  << prevblock.Mtime.timestring() << std::endl;
134  std::cout << " and block # " << iblock << " @ "
135  << block.Mtime.timestring() << std::endl;
136  std::cout << "(ihpmostream::read): copy block #";
137  }
138  }
139  }
140  else
141  {
142  Mindex[Mnblocks]=0;
143  ++Mnblocks;
144  }
145  if (verbose) { std::cout << " " << iblock; }
146  }
147  if (verbose)
148  {
149  std::cout << std::endl;
150  std::cout << "(ihpmostream::read): extracted "
151  << Mnblocks << " contiguous data block(s)" << std::endl;
152  }
153  // marks last block
154  Mindex[Mnblocks]=nblocksread;
155  // init reading pointers
156  Mnextblock=0;
157  Mnextchannel=1;
158  // prepare file FREE block
159  std::ostringstream oss;
160  oss << nblocksread;
161  sff::FREE filefree;
162  filefree.append("ihpmostream read " + oss.str() + " blocks from file");
163  oss.str("");
164  oss << Mnblocks;
165  filefree.append("found " + oss.str() + " contiguous sets of blocks");
166  filefree.append(qualityreports(Mdatafile, nblocksread));
167  this->setfilefree(filefree);
168  } // void ihpmostream::read(std::istream& is, const bool& verbose)
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
sff::FREE qualityreports(const MinuteBlock *blocks, const int &nblocks)
prepare a report on unusual quality reports
Definition: readhpmo.cc:125
void setfilefree(const sff::FREE &free)
Definition: datread.cc:97
std::vector< MinuteBlock > Tvecofblocks
within the inner reading functions, we use vector to hold minute blocks
Definition: readhpmo.h:67
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
Definition: readhpmo.cc:83
const int nsamples
number of samples per minute block and channel
Definition: hpmodata.h:51
hold one minute block
Definition: hpmodata.h:67
datrw::hpmo::MinuteBlock Mdatafile[datrw::hpmo::nminutes]
buffer to hold one data file
Definition: hpmo.h:79
libtime::TAbsoluteTime Mtime
Definition: hpmodata.h:68
int Mnextchannel
Definition: hpmo.h:83
Tvecofblocks readfile(std::istream &is, const bool &verbose)
read a full data file
Definition: readhpmo.cc:216
int Mindex[datrw::hpmo::nminutes]
Definition: hpmo.h:80
int Mnextblock
Definition: hpmo.h:82
const int nminutes
number of minute blocks per file (1h)
Definition: hpmodata.h:53
Here is the call graph for this function:
Here is the caller graph for this function: