conv/many suite: convert (m)any seismic data format(s)

◆ gaps()

Tvecofgaps gaps ( const libtime::TAbsoluteTime &  earliest,
const libtime::TAbsoluteTime &  latest,
const TContiguouslist cl,
const bool &  debug 
)

Take the collection of contiguous data and the earliest and latest time for which data are expected and construct a list of missing samples.

Definition at line 47 of file fngaps.cc.

References Gapid::dt, Gap::first, Gap::ID, Gap::isbreak(), and Gap::last.

Referenced by main().

51 {
52  TFXX_debug(debug, "gaps()", "received values: " <<
53  TFXX_value(earliest.timestring()));
54  TFXX_debug(debug, "gaps()", "received values: " <<
55  TFXX_value(latest.timestring()));
56  /*
57  * The word "stream" here refers to a "data stream" i.e. data comming from
58  * the same source as indicated by parameters like channel, station, auxid,
59  * and sampling interval. The first three are combined to the streams ID.
60  *
61  * The algorithm assumes the cl contains a sorted list:
62  * 1. contiguous chunks of data for one stream appear in order of increasing
63  * sampling time
64  * 2. the chunks of one stream are collected contiguously
65  */
66  // create return variable
67  Tvecofgaps stream;
68  // first index in vector to be used
69  int istream=0;
70  libtime::TAbsoluteTime lastexisting=earliest;
71  for (TContiguouslist::const_iterator I=cl.begin(); I!=cl.end(); ++I)
72  {
73  Gapid currentid(*I);
74  TFXX_debug(debug, "gaps()", "current gap ID: " << TFXX_value(*I));
75 
76  bool firstofstream=false;
77  // check whether a new stream starts here
78  if (stream.size()<1)
79  {
80  firstofstream=true;
81  TFXX_debug(debug, "gaps()", "first of all streams");
82  }
83  else
84  {
85  if (stream[istream].ID!=currentid)
86  {
87  TFXX_debug(debug, "gaps()", "first of all in this stream");
88  firstofstream=true;
89  }
90  }
91 
92  // initialize new stream if required and find time of last existing sample
93  if (firstofstream)
94  {
95  Gapsofstream newgaps(currentid, earliest, latest);
96  // newgaps.ID=currentid;
97  stream.push_back(newgaps);
98  istream=stream.size()-1;
99  lastexisting=earliest-currentid.dt;
100  TFXX_debug(debug, "gaps()", "initialized new stream");
101  }
102 
103  TFXX_debug(debug, "gaps()",
104  TFXX_value(lastexisting.timestring()));
105 
106  // set up new gap
107  Gap newgap;
108  newgap.ID=currentid;
109  newgap.first=lastexisting+currentid.dt;
110  newgap.last=I->first-currentid.dt;
111  TFXX_debug(debug, "gaps()", "new gap (not yet adjusted): "
112  << TFXX_value(newgap));
113 
114  if (!(firstofstream && newgap.isbreak()))
115  {
116  stream[istream].gap.push_back(newgap);
117  TFXX_debug(debug, "gaps()", "pushed back gap of finite size "
118  << TFXX_value(newgap));
119  }
120 
121  // check if this is the last entry for this stream
122  bool lastofstream=false;
123  TContiguouslist::const_iterator J=I;
124  ++J;
125  if (J==cl.end())
126  {
127  lastofstream=true;
128  }
129  else
130  {
131  Gapid nextid(*J);
132  if (nextid!=currentid) { lastofstream=true; }
133  }
134  if (lastofstream)
135  {
136  newgap.first=I->last+currentid.dt;
137  newgap.last=latest;
138  if (newgap.last>=newgap.first)
139  {
140  stream[istream].gap.push_back(newgap);
141  TFXX_debug(debug, "gaps()", "pushed back gap of finite size "
142  << TFXX_value(newgap));
143  }
144  }
145  lastexisting=I->last;;
146  } // for (TContiguouslist::const_iterator I=cl.begin(); I!=cl.end(); ++I)
147  TFXX_debug(debug, "gaps()", "finished...");
148  return(stream);
149 } // Tvecofgaps gaps(const libtime::TAbsoluteTime& earliest,...
struct to hold gaps of one stream
ID to identify stream.
libtime::TAbsoluteTime first
struct to hold one gap
libtime::TAbsoluteTime last
std::vector< Gapsofstream > Tvecofgaps
vector to hold all gaps
Gapid ID
bool isbreak() const
Here is the call graph for this function:
Here is the caller graph for this function: