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
25namespace Isis {
26
38
39 public:
40 // Constructors and Destructor
41 GainChannelNormalize() : Module("GainChannelNormalize") { }
42 GainChannelNormalize(const HiCalConf &conf) :
43 Module("GainChannelNormalize") {
44 init(conf);
45 }
46
49
50 private:
51
52 void init(const HiCalConf &conf) {
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
#define _FILEINFO_
Macro for the filename and line number.
Definition IException.h:24
A DbProfile is a container for access parameters to a database.
Definition DbProfile.h:51
Computes a gain correction for each sample GainChannelNormalize.
Definition GainChannelNormalize.h:37
GainChannelNormalize(const HiCalConf &conf)
Definition GainChannelNormalize.h:42
GainChannelNormalize()
Definition GainChannelNormalize.h:41
virtual ~GainChannelNormalize()
Destructor.
Definition GainChannelNormalize.h:48
void clear()
Definition HiCalTypes.h:65
void add(const QString &event)
Definition HiCalTypes.h:55
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
Module manages HiRISE calibration vectors from various sources.
Definition Module.h:39
HiVector _data
Data vector.
Definition Module.h:151
QString getcsvFile() const
Returns expanded name of last CSV file loaded by loadCsv.
Definition Module.h:71
HiHistory _history
Hierarchial component history.
Definition Module.h:152
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
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
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
double ToDouble(const T &value)
Helper function to convert values to doubles.
Definition HiCalUtil.h:234
int ToInteger(const T &value)
Helper function to convert values to Integers.
Definition HiCalUtil.h:222