Isis 3 Programmer Reference
ShadeAtm.cpp
1 #include <cmath>
2 #include "ShadeAtm.h"
3 #include "AtmosModel.h"
4 #include "NumericalApproximation.h"
5 #include "IException.h"
6 
7 namespace Isis {
8  ShadeAtm::ShadeAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : NormModel(pvl, pmodel, amodel) {
9  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
10 
11  SetNormPharef(0.0);
12  SetNormIncref(0.0);
13  SetNormEmaref(0.0);
14  SetNormAlbedo(1.0);
15 
16  if(algorithm.hasKeyword("Incref")) {
17  SetNormIncref(algorithm["Incref"]);
18  }
19 
20  if(algorithm.hasKeyword("Pharef")) {
21  SetNormPharef(algorithm["Pharef"]);
22  } else {
23  p_normPharef = p_normIncref;
24  }
25 
26  if(algorithm.hasKeyword("Emaref")) {
27  SetNormEmaref(algorithm["Emaref"]);
28  }
29 
30  if(algorithm.hasKeyword("Albedo")) {
31  SetNormAlbedo(algorithm["Albedo"]);
32  }
33  }
34 
35  /*
36  * @param phase Phase angle
37  * @param incidence Incidence angle
38  * @param emission Emission angle
39  * @param dn
40  * @param albedo
41  * @param mult
42  * @param base
43  *
44  * @history 2008-11-05 Jeannie Walldren - Modified references
45  * to NumericalMethods class and replaced Isis::PI
46  * with PI since this is in Isis namespace.
47  *
48  */
49  void ShadeAtm::NormModelAlgorithm(double phase, double incidence, double emission,
50  double demincidence, double dememission, double dn,
51  double &albedo, double &mult, double &base) {
52  double rho;
53  double psurfref;
54  static double psurf;
55  static double ahInterp;
56  static double munot;
57  double pstd;
58  double trans;
59  double trans0;
60  double transs;
61  double sbar;
62 
63  static double old_phase = -9999;
64  static double old_incidence = -9999;
65  static double old_emission = -9999;
66  static double old_demincidence = -9999;
67  static double old_dememission = -9999;
68 
69  // Calculate normalization at standard conditions
70  GetPhotoModel()->SetStandardConditions(true);
71  psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
72  GetPhotoModel()->SetStandardConditions(false);
73 
74  // Get reference hemispheric albedo (Hapke opposition effect doesn't influence it much)
75  GetAtmosModel()->GenerateAhTable();
76 
77  if(psurfref == 0.0) {
78  std::string msg = "Divide by zero error";
79  throw IException(IException::Unknown, msg, _FILEINFO_);
80  }
81 
82  rho = p_normAlbedo / psurfref;
83 
84  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
85  old_demincidence != demincidence || old_dememission != dememission) {
86 
87  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
88 
89  ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate);
90 
91  munot = cos(incidence * (PI / 180.0));
92 
93  old_phase = phase;
94  old_incidence = incidence;
95  old_emission = emission;
96  old_demincidence = demincidence;
97  old_dememission = dememission;
98  }
99 
100  GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &sbar,
101  &transs);
102 
103  albedo = pstd + rho * (ahInterp * munot * trans /
104  (1.0 - rho * GetAtmosModel()->AtmosAb() * sbar) + (psurf - ahInterp * munot) * trans0);
105  }
106 
116  void ShadeAtm::SetNormPharef(const double pharef) {
117  if(pharef < 0.0 || pharef >= 180.0) {
118  std::string msg = "Invalid value of normalization pharef [" +
119  IString(pharef) + "]";
121  }
122 
123  p_normPharef = pharef;
124  }
125 
135  void ShadeAtm::SetNormIncref(const double incref) {
136  if(incref < 0.0 || incref >= 90.0) {
137  std::string msg = "Invalid value of normalization incref [" +
138  IString(incref) + "]";
140  }
141 
142  p_normIncref = incref;
143  }
144 
154  void ShadeAtm::SetNormEmaref(const double emaref) {
155  if(emaref < 0.0 || emaref >= 90.0) {
156  std::string msg = "Invalid value of normalization emaref [" +
157  IString(emaref) + "]";
159  }
160 
161  p_normEmaref = emaref;
162  }
163 
172  void ShadeAtm::SetNormAlbedo(const double albedo) {
173  p_normAlbedo = albedo;
174  }
175 }
176 
177 extern "C" Isis::NormModel *ShadeAtmPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) {
178  return new Isis::ShadeAtm(pvl, pmodel, amodel);
179 }
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition: Shade.cpp:64
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Shade.cpp:118
double CalcSurfAlbedo(double pha, double inc, double ema)
Calculate the surface brightness using photometric angle information.
Definition: PhotoModel.cpp:171
const double PI
The mathematical constant PI.
Definition: Constants.h:56
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 SetNormPharef(const double pharef)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:116
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Shade.cpp:82
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
Isotropic atmos scattering model.
Definition: AtmosModel.h:76
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:135
#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 SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:172
Container for cube-like labels.
Definition: Pvl.h:135
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Shade.cpp:100
Isis exception class.
Definition: IException.h:107
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
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:154
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