conv/many suite: convert (m)any seismic data format(s)
fnprintgaps.cc
Go to the documentation of this file.
1 
40 #define TF_FNPRINTGAPS_CC_VERSION \
41  "TF_FNPRINTGAPS_CC V1.3"
42 
43 #include "gapfunctions.h"
44 #include <tfxx/misc.h>
45 
46 void printgaps(std::ostream& os, const Tvecofgaps& vog,
47  const libtime::TAbsoluteTime& earliest,
48  const libtime::TAbsoluteTime& latest,
49  const unsigned int& lev)
50 {
51  if (lev<3)
52  {
53  os << "analysis period: "
54  << earliest.timestring().substr(4)
55  << " - "
56  << latest.timestring().substr(4)
57  << "\n";
58  os << "gaps present in input data:\n";
59  }
60  unsigned int ntotalgaps=0;
61  unsigned int ntotalbreaks=0;
62  unsigned int ntotalmissing=0;
63  unsigned int ntotalexpected=0;
64  libtime::TRelativeTime ttotalexpected(0);
65  libtime::TRelativeTime ttotalmissing(0);
66  for (Tvecofgaps::const_iterator I=vog.begin(); I!=vog.end(); ++I)
67  {
68  if (lev<2) { os << "stream: " << I->ID << std::endl; }
69  for (Gapsofstream::Tvecofgap::const_iterator J=I->gap.begin();
70  J!=I->gap.end(); ++J)
71  {
72  if (lev<1) { os << *J << std::endl; }
73  } // for (Gapsofstream::Tvecofgap::const_iterator J=I->gap.begin();
74  // J!=I->gap.end(); ++J)
75 
76  Gapsummary summary=I->summarize();
77 // os << "DEBUG: I->mearliest.timestring(): " << I->Mearliest.timestring() << std::endl;
78 // os << "DEBUG: I->mlatest.timestring(): " << I->Mlatest.timestring() << std::endl;
79  ntotalgaps += summary.ngaps;
80  ntotalbreaks += summary.nbreaks;
81  ntotalmissing += summary.nmissing;
82  ntotalexpected += summary.nexpected;
83  ttotalexpected += summary.tspan;
84  ttotalmissing += summary.tmissing;
85  if (lev<2)
86  {
87  os << " number of breaks / number of gaps / number of missing samples / completeness:\n";
88  os << " " << summary.nbreaks << " / ";
89  os << summary.ngaps << " / ";
90  os << summary.nmissing << " / ";
91  double tspan=libtime::time2double(summary.tspan);
92  double tmissing=libtime::time2double(summary.tmissing);
93  int completeness=nearbyint(1.e4*(1.-(tmissing/tspan)));
94  if ((completeness == 10000) &&
95  ((summary.nbreaks+summary.ngaps+summary.nmissing)>0))
96  { completeness -= 1; }
97  os << static_cast<double>(completeness)*1.e-2 << "%\n";
98  }
99  } // for (Tvecofgaps::const_iterator I=vog.begin(); I!=vog.end(); ++I)
100 
101  double tspan=libtime::time2double(ttotalexpected);
102  double tmissing=libtime::time2double(ttotalmissing);
103  int completeness=nearbyint(1.e4*(1.-(tmissing/tspan)));
104  if (lev<3)
105  {
106  os << "summary of entire analysis:\n";
107  os << "number of breaks / number of gaps / number of missing samples / completeness:\n";
108  os << ntotalbreaks << " / ";
109  os << ntotalgaps << " / ";
110  os << ntotalmissing << " / ";
111  if ((completeness == 10000) &&
112  ((ntotalbreaks+ntotalgaps+ntotalmissing)>0))
113  { completeness -= 1; }
114  os << static_cast<double>(completeness)*1.e-2 << "%\n";
115  }
116 
117  if (lev==3) { os << ntotalgaps << std::endl; }
118  if (lev==4) { os << ntotalmissing << std::endl; }
119 } // void printgaps(std::ostream& os, const Tvecofgaps& vog)
120 
121 /* ----- END OF fnprintgaps.cc ----- */
libtime::TRelativeTime tspan
time span of analysis
unsigned int ngaps
total number of gaps
unsigned int nbreaks
total number of breaks
CompletenessSeries completeness(const GapSeries &gs, const bool &debug)
convert gaps to completeness
struct to present a summary
unsigned int nmissing
number of missing samples
std::vector< Gapsofstream > Tvecofgaps
vector to hold all gaps
unsigned int nexpected
number of expected samples
void printgaps(std::ostream &os, const Tvecofgaps &vog, const libtime::TAbsoluteTime &earliest, const libtime::TAbsoluteTime &latest, const unsigned int &lev)
Definition: fnprintgaps.cc:46
function prototypes used in gap analysis (prototypes)
libtime::TRelativeTime tmissing
time span not covered with samples