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
26namespace 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) {
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
IO Handler for Isis Cubes.
Definition Cube.h:168
A DbProfile is a container for access parameters to a database.
Definition DbProfile.h:51
Computes units parameters for HiRISE data calibration (Ziof Module)
Definition GainUnitConversion.h:43
virtual ~GainUnitConversion()
Destructor.
Definition GainUnitConversion.h:54
GainUnitConversion(HiCalConf &conf, const QString &units, Cube *cube)
Definition GainUnitConversion.h:48
GainUnitConversion()
Definition GainUnitConversion.h:47
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
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:236
double ToDouble(const T &value)
Helper function to convert values to doubles.
Definition HiCalUtil.h:224
bool IsEqual(const QString &v1, const QString &v2="TRUE")
Shortened string equality test.
Definition HiCalUtil.h:248