Isis 3 Programmer Reference
GainChannelNormalize.h
Go to the documentation of this file.
1 #ifndef GainChannelNormalize_h
2 #define GainChannelNormalize_h
3 
26 #include <cmath>
27 #include <string>
28 #include <vector>
29 
30 #include "IString.h"
31 #include "HiCalTypes.h"
32 #include "HiCalUtil.h"
33 #include "HiCalConf.h"
34 #include "Module.h"
35 #include "FileName.h"
36 
37 #include "IException.h"
38 
39 namespace Isis {
40 
51  class GainChannelNormalize : public Module {
52 
53  public:
54  // Constructors and Destructor
55  GainChannelNormalize() : Module("GainChannelNormalize") { }
56  GainChannelNormalize(const HiCalConf &conf) :
57  Module("GainChannelNormalize") {
58  init(conf);
59  }
60 
62  virtual ~GainChannelNormalize() { }
63 
64  private:
65 
66  void init(const HiCalConf &conf) {
67  _history.clear();
68  DbProfile prof = conf.getMatrixProfile();
69  _history.add("Profile["+ prof.Name()+"]");
70 
71  double bin = ToDouble(prof("Summing"));
72  double tdi = ToDouble(prof("Tdi"));
73  double _normalizer = 128.0 / tdi / (bin*bin);
74  _history.add("ModeNormalizer["+ToString(_normalizer)+"]");
75 
76  HiVector z = loadCsv("Gains", conf, prof, 0);
77  int nsamps = ToInteger(prof("Samples"));
78  _data = HiVector(nsamps);
79  // Support a single value being read or equal to the number of samples
80  if ( z.dim() == 1 ) {
81  _data = z[0];
82  }
83  else if ( z.dim() == nsamps) {
84  _data = z;
85  }
86  else {
87  std::ostringstream mess;
88  mess << "Expected 1 or " << nsamps << " values from CSV file "
89  << getcsvFile() << " but got " << z.dim() << " instead!";
90  throw IException(IException::User, mess.str(), _FILEINFO_);
91  }
92 
93  // Apply the factor to the data
94  for ( int i = 0 ; i < _data.dim() ; i++ ) { _data[i] *= _normalizer; }
95  return;
96  }
97 
98  };
99 
100 } // namespace Isis
101 #endif
HiVector _data
Data vector.
Definition: Module.h:166
HiHistory _history
Hierarchial component history.
Definition: Module.h:167
HiVector loadCsv(const QString &csvBase, const HiCalConf &conf, const DbProfile &prof, const int &elements=0)
Provide generic loading of CSV file for all modules.
Definition: Module.h:116
virtual ~GainChannelNormalize()
Destructor.
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:65
int ToInteger(const T &value)
Helper function to convert values to Integers.
Definition: HiCalUtil.h:236
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:54
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
double ToDouble(const T &value)
Helper function to convert values to doubles.
Definition: HiCalUtil.h:248
Computes a gain correction for each sample GainChannelNormalize.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QString getcsvFile() const
Returns expanded name of last CSV file loaded by loadCsv.
Definition: Module.h:86
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:118
QString ToString(const T &value)
Helper function to convert values to strings.
Definition: HiCalUtil.h:260
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:40