Isis Developer Reference
ZeroBufferSmooth.h
Go to the documentation of this file.
1#ifndef ZeroBufferSmooth_h
2#define ZeroBufferSmooth_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12#include <cmath>
13#include <string>
14#include <vector>
15#include <iostream>
16#include <sstream>
17
18
19#include "IString.h"
20#include "HiCalTypes.h"
21#include "HiCalUtil.h"
22#include "HiCalConf.h"
23#include "Module.h"
24#include "SplineFill.h"
25#include "LowPassFilter.h"
26#include "Statistics.h"
27#include "SpecialPixel.h"
28#include "IException.h"
29
30namespace Isis {
31
53 class ZeroBufferSmooth : public Module {
54
55 public:
56 // Constructors and Destructor
57 ZeroBufferSmooth() : Module("ZeroBufferSmooth") { }
67 ZeroBufferSmooth(HiCalData &cal, const HiCalConf &conf) :
68 Module("ZeroBufferSmooth") {
69 init(cal, conf);
70 }
71
73 virtual ~ZeroBufferSmooth() { }
74
80 const Statistics &Stats() const { return (_stats); }
81
82 private:
83 HiVector _buffer;
84 Statistics _stats;
85
97 void init(HiCalData &cal, const HiCalConf &conf) {
98 DbProfile prof = conf.getMatrixProfile();
100 _history.add("Profile["+ prof.Name()+"]");
101
102 int samp0 = toInt(ConfKey(prof,"ZeroBufferSmoothFirstSample",QString("0")));
103 int sampN = toInt(ConfKey(prof,"ZeroBufferSmoothLastSample",QString("11")));
104 _buffer = averageSamples(cal.getBuffer(), samp0, sampN);
105 _history.add("AveCols(Buffer["+ToString(samp0)+","+ToString(sampN)+"])");
106
107 // Smooth/filter the averages
108 LowPassFilter bufter(_buffer, _history,
109 toInt(ConfKey(prof,"ZeroBufferSmoothFilterWidth",QString("201"))),
110 toInt(ConfKey(prof,"ZeroBufferSmoothFilterIterations",QString("2"))));
111 // If need be, fill the data with a cubic spline
112 SplineFill spline(bufter);
113 _data = spline.ref();
114 _history = spline.History();
115
116 // Compute statistics and record to history
117 _stats.Reset();
118 for ( int i = 0 ; i < _data.dim() ; i++ ) {
119 // Spline guarantees _data is non-null!
120 if ( !IsSpecial(_buffer[i]) ) {
121 _stats.AddData(_data[i] - _buffer[i]);
122 }
123 }
124 _history.add("Statistics(Average["+ToString(_stats.Average())+
125 "],StdDev["+ToString(_stats.StandardDeviation())+"])");
126 return;
127 }
128
136 virtual void printOn(std::ostream &o) const {
137 o << "# History = " << _history << std::endl;
138 // Write out the header
139 o << std::setw(_fmtWidth) << "RawBuffer"
140 << std::setw(_fmtWidth+1) << "Filtered\n";
141
142 for (int i = 0 ; i < _data.dim() ; i++) {
143 o << formatDbl(_buffer[i]) << " "
144 << formatDbl(_data[i]) << std::endl;
145 }
146 return;
147 }
148
149 };
150
151} // namespace Isis
152#endif
A DbProfile is a container for access parameters to a database.
Definition DbProfile.h:51
Container for HiRISE calibration data.
Definition HiCalData.h:35
void clear()
Definition HiCalTypes.h:65
void add(const QString &event)
Definition HiCalTypes.h:55
Compute a low pass filter from a Module class content.
Definition LowPassFilter.h:30
Module manages HiRISE calibration vectors from various sources.
Definition Module.h:39
HiVector _data
Data vector.
Definition Module.h:151
HiHistory _history
Hierarchial component history.
Definition Module.h:152
int _fmtWidth
Default field with of double.
Definition Module.h:153
QString formatDbl(const double &value) const
Properly format values that could be special pixels.
Definition Module.h:169
Compute a low pass filter from a Module class content.
Definition SplineFill.h:32
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:94
double Average() const
Computes and returns the average.
Definition Statistics.cpp:300
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition Statistics.cpp:141
double StandardDeviation() const
Computes and returns the standard deviation.
Definition Statistics.cpp:312
void Reset()
Reset all accumulators and counters to zero.
Definition Statistics.cpp:113
Processes Buffer calibration data (ZeroBufferSmooth Module)
Definition ZeroBufferSmooth.h:53
ZeroBufferSmooth()
Definition ZeroBufferSmooth.h:57
virtual ~ZeroBufferSmooth()
Destructor.
Definition ZeroBufferSmooth.h:73
const Statistics & Stats() const
Return statistics for filtered - raw Buffer.
Definition ZeroBufferSmooth.h:80
ZeroBufferSmooth(HiCalData &cal, const HiCalConf &conf)
Construct with data parameters.
Definition ZeroBufferSmooth.h:67
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
HiVector averageSamples(const HiMatrix &m, int ssamp=0, int esamp=-1)
Reduces by averaging specified samples from a buffer.
Definition HiCalUtil.h:182
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:205
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition SpecialPixel.h:197
TNT::Array1D< double > HiVector
1-D Buffer
Definition HiCalTypes.h:27
QString ToString(const T &value)
Helper function to convert values to strings.
Definition HiCalUtil.h:246