Isis 3 Programmer Reference
ZeroReverse.h
Go to the documentation of this file.
1 #ifndef ZeroReverse_h
2 #define ZeroReverse_h
3 
26 #include <cmath>
27 #include <string>
28 #include <vector>
29 #include <iostream>
30 #include <sstream>
31 
32 
33 #include "IString.h"
34 #include "HiCalTypes.h"
35 #include "HiCalUtil.h"
36 #include "HiCalConf.h"
37 #include "Module.h"
38 #include "SplineFill.h"
39 #include "Statistics.h"
40 #include "SpecialPixel.h"
41 #include "IException.h"
42 
43 namespace Isis {
44 
60  class ZeroReverse : public Module {
61 
62  public:
63  // Constructors and Destructor
64  ZeroReverse() : Module("ZeroReverse") { }
65  ZeroReverse(HiCalData &cal, const HiCalConf &conf) :
66  Module("ZeroReverse") {
67  init(cal, conf);
68  }
69 
71  virtual ~ZeroReverse() { }
72 
78  const Statistics &Stats() const { return (_stats); }
79 
88  bool wasTriggered() const { return (_triggered); }
89 
90  private:
91  HiVector _revClock;
92  Statistics _stats;
93  bool _triggered;
94 
95 
105  void init(HiCalData &cal, const HiCalConf &conf) {
106  DbProfile prof = conf.getMatrixProfile();
107  _history.clear();
108  _history.add("Profile["+ prof.Name()+"]");
109 
110  int line0 = toInt(ConfKey(prof,"ZeroReverseFirstLine",QString("0")));
111  int lineN = toInt(ConfKey(prof,"ZeroReverseLastLine",QString("19")));
112  QString tfile= conf.getMatrixSource("ReverseClockStatistics",prof);
113 
114  HiMatrix revclk = cropLines(cal.getReverseClock(), line0, lineN);
115  _stats.Reset();
116  _stats.AddData(revclk[0], revclk.dim1()*revclk.dim2());
117 
118  _revClock = averageLines(revclk);
119  _history.add("RevClock(CropLines["+ToString(line0)+","+ToString(lineN) +
120  "],Mean["+ToString(_stats.Average()) +
121  "],StdDev["+ToString(_stats.StandardDeviation()) +
122  "],LisPixels["+ToString(_stats.LisPixels())+
123  "],HisPixels["+ToString(_stats.HisPixels()) +
124  "],NulPixels["+ToString(_stats.NullPixels())+ "])");
125 
126  DbAccess triggers(Pvl(tfile).findObject("ReverseClockStatistics"));
127  QString tprofName = conf.resolve("{FILTER}{CCD}_{CHANNEL}_{BIN}",prof);
128  _history.add("ReverseClockStatistics(File["+tfile+
129  "],Profile["+tprofName+"])");
130 
131  _triggered= false;
132  if (triggers.profileExists(tprofName)) {
133  DbProfile tprof(prof, triggers.getProfile(tprofName), tprofName);
134  double revmean = toDouble(ConfKey(tprof,"RevMeanTrigger", toString(_stats.Average())));
135  double revstddev = toDouble(ConfKey(tprof,"RevStdDevTrigger", toString(DBL_MAX)));
136  int lisTol = toInt(ConfKey(tprof, "RevLisTolerance", toString(1)));
137  int hisTol = toInt(ConfKey(tprof, "RevHisTolerance", toString(1)));
138  int nulTol = toInt(ConfKey(tprof, "RevNulTolerance", toString(1)));
139 
140  _history.add("TriggerLimits(RevMeanTrigger["+ToString(revmean) +
141  "],RevStdDevTrigger["+ToString(revstddev)+
142  "],RevLisTolerance["+ToString(lisTol)+
143  "],RevHisTolerance["+ToString(hisTol)+
144  "],RevNulTolerance["+ToString(nulTol)+ "])");
145 
146  if ((_stats.LisPixels() > lisTol) || (_stats.HisPixels() > hisTol) ||
147  (_stats.NullPixels() > nulTol) ||
148  (_stats.StandardDeviation() > revstddev)) {
149  _triggered = true;
150  _data = HiVector(_revClock.dim1(), revmean);
151  _history.add("Trigger(True - Reverse Clock set to constant,"
152  "ReverseClock["+ToString(revmean)+"])");
153  }
154  else {
155  _history.add("Trigger(False - Reverse Clock processing invoked)");
156  _triggered = false;
157  }
158  }
159  else {
160  _history.add("Trigger(Profile["+tprofName+"],NotFound!)");
161  _triggered = false;
162  }
163 
164  if (!_triggered) {
165  SplineFill spline(_revClock, _history);
166  _data = spline.ref();
167  _history = spline.History();
168  }
169 
170  return;
171  }
172 
174  virtual void printOn(std::ostream &o) const {
175  o << "# History = " << _history << std::endl;
176  // Write out the header
177  o << std::setw(_fmtWidth) << "RevClock"
178  << std::setw(_fmtWidth+1) << "Applied\n";
179 
180  for (int i = 0 ; i < _data.dim() ; i++) {
181  o << formatDbl(_revClock[i]) << " "
182  << formatDbl(_data[i]) << std::endl;
183  }
184  return;
185  }
186 
187  };
188 
189 } // namespace Isis
190 #endif
191 
const HiVector & ref() const
Return data via a const reference.
Definition: Module.h:126
double StandardDeviation() const
Computes and returns the standard deviation.
Definition: Statistics.cpp:325
int _fmtWidth
Default field with of double.
Definition: Module.h:168
HiVector _data
Data vector.
Definition: Module.h:166
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
bool profileExists(const QString &profile) const
Checks existance of a database user profile.
Definition: DbAccess.h:152
Compute a low pass filter from a Module class content.
Definition: SplineFill.h:47
HiHistory _history
Hierarchial component history.
Definition: Module.h:167
virtual void printOn(std::ostream &o) const
Virtual dump of data processing vectors.
Definition: ZeroReverse.h:174
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
Definition: Statistics.cpp:511
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
Definition: Statistics.cpp:478
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:65
const HiHistory & History() const
Return recorded history of events.
Definition: Module.h:131
QString formatDbl(const double &value) const
Properly format values that could be special pixels.
Definition: Module.h:184
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
const DbProfile getProfile(const QString &name="") const
Retrieves the specified access profile.
Definition: DbAccess.cpp:106
void init(HiCalData &cal, const HiCalConf &conf)
Initialize and compute data solution.
Definition: ZeroReverse.h:105
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
Definition: Statistics.cpp:489
void Reset()
Reset all accumulators and counters to zero.
Definition: Statistics.cpp:126
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:54
Processes Reverse Clock calibration data (ZeroReverse Module)
Definition: ZeroReverse.h:60
const Statistics & Stats() const
Return statistics for raw Reverse Clock buffer.
Definition: ZeroReverse.h:78
Container for cube-like labels.
Definition: Pvl.h:135
bool wasTriggered() const
Specifies if the input trigger conditions were met.
Definition: ZeroReverse.h:88
HiVector averageLines(const HiMatrix &m, int sline=0, int eline=-1)
Reduces by averaging specified lines from a buffer.
Definition: HiCalUtil.h:171
virtual ~ZeroReverse()
Destructor.
Definition: ZeroReverse.h:71
DbAccess manages programatic access to a database through profiles.
Definition: DbAccess.h:120
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
T ConfKey(const DbProfile &conf, const QString &keyname, const T &defval, int index=0)
Find a keyword in a profile using default for non-existant keywords.
Definition: HiCalUtil.h:219
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:118
HiMatrix cropLines(const HiMatrix &m, int sline, int eline)
Crop specified lines from a buffer.
Definition: HiCalUtil.h:125
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition: Statistics.cpp:154
Container for HiRISE calibration data.
Definition: HiCalData.h:50
QString ToString(const T &value)
Helper function to convert values to strings.
Definition: HiCalUtil.h:260
double Average() const
Computes and returns the average.
Definition: Statistics.cpp:313
TNT::Array2D< double > HiMatrix
2-D buffer
Definition: HiCalTypes.h:41
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:40