Isis 3 Programmer Reference
ZeroBufferSmooth.h
Go to the documentation of this file.
1 #ifndef ZeroBufferSmooth_h
2 #define ZeroBufferSmooth_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 "LowPassFilter.h"
40 #include "Statistics.h"
41 #include "SpecialPixel.h"
42 #include "IException.h"
43 
44 namespace Isis {
45 
67  class ZeroBufferSmooth : public Module {
68 
69  public:
70  // Constructors and Destructor
71  ZeroBufferSmooth() : Module("ZeroBufferSmooth") { }
81  ZeroBufferSmooth(HiCalData &cal, const HiCalConf &conf) :
82  Module("ZeroBufferSmooth") {
83  init(cal, conf);
84  }
85 
87  virtual ~ZeroBufferSmooth() { }
88 
94  const Statistics &Stats() const { return (_stats); }
95 
96  private:
97  HiVector _buffer;
98  Statistics _stats;
99 
111  void init(HiCalData &cal, const HiCalConf &conf) {
112  DbProfile prof = conf.getMatrixProfile();
113  _history.clear();
114  _history.add("Profile["+ prof.Name()+"]");
115 
116  int samp0 = toInt(ConfKey(prof,"ZeroBufferSmoothFirstSample",QString("0")));
117  int sampN = toInt(ConfKey(prof,"ZeroBufferSmoothLastSample",QString("11")));
118  _buffer = averageSamples(cal.getBuffer(), samp0, sampN);
119  _history.add("AveCols(Buffer["+ToString(samp0)+","+ToString(sampN)+"])");
120 
121  // Smooth/filter the averages
122  LowPassFilter bufter(_buffer, _history,
123  toInt(ConfKey(prof,"ZeroBufferSmoothFilterWidth",QString("201"))),
124  toInt(ConfKey(prof,"ZeroBufferSmoothFilterIterations",QString("2"))));
125  // If need be, fill the data with a cubic spline
126  SplineFill spline(bufter);
127  _data = spline.ref();
128  _history = spline.History();
129 
130  // Compute statistics and record to history
131  _stats.Reset();
132  for ( int i = 0 ; i < _data.dim() ; i++ ) {
133  // Spline guarantees _data is non-null!
134  if ( !IsSpecial(_buffer[i]) ) {
135  _stats.AddData(_data[i] - _buffer[i]);
136  }
137  }
138  _history.add("Statistics(Average["+ToString(_stats.Average())+
139  "],StdDev["+ToString(_stats.StandardDeviation())+"])");
140  return;
141  }
142 
150  virtual void printOn(std::ostream &o) const {
151  o << "# History = " << _history << std::endl;
152  // Write out the header
153  o << std::setw(_fmtWidth) << "RawBuffer"
154  << std::setw(_fmtWidth+1) << "Filtered\n";
155 
156  for (int i = 0 ; i < _data.dim() ; i++) {
157  o << formatDbl(_buffer[i]) << " "
158  << formatDbl(_data[i]) << std::endl;
159  }
160  return;
161  }
162 
163  };
164 
165 } // namespace Isis
166 #endif
167 
const HiVector & ref() const
Return data via a const reference.
Definition: Module.h:126
void init(HiCalData &cal, const HiCalConf &conf)
Workhorse of the zero buffer computation.
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 averageSamples(const HiMatrix &m, int ssamp=0, int esamp=-1)
Reduces by averaging specified samples from a buffer.
Definition: HiCalUtil.h:196
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
Compute a low pass filter from a Module class content.
Definition: SplineFill.h:47
HiHistory _history
Hierarchial component history.
Definition: Module.h:167
virtual ~ZeroBufferSmooth()
Destructor.
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 Statistics & Stats() const
Return statistics for filtered - raw Buffer.
void Reset()
Reset all accumulators and counters to zero.
Definition: Statistics.cpp:126
Compute a low pass filter from a Module class content.
Definition: LowPassFilter.h:45
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:54
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:212
Processes Buffer calibration data (ZeroBufferSmooth Module)
ZeroBufferSmooth(HiCalData &cal, const HiCalConf &conf)
Construct with data parameters.
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
virtual void printOn(std::ostream &o) const
Virtualized parameter reporting method.
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::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:40