Isis Developer Reference
GainChannelNormalize.h
Go to the documentation of this file.
1 #ifndef GainChannelNormalize_h
2 #define GainChannelNormalize_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <cmath>
13 #include <string>
14 #include <vector>
15 
16 #include "IString.h"
17 #include "HiCalTypes.h"
18 #include "HiCalUtil.h"
19 #include "HiCalConf.h"
20 #include "Module.h"
21 #include "FileName.h"
22 
23 #include "IException.h"
24 
25 namespace Isis {
26 
37  class GainChannelNormalize : public Module {
38 
39  public:
40  // Constructors and Destructor
41  GainChannelNormalize() : Module("GainChannelNormalize") { }
42  GainChannelNormalize(const HiCalConf &conf) :
43  Module("GainChannelNormalize") {
44  init(conf);
45  }
46 
48  virtual ~GainChannelNormalize() { }
49 
50  private:
51 
52  void init(const HiCalConf &conf) {
53  _history.clear();
54  DbProfile prof = conf.getMatrixProfile();
55  _history.add("Profile["+ prof.Name()+"]");
56 
57  double bin = ToDouble(prof("Summing"));
58  double tdi = ToDouble(prof("Tdi"));
59  double _normalizer = 128.0 / tdi / (bin*bin);
60  _history.add("ModeNormalizer["+ToString(_normalizer)+"]");
61 
62  HiVector z = loadCsv("Gains", conf, prof, 0);
63  int nsamps = ToInteger(prof("Samples"));
64  _data = HiVector(nsamps);
65  // Support a single value being read or equal to the number of samples
66  if ( z.dim() == 1 ) {
67  _data = z[0];
68  }
69  else if ( z.dim() == nsamps) {
70  _data = z;
71  }
72  else {
73  std::ostringstream mess;
74  mess << "Expected 1 or " << nsamps << " values from CSV file "
75  << getcsvFile() << " but got " << z.dim() << " instead!";
76  throw IException(IException::User, mess.str(), _FILEINFO_);
77  }
78 
79  // Apply the factor to the data
80  for ( int i = 0 ; i < _data.dim() ; i++ ) { _data[i] *= _normalizer; }
81  return;
82  }
83 
84  };
85 
86 } // namespace Isis
87 #endif
Isis::Module::_history
HiHistory _history
Hierarchial component history.
Definition: Module.h:152
Isis::HiHistory::clear
void clear()
Definition: HiCalTypes.h:65
FileName.h
Isis::DbProfile::Name
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:104
Isis::GainChannelNormalize
Computes a gain correction for each sample GainChannelNormalize.
Definition: GainChannelNormalize.h:37
Isis::ToString
QString ToString(const T &value)
Helper function to convert values to strings.
Definition: HiCalUtil.h:246
Isis::Module
Module manages HiRISE calibration vectors from various sources.
Definition: Module.h:39
HiCalConf.h
Isis::GainChannelNormalize::GainChannelNormalize
GainChannelNormalize(const HiCalConf &conf)
Definition: GainChannelNormalize.h:42
IString.h
Isis::GainChannelNormalize::~GainChannelNormalize
virtual ~GainChannelNormalize()
Destructor.
Definition: GainChannelNormalize.h:48
Isis::Module::_data
HiVector _data
Data vector.
Definition: Module.h:151
Isis::GainChannelNormalize::GainChannelNormalize
GainChannelNormalize()
Definition: GainChannelNormalize.h:41
Isis::Module::loadCsv
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:101
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::ToInteger
int ToInteger(const T &value)
Helper function to convert values to Integers.
Definition: HiCalUtil.h:222
HiCalUtil.h
Isis::DbProfile
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:51
HiCalTypes.h
Isis::HiVector
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:27
Isis::HiHistory::add
void add(const QString &event)
Definition: HiCalTypes.h:55
Isis::ToDouble
double ToDouble(const T &value)
Helper function to convert values to doubles.
Definition: HiCalUtil.h:234
IException.h
Isis::Module::getcsvFile
QString getcsvFile() const
Returns expanded name of last CSV file loaded by loadCsv.
Definition: Module.h:71
Module.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126