Isis Developer Reference
GainUnitConversion.h
Go to the documentation of this file.
1 #ifndef GainUnitConversion_h
2 #define GainUnitConversion_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <cmath>
13 #include <string>
14 #include <vector>
15 
16 #include "Cube.h"
17 #include "IString.h"
18 #include "HiCalTypes.h"
19 #include "HiCalUtil.h"
20 #include "HiCalConf.h"
21 #include "Module.h"
22 #include "FileName.h"
23 
24 #include "IException.h"
25 
26 namespace Isis {
27 
43  class GainUnitConversion : public Module {
44 
45  public:
46  // Constructors and Destructor
47  GainUnitConversion() : Module("GainUnitConversion"), _units("DN") { }
48  GainUnitConversion(HiCalConf &conf, const QString &units, Cube *cube) :
49  Module("GainUnitConversion"), _units(units) {
50  init(conf, cube);
51  }
52 
54  virtual ~GainUnitConversion() { }
55 
56  private:
57  QString _units;
58 
59  void init(HiCalConf &conf, Cube *cube) {
60  _history.clear();
61  DbProfile prof = conf.getMatrixProfile();
62  _history.add("Profile["+ prof.Name()+"]");
63 
64  double sed = ToDouble(prof("ScanExposureDuration")); // units = us
65  if ( IsEqual(_units, "IOF") ) {
66  // Add solar I/F correction parameters
67  double au = conf.sunDistanceAU(cube);
68  _history.add("SunDist[" + ToString(au) + " (AU)]");
69  double suncorr = 1.5 / au;
70  suncorr *= suncorr;
71 
72  double zbin = ToDouble(prof("GainUnitConversionBinFactor"));
73  _history.add("GainUnitConversionBinFactor[" + ToString(zbin) + "]");
74 
75  double ztemp = getTempDepGain(conf, prof);
76  _history.add("ScanExposureDuration[" + ToString(sed) + "]");
77  double ziof = (zbin * ztemp) * (sed * 1.0e-6) * suncorr;
78  _data = HiVector(1, ziof);
79 
80  _history.add("I/F_Factor[" + ToString(ziof) + "]");
81  _history.add("Units[I/F]");
82  }
83  else if ( IsEqual(_units, "DN/US") ) {
84  // Ziof is a divisor in calibration equation
85  double ziof = sed;
86  _data = HiVector(1, ziof);
87  _history.add("ScanExposureDuration[" + ToString(sed) + "]");
88  _history.add("DN/uS_Factor[" + ToString(ziof) + "]");
89  _history.add("Units[DNs/microsecond]");
90  }
91  else {
92  // Units are already in DN
93  double ziof = 1.0;
94  _data = HiVector(1, ziof);
95  _history.add("DN_Factor[" + ToString(ziof) + "]");
96  _history.add("Units[DN]");
97  }
98 
99  return;
100  }
101 
111  double getTempDepGain(const HiCalConf &conf, const DbProfile &prof) {
112  double zgain = ToDouble(prof("FilterGainCorrection"));
113  _history.add("FilterGainCorrection[" + ToString(zgain) + "]");
114 
115  double fpa_py_temp = ToDouble(prof("FpaPositiveYTemperature"));
116  double fpa_my_temp = ToDouble(prof("FpaNegativeYTemperature"));
117  double T = (fpa_py_temp+fpa_my_temp) / 2.0;
118  _history.add("T(AveFpa_YTemp)[" + ToString(T) + "]");
119 
120  double baseT = ToDouble(prof("IoverFbasetemperature"));
121  _history.add("IoverFbasetemperature[" + ToString(baseT) + "]");
122 
123  double QEpcntC = ToDouble(prof("QEpercentincreaseperC"));
124  _history.add("QEpercentincreaseperC[" + ToString(QEpcntC) + "]");
125 
126  double absGainTdi = ToDouble(prof("AbsGain_TDI128"));
127  _history.add("AbsGain_TDI128[" + ToString(absGainTdi) + "]");
128 
129  double QETD = zgain * ( 1.0 + (T - baseT) * QEpcntC * absGainTdi);
130  _history.add("CalFactQETempDep[" + ToString(QETD) + "]");
131  return (QETD);
132  }
133 
134 
135  };
136 
137 } // namespace Isis
138 #endif
Isis::Module::_history
HiHistory _history
Hierarchial component history.
Definition: Module.h:152
Isis::IsEqual
bool IsEqual(const QString &v1, const QString &v2="TRUE")
Shortened string equality test.
Definition: HiCalUtil.h:258
Isis::HiHistory::clear
void clear()
Definition: HiCalTypes.h:65
FileName.h
Cube.h
Isis::DbProfile::Name
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:104
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
Isis::GainUnitConversion::~GainUnitConversion
virtual ~GainUnitConversion()
Destructor.
Definition: GainUnitConversion.h:54
HiCalConf.h
Isis::GainUnitConversion::GainUnitConversion
GainUnitConversion(HiCalConf &conf, const QString &units, Cube *cube)
Definition: GainUnitConversion.h:48
IString.h
Isis::Module::_data
HiVector _data
Data vector.
Definition: Module.h:151
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::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::GainUnitConversion::GainUnitConversion
GainUnitConversion()
Definition: GainUnitConversion.h:47
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::GainUnitConversion
Computes units parameters for HiRISE data calibration (Ziof Module)
Definition: GainUnitConversion.h:43
Module.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16