Isis 3 Programmer Reference
TopoAtm.cpp
1 #include <cmath>
2 #include "TopoAtm.h"
3 #include "NumericalApproximation.h"
4 #include "IException.h"
5 
6 namespace Isis {
7  /*
8  * @history 2008-11-05 Jeannie Walldren - Modified references to
9  * NumericalMethods class and replaced Isis::PI with PI
10  * since this is in Isis namespace.
11  */
12  TopoAtm::TopoAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : NormModel(pvl, pmodel, amodel) {
13  double psurf0;
14  double psurfref;
15  double pprimeref;
16  double ahref;
17  double munotref;
18  double pstdref;
19  double transref;
20  double trans0ref;
21  double transs;
22  double sbar;
23 
24  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
25 
26  SetNormPharef(0.0);
27  SetNormIncref(0.0);
28  SetNormEmaref(0.0);
29  SetNormAlbedo(1.0);
30 
31  if(algorithm.hasKeyword("Incref")) {
32  SetNormIncref(algorithm["Incref"]);
33  }
34 
35  if(algorithm.hasKeyword("Pharef")) {
36  SetNormPharef(algorithm["Pharef"]);
37  }
38  else {
39  p_normPharef = p_normIncref;
40  }
41 
42  if(algorithm.hasKeyword("Emaref")) {
43  SetNormEmaref(algorithm["Emaref"]);
44  }
45 
46  if(algorithm.hasKeyword("Albedo")) {
47  SetNormAlbedo(algorithm["Albedo"]);
48  }
49 
50  // First-time setup:
51  // Calculate normalization at standard conditions
52  GetPhotoModel()->SetStandardConditions(true);
53  psurf0 = GetPhotoModel()->CalcSurfAlbedo(0.0, 0.0, 0.0);
54 
55  if(psurf0 == 0.0) {
56  std::string msg = "Divide by zero encountered";
57  throw IException(IException::Unknown, msg, _FILEINFO_);
58  }
59  else {
60  p_normRhobar = p_normAlbedo / psurf0;
61  }
62 
63  psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
64  pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
65  GetPhotoModel()->SetStandardConditions(false);
66 
67  // Get reference hemispheric albedo (p_photoB0 doesn't influence it much)
68  GetAtmosModel()->GenerateAhTable();
69 
70  ahref = (GetAtmosModel()->AtmosAhSpline()).Evaluate(p_normIncref, NumericalApproximation::Extrapolate);
71 
72  munotref = cos((PI / 180.0) * p_normIncref);
73 
74  // Now calculate atmosphere at standard conditions
75  GetAtmosModel()->SetStandardConditions(true);
76  GetAtmosModel()->CalcAtmEffect(p_normPharef, p_normIncref, p_normEmaref, &pstdref, &transref,
77  &trans0ref, &sbar, &transs);
78  GetAtmosModel()->SetStandardConditions(false);
79 
80  // Finally, calculate the additive and multiplicative parts of the
81  // output-normalized signal, from the point of view of fixed albedo
82  // and varying topography
83  p_normAout = p_normRhobar * pprimeref * trans0ref;
84  p_normBout = pstdref + p_normRhobar * (transref * ahref * munotref /
85  (1.0 - p_normRhobar * GetAtmosModel()->AtmosAb() * sbar) + trans0ref *
86  (psurfref - ahref * munotref));
87  }
88 
89  /*
90  *@history 2008-11-05 Jeannie Walldren - Modified references to
91  * NumericalMethods class and replaced Isis::PI with PI
92  * since this is in Isis namespace.
93  */
94  void TopoAtm::NormModelAlgorithm(double phase, double incidence, double emission,
95  double demincidence, double dememission, double dn,
96  double &albedo, double &mult, double &base) {
97  double eps = 0.1;
98  static double psurf;
99  static double pprime;
100  static double ahInterp;
101  static double munot;
102  double pstd;
103  double trans;
104  double trans0;
105  double transs;
106  double sbar;
107  double rhotlt;
108  double dpo;
109  double q;
110  double slope;
111  double pprimeeff;
112  double ptilt;
113  double dpm;
114  double pflat;
115  double rhoflat;
116 
117  static double old_phase = -9999;
118  static double old_incidence = -9999;
119  static double old_emission = -9999;
120  static double old_demincidence = -9999;
121  static double old_dememission = -9999;
122 
123  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
124  old_demincidence != demincidence || old_dememission != dememission) {
125 
126  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
127  pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission);
128  ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate);
129 
130  munot = cos(incidence * (PI / 180.0));
131 
132  old_phase = phase;
133  old_incidence = incidence;
134  old_emission = emission;
135  old_demincidence = demincidence;
136  old_dememission = dememission;
137  }
138 
139  GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &sbar,
140  &transs);
141  pflat = pstd + p_normRhobar * (trans * ahInterp * munot /
142  (1.0 - p_normRhobar * GetAtmosModel()->AtmosAb() * sbar) + trans0 * (psurf -
143  ahInterp * munot));
144  ptilt = pflat + p_normRhobar * pprime * trans0 * eps;
145  dpo = ptilt - pstd;
146  dpm = (psurf - ahInterp * munot) * trans0;
147  q = ahInterp * munot * trans + GetAtmosModel()->AtmosAb() * sbar * dpo + dpm;
148  rhotlt = 2.0 * dpo / (q + sqrt(pow(q, 2.0) - 4.0 * GetAtmosModel()->AtmosAb() * sbar * dpo * dpm));
149  dpo = pflat - pstd;
150  q = ahInterp * munot * trans + GetAtmosModel()->AtmosAb() * sbar * dpo + dpm;
151  rhoflat = 2.0 * dpo / (q + sqrt(pow(q, 2.0) - 4.0 * GetAtmosModel()->AtmosAb() * sbar * dpo * dpm));
152  pprimeeff = (rhotlt - rhoflat) / (rhoflat * eps);
153  slope = (dn - 1.0) / pprimeeff;
154  albedo = p_normAout * slope + p_normBout;
155  }
156 
166  void TopoAtm::SetNormPharef(const double pharef) {
167  if(pharef < 0.0 || pharef >= 180.0) {
168  std::string msg = "Invalid value of normalization pharef [" + IString(pharef) + "]";
170  }
171 
172  p_normPharef = pharef;
173  }
174 
184  void TopoAtm::SetNormIncref(const double incref) {
185  if(incref < 0.0 || incref >= 90.0) {
186  std::string msg = "Invalid value of normalization incref [" + IString(incref) + "]";
188  }
189 
190  p_normIncref = incref;
191  }
192 
202  void TopoAtm::SetNormEmaref(const double emaref) {
203  if(emaref < 0.0 || emaref >= 90.0) {
204  std::string msg = "Invalid value of normalization emaref [" + IString(emaref) + "]";
206  }
207 
208  p_normEmaref = emaref;
209  }
210 
219  void TopoAtm::SetNormAlbedo(const double albedo) {
220  p_normAlbedo = albedo;
221  }
222 }
223 
224 extern "C" Isis::NormModel *TopoAtmPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) {
225  return new Isis::TopoAtm(pvl, pmodel, amodel);
226 }
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Topo.cpp:166
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: TopoAtm.cpp:219
double CalcSurfAlbedo(double pha, double inc, double ema)
Calculate the surface brightness using photometric angle information.
Definition: PhotoModel.cpp:171
void SetNormPharef(const double pharef)
Set the normalization function parameter.
Definition: TopoAtm.cpp:166
const double PI
The mathematical constant PI.
Definition: Constants.h:56
virtual void SetStandardConditions(bool standard)
Used to calculate atmosphere at standard conditions.
Definition: AtmosModel.cpp:492
void CalcAtmEffect(double pha, double inc, double ema, double *pstd, double *trans, double *trans0, double *sbar, double *transs)
Calculate the atmospheric scattering effect using photometric angle information.
Definition: AtmosModel.cpp:469
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: TopoAtm.cpp:202
Search child objects.
Definition: PvlObject.h:170
NumericalApproximation AtmosAhSpline()
If GenerateAhTable() has been called this returns a clamped cubic spline of the data set (p_atmosIncT...
Definition: AtmosModel.h:199
double PhtTopder(double phase, double incidence, double emission)
Obtain topographic derivative of an arbitrary photometric function.
Definition: PhotoModel.cpp:58
Isotropic atmos scattering model.
Definition: AtmosModel.h:76
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:134
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Topo.cpp:148
Container for cube-like labels.
Definition: Pvl.h:135
void SetNormPharef(const double pharef)
Set the normalization function parameter.
Definition: Topo.cpp:110
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Topo.cpp:129
As in the case without an atmosphere, processing proceeds in three steps, a pass 1 PHOTOM followed by...
Definition: TopoAtm.h:90
Isis exception class.
Definition: IException.h:107
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: TopoAtm.cpp:184
Adds specific functionality to C++ strings.
Definition: IString.h:181
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
double AtmosAb() const
Return atmospheric Ab value.
Definition: AtmosModel.h:155
void GenerateAhTable()
This method computes the values of the atmospheric Ah table and sets the properties of the atmospheri...
Definition: AtmosModel.cpp:531
Evaluate() attempts to extrapolate if a is outside of the domain. This is only valid for NumericalApp...
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:44