File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
ShadeAtm.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <cmath>
8 #include "ShadeAtm.h"
9 #include "AtmosModel.h"
10 #include "NumericalApproximation.h"
11 #include "IException.h"
12 
13 namespace Isis {
14  ShadeAtm::ShadeAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : NormModel(pvl, pmodel, amodel) {
15  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
16 
17  SetNormPharef(0.0);
18  SetNormIncref(0.0);
19  SetNormEmaref(0.0);
20  SetNormAlbedo(1.0);
21 
22  if(algorithm.hasKeyword("Incref")) {
23  SetNormIncref(algorithm["Incref"]);
24  }
25 
26  if(algorithm.hasKeyword("Pharef")) {
27  SetNormPharef(algorithm["Pharef"]);
28  } else {
29  p_normPharef = p_normIncref;
30  }
31 
32  if(algorithm.hasKeyword("Emaref")) {
33  SetNormEmaref(algorithm["Emaref"]);
34  }
35 
36  if(algorithm.hasKeyword("Albedo")) {
37  SetNormAlbedo(algorithm["Albedo"]);
38  }
39  }
40 
41  /*
42  * @param phase Phase angle
43  * @param incidence Incidence angle
44  * @param emission Emission angle
45  * @param dn
46  * @param albedo
47  * @param mult
48  * @param base
49  *
50  * @history 2008-11-05 Jeannie Walldren - Modified references
51  * to NumericalMethods class and replaced Isis::PI
52  * with PI since this is in Isis namespace.
53  *
54  */
55  void ShadeAtm::NormModelAlgorithm(double phase, double incidence, double emission,
56  double demincidence, double dememission, double dn,
57  double &albedo, double &mult, double &base) {
58  double rho;
59  double psurfref;
60  static double psurf;
61  static double ahInterp;
62  static double munot;
63  double pstd;
64  double trans;
65  double trans0;
66  double transs;
67  double sbar;
68 
69  static double old_phase = -9999;
70  static double old_incidence = -9999;
71  static double old_emission = -9999;
72  static double old_demincidence = -9999;
73  static double old_dememission = -9999;
74 
75  // Calculate normalization at standard conditions
76  GetPhotoModel()->SetStandardConditions(true);
77  psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
78  GetPhotoModel()->SetStandardConditions(false);
79 
80  // Get reference hemispheric albedo (Hapke opposition effect doesn't influence it much)
81  GetAtmosModel()->GenerateAhTable();
82 
83  if(psurfref == 0.0) {
84  std::string msg = "Divide by zero error";
85  throw IException(IException::Unknown, msg, _FILEINFO_);
86  }
87 
88  rho = p_normAlbedo / psurfref;
89 
90  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
91  old_demincidence != demincidence || old_dememission != dememission) {
92 
93  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
94 
95  ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate);
96 
97  munot = cos(incidence * (PI / 180.0));
98 
99  old_phase = phase;
100  old_incidence = incidence;
101  old_emission = emission;
102  old_demincidence = demincidence;
103  old_dememission = dememission;
104  }
105 
106  GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &sbar,
107  &transs);
108 
109  albedo = pstd + rho * (ahInterp * munot * trans /
110  (1.0 - rho * GetAtmosModel()->AtmosAb() * sbar) + (psurf - ahInterp * munot) * trans0);
111  }
112 
122  void ShadeAtm::SetNormPharef(const double pharef) {
123  if(pharef < 0.0 || pharef >= 180.0) {
124  std::string msg = "Invalid value of normalization pharef [" +
125  IString(pharef) + "]";
126  throw IException(IException::User, msg, _FILEINFO_);
127  }
128 
129  p_normPharef = pharef;
130  }
131 
141  void ShadeAtm::SetNormIncref(const double incref) {
142  if(incref < 0.0 || incref >= 90.0) {
143  std::string msg = "Invalid value of normalization incref [" +
144  IString(incref) + "]";
145  throw IException(IException::User, msg, _FILEINFO_);
146  }
147 
148  p_normIncref = incref;
149  }
150 
160  void ShadeAtm::SetNormEmaref(const double emaref) {
161  if(emaref < 0.0 || emaref >= 90.0) {
162  std::string msg = "Invalid value of normalization emaref [" +
163  IString(emaref) + "]";
164  throw IException(IException::User, msg, _FILEINFO_);
165  }
166 
167  p_normEmaref = emaref;
168  }
169 
178  void ShadeAtm::SetNormAlbedo(const double albedo) {
179  p_normAlbedo = albedo;
180  }
181 }
182 
183 extern "C" Isis::NormModel *ShadeAtmPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) {
184  return new Isis::ShadeAtm(pvl, pmodel, amodel);
185 }
Isis::ShadeAtm::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:141
Isis::NumericalApproximation::Extrapolate
@ Extrapolate
Evaluate() attempts to extrapolate if a is outside of the domain. This is only valid for NumericalApp...
Definition: NumericalApproximation.h:814
Isis::PhotoModel
Definition: PhotoModel.h:41
Isis::PI
const double PI
The mathematical constant PI.
Definition: Constants.h:40
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::AtmosModel
Isotropic atmos scattering model.
Definition: AtmosModel.h:60
Isis::PhotoModel::CalcSurfAlbedo
double CalcSurfAlbedo(double pha, double inc, double ema)
Calculate the surface brightness using photometric angle information.
Definition: PhotoModel.cpp:177
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::ShadeAtm::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:160
Isis::Shade::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Shade.cpp:124
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Shade::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Shade.cpp:88
Isis::NormModel
Definition: NormModel.h:36
Isis::AtmosModel::GenerateAhTable
void GenerateAhTable()
This method computes the values of the atmospheric Ah table and sets the properties of the atmospheri...
Definition: AtmosModel.cpp:537
Isis::ShadeAtm::SetNormPharef
void SetNormPharef(const double pharef)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:122
Isis::AtmosModel::AtmosAhSpline
NumericalApproximation AtmosAhSpline()
If GenerateAhTable() has been called this returns a clamped cubic spline of the data set (p_atmosIncT...
Definition: AtmosModel.h:183
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PhotoModel::SetStandardConditions
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:50
Isis::AtmosModel::AtmosAb
double AtmosAb() const
Return atmospheric Ab value.
Definition: AtmosModel.h:139
Isis::Shade::SetNormPharef
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition: Shade.cpp:70
Isis::ShadeAtm
Definition: ShadeAtm.h:35
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::AtmosModel::CalcAtmEffect
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:475
Isis::ShadeAtm::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: ShadeAtm.cpp:178
Isis::Shade::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Shade.cpp:106
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:17:16