Isis Developer Reference
ZeroReverse.h
Go to the documentation of this file.
1#ifndef ZeroReverse_h
2#define ZeroReverse_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 "Statistics.h"
26#include "SpecialPixel.h"
27#include "IException.h"
28
29namespace Isis {
30
46 class ZeroReverse : public Module {
47
48 public:
49 // Constructors and Destructor
50 ZeroReverse() : Module("ZeroReverse") { }
51 ZeroReverse(HiCalData &cal, const HiCalConf &conf) :
52 Module("ZeroReverse") {
53 init(cal, conf);
54 }
55
57 virtual ~ZeroReverse() { }
58
64 const Statistics &Stats() const { return (_stats); }
65
74 bool wasTriggered() const { return (_triggered); }
75
76 private:
77 HiVector _revClock;
78 Statistics _stats;
79 bool _triggered;
80
81
91 void init(HiCalData &cal, const HiCalConf &conf) {
92 DbProfile prof = conf.getMatrixProfile();
94 _history.add("Profile["+ prof.Name()+"]");
95
96 int line0 = toInt(ConfKey(prof,"ZeroReverseFirstLine",QString("0")));
97 int lineN = toInt(ConfKey(prof,"ZeroReverseLastLine",QString("19")));
98 QString tfile= conf.getMatrixSource("ReverseClockStatistics",prof);
99
100 HiMatrix revclk = cropLines(cal.getReverseClock(), line0, lineN);
101 _stats.Reset();
102 _stats.AddData(revclk[0], revclk.dim1()*revclk.dim2());
103
104 _revClock = averageLines(revclk);
105 _history.add("RevClock(CropLines["+ToString(line0)+","+ToString(lineN) +
106 "],Mean["+ToString(_stats.Average()) +
107 "],StdDev["+ToString(_stats.StandardDeviation()) +
108 "],LisPixels["+ToString(_stats.LisPixels())+
109 "],HisPixels["+ToString(_stats.HisPixels()) +
110 "],NulPixels["+ToString(_stats.NullPixels())+ "])");
111
112 DbAccess triggers(Pvl(tfile).findObject("ReverseClockStatistics"));
113 QString tprofName = conf.resolve("{FILTER}{CCD}_{CHANNEL}_{BIN}",prof);
114 _history.add("ReverseClockStatistics(File["+tfile+
115 "],Profile["+tprofName+"])");
116
117 _triggered= false;
118 if (triggers.profileExists(tprofName)) {
119 DbProfile tprof(prof, triggers.getProfile(tprofName), tprofName);
120 double revmean = toDouble(ConfKey(tprof,"RevMeanTrigger", toString(_stats.Average())));
121 double revstddev = toDouble(ConfKey(tprof,"RevStdDevTrigger", toString(DBL_MAX)));
122 int lisTol = toInt(ConfKey(tprof, "RevLisTolerance", toString(1)));
123 int hisTol = toInt(ConfKey(tprof, "RevHisTolerance", toString(1)));
124 int nulTol = toInt(ConfKey(tprof, "RevNulTolerance", toString(1)));
125
126 _history.add("TriggerLimits(RevMeanTrigger["+ToString(revmean) +
127 "],RevStdDevTrigger["+ToString(revstddev)+
128 "],RevLisTolerance["+ToString(lisTol)+
129 "],RevHisTolerance["+ToString(hisTol)+
130 "],RevNulTolerance["+ToString(nulTol)+ "])");
131
132 if ((_stats.LisPixels() > lisTol) || (_stats.HisPixels() > hisTol) ||
133 (_stats.NullPixels() > nulTol) ||
134 (_stats.StandardDeviation() > revstddev)) {
135 _triggered = true;
136 _data = HiVector(_revClock.dim1(), revmean);
137 _history.add("Trigger(True - Reverse Clock set to constant,"
138 "ReverseClock["+ToString(revmean)+"])");
139 }
140 else {
141 _history.add("Trigger(False - Reverse Clock processing invoked)");
142 _triggered = false;
143 }
144 }
145 else {
146 _history.add("Trigger(Profile["+tprofName+"],NotFound!)");
147 _triggered = false;
148 }
149
150 if (!_triggered) {
151 SplineFill spline(_revClock, _history);
152 _data = spline.ref();
153 _history = spline.History();
154 }
155
156 return;
157 }
158
160 virtual void printOn(std::ostream &o) const {
161 o << "# History = " << _history << std::endl;
162 // Write out the header
163 o << std::setw(_fmtWidth) << "RevClock"
164 << std::setw(_fmtWidth+1) << "Applied\n";
165
166 for (int i = 0 ; i < _data.dim() ; i++) {
167 o << formatDbl(_revClock[i]) << " "
168 << formatDbl(_data[i]) << std::endl;
169 }
170 return;
171 }
172
173 };
174
175} // namespace Isis
176#endif
DbAccess manages programatic access to a database through profiles.
Definition DbAccess.h:106
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
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
Container for cube-like labels.
Definition Pvl.h:119
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:94
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
Definition Statistics.cpp:465
double Average() const
Computes and returns the average.
Definition Statistics.cpp:300
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
Definition Statistics.cpp:476
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
Definition Statistics.cpp:498
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 Reverse Clock calibration data (ZeroReverse Module)
Definition ZeroReverse.h:46
virtual ~ZeroReverse()
Destructor.
Definition ZeroReverse.h:57
ZeroReverse(HiCalData &cal, const HiCalConf &conf)
Definition ZeroReverse.h:51
ZeroReverse()
Definition ZeroReverse.h:50
bool wasTriggered() const
Specifies if the input trigger conditions were met.
Definition ZeroReverse.h:74
const Statistics & Stats() const
Return statistics for raw Reverse Clock buffer.
Definition ZeroReverse.h:64
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
TNT::Array2D< double > HiMatrix
2-D buffer
Definition HiCalTypes.h:28
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
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
HiVector averageLines(const HiMatrix &m, int sline=0, int eline=-1)
Reduces by averaging specified lines from a buffer.
Definition HiCalUtil.h:157
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
HiMatrix cropLines(const HiMatrix &m, int sline, int eline)
Crop specified lines from a buffer.
Definition HiCalUtil.h:111