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

◆ push_sample()

void datrw::tsoft::Channeldata::push_sample ( const libtime::TAbsoluteTime &  time,
const double &  value,
const double &  undetval,
const libtime::TRelativeTime &  dt,
const ReaderConfig rc,
const bool &  debug = false 
)

push a sample

Definition at line 228 of file tsoftdata.cc.

References datrw::tsoft::Datasequence::append(), datrw::tsoft::ReaderConfig::bridgeflagvalue, datrw::tsoft::ReaderConfig::bridgesamples, datrw::tsoft::ReaderConfig::bridgetime, datrw::tsoft::Datasequence::date(), DATRW_report_assert, datrw::hpmo::dt(), datrw::tsoft::ReaderConfig::flagbridged, datrw::tsoft::ReaderConfig::flagvalue, flushcollector(), datrw::tsoft::Datasequence::interval(), datrw::tsoft::ReaderConfig::keepundetval, Mcollector, datrw::tsoft::Datasequence::nsamples(), datrw::tsoft::ReaderConfig::setundetval, and datrw::tsoft::Datasequence::timeofnextsample().

Referenced by datrw::tsoft::Datacontainer::push_data().

234  {
235  // copy value to allow modification
236  double value=invalue;
237  libtime::TAbsoluteTime time=intime;
238  // replace flag value if requested
239  if ((value == undetval) && (rc.setundetval))
240  {
241  value=rc.flagvalue;
242  }
243  // handle value if valid or if UNDETVAL values are requested to be read
244  if ((value != undetval) || (rc.keepundetval))
245  {
246  if (debug)
247  {
248  std::cout << " yes, take this sample" << std::endl;
249  }
250  // check, whether collector is already in use
251  bool insequence = (Mcollector.nsamples() > 0);
252  // bridge sample if requested
253  if (rc.bridgesamples)
254  {
255  if (time == rc.bridgetime)
256  {
257  if (insequence)
258  {
259  time = Mcollector.timeofnextsample();
260  if (rc.flagbridged)
261  {
262  value=rc.bridgeflagvalue;
263  }
264  }
265  else
266  {
267  DATRW_report_assert(insequence,
268  "WARNING (Channeldata::push_sample): TSOFT reading\n"
269  "User requested to bridge data entries labelled with time: "
270  << rc.bridgetime.timestring() << "\n"
271  << "This time label is present in the first entry of the"
272  << "input data.\n"
273  << "First input lines cannot be bridged.");
274  }
275  }
276  }
277  // if collector is in use, then check is current value matches
278  if (insequence)
279  {
280  insequence = ((time == Mcollector.timeofnextsample(debug))
281  && (dt == Mcollector.interval()));
282  }
283  // if current value does not match: flush collector and start new
284  if (!insequence)
285  {
286  this->flushcollector();
287  Mcollector.date(time);
289  }
290  Mcollector.append(value);
291  }
292  } // void Channeldata::push_sample
void append(const double &v)
append sample
Definition: tsoftdata.h:275
libtime::TAbsoluteTime timeofnextsample(const bool &debug=false) const
return time of next sample after last samples
Definition: tsoftdata.cc:164
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
Definition: readhpmo.cc:83
int nsamples() const
return number of samples
Definition: tsoftdata.h:288
void interval(const libtime::TRelativeTime i)
set sampling interval
Definition: tsoftdata.h:279
void flushcollector()
function to flush collector to vector of sequences
Definition: tsoftdata.cc:213
Datasequence Mcollector
vector of samples to collect from file
Definition: tsoftdata.h:361
void date(const libtime::TAbsoluteTime d)
set time of first sample
Definition: tsoftdata.h:277
#define DATRW_report_assert(C, M)
Check an assertion and report only.
Definition: error.h:120
Here is the call graph for this function:
Here is the caller graph for this function: