conv/many suite: convert (m)any seismic data format(s)
fnseriesofmissingsamples.cc
Go to the documentation of this file.
1 
38 #define TF_FNSERIESOFMISSINGSAMPLES_CC_VERSION \
39  "TF_FNSERIESOFMISSINGSAMPLES_CC V1.1"
40 
41 #include "gapfunctions.h"
42 #include "structgapanalysis.h"
43 #include <iostream>
44 #include <tfxx/misc.h>
45 
49  const CompletenessBins& cb,
50  const bool& debug)
51 {
52  // fetch header data
53  GapSeriesHeader header(cb, gos.ID);;
54  GapSeries retseries(header);
55  const libtime::TRelativeTime& dt=gos.ID.dt;
56  // build series
57  for (Gapsofstream::Tvecofgap::const_iterator G=gos.gap.begin();
58  G!=gos.gap.end(); ++G)
59  {
60  TFXX_debug(debug, "seriesofmissingsamples",
61  "fill in gap: " << (*G));
62  const libtime::TAbsoluteTime& first=G->first;
63  const libtime::TAbsoluteTime& last=G->last;
64  libtime::TAbsoluteTime current=first;
65  // do not process if this gaps actually is a break
66  if (!G->isbreak())
67  {
68  for (unsigned int i=0; i<cb.nbins(); ++i)
69  {
70  TFXX_debug(debug, "seriesofmissingsamples",
71  "bin #" << i << ": "
72  << cb.bin(i).timestring() << " - "
73  << cb.nextbin(i).timestring());
74  TFXX_debug(debug, "seriesofmissingsamples",
75  " current: " << current.timestring());
76  if (cb.isinbin(current, i))
77  {
78  TFXX_debug(debug, "seriesofmissingsamples",
79  "is in bin " << i << ": " << current.timestring());
80  libtime::TAbsoluteTime nextbin=cb.nextbin(i);
81  TFXX_debug(debug, "seriesofmissingsamples",
82  TFXX_value(nextbin.timestring()) << " " <<
83  TFXX_value(last.timestring()));
84  if (nextbin<=last)
85  {
86  unsigned int n=(nextbin-current)/dt;
87  while ((current+n*dt)<nextbin)
88  {
89  TFXX_debug(debug, "seriesofmissingsamples",
90  "n: " << n <<
91  " (current+n*dt): " <<
92  libtime::TAbsoluteTime(current+n*dt).timestring() <<
93  " nextbin: " << nextbin.timestring());
94  ++n;
95  }
96  TFXX_debug(debug, "seriesofmissingsamples",
97  "n: " << n <<
98  " (current+n*dt): " <<
99  libtime::TAbsoluteTime(current+n*dt).timestring() <<
100  " nextbin: " << nextbin.timestring());
101  retseries.gapseries(i) += n;
102  current += n*dt;
103  }
104  else
105  {
106  unsigned int n=(last-current)/dt;
107  while ((current+n*dt)<=last)
108  {
109  TFXX_debug(debug, "seriesofmissingsamples",
110  "n: " << n <<
111  " (current+n*dt): " <<
112  libtime::TAbsoluteTime(current+n*dt).timestring() <<
113  " last: " << last.timestring());
114  ++n;
115  }
116  TFXX_debug(debug, "seriesofmissingsamples",
117  "n: " << n <<
118  " (current+n*dt): " <<
119  libtime::TAbsoluteTime(current+n*dt).timestring() <<
120  " last: " << last.timestring());
121  retseries.gapseries(i) += n;
122  // no need to cycle further
123  i=cb.nbins();
124  }
125  } // if (cb.isinbin(current, i))
126  } // end of loop over bins
127  } // if (last >= first)
128  } // end of loop over gaps in gos
129  if (debug)
130  {
131  for (unsigned int j=retseries.gapseries.first();
132  j<=retseries.gapseries.last(); ++j)
133  {
134  std::cout << TFXX_value(j) << " "
135  << TFXX_value(retseries.gapseries(j)) << "\n";
136  }
137  }
138  return(retseries);
139 } // GapSeries seriesofmissingsamples()
140 
141 /* ----- END OF fnseriesofmissingsamples.cc ----- */
Tgapseries gapseries
a class to hold a gap series for one stream
structs used in primary gap analysis (prototypes)
unsigned int nbins() const
libtime::TAbsoluteTime bin(const unsigned int &i) const
beginnig of bin (according to bin raster)
GapSeries seriesofmissingsamples(const Gapsofstream &gos, const CompletenessBins &cb, const bool &debug)
Function to extract a GapSeries from given Gapsofstream.
class to define the time axis of the completeness time series.
bool isinbin(const libtime::TAbsoluteTime &d, const unsigned int &i) const
struct to hold gaps of one stream
libtime::TRelativeTime dt
header data for complenetess series
function prototypes used in gap analysis (prototypes)
libtime::TAbsoluteTime nextbin(const unsigned int &i) const
start of bin (will be earliest for fisrt bin)