File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Mixed.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <cmath>
8 #include "Mixed.h"
9 #include "SpecialPixel.h"
10 #include "IException.h"
11 
12 namespace Isis {
13  Mixed::Mixed(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
14  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
15 
16  // Set default value
17  SetNormPharef(0.0);
18  SetNormIncref(0.0);
19  SetNormEmaref(0.0);
20  SetNormPhamat(0.0);
21  SetNormIncmat(0.0);
22  SetNormEmamat(0.0);
23  SetNormThresh(30.0);
24  SetNormAlbedo(1.0);
25 
26  // Get value from user
27  if(algorithm.hasKeyword("Pharef")) {
28  SetNormPharef(algorithm["Pharef"]);
29  }
30 
31  if(algorithm.hasKeyword("Incref")) {
32  SetNormIncref(algorithm["Incref"]);
33  }
34 
35  if(algorithm.hasKeyword("Emaref")) {
36  SetNormEmaref(algorithm["Emaref"]);
37  }
38 
39  if(algorithm.hasKeyword("Incmat")) {
40  SetNormIncmat(algorithm["Incmat"]);
41  }
42 
43  if(algorithm.hasKeyword("Phamat")) {
44  SetNormPhamat(algorithm["Phamat"]);
45  } else {
46  p_normPhamat = p_normIncmat;
47  }
48 
49  if(algorithm.hasKeyword("Emamat")) {
50  SetNormEmamat(algorithm["Emamat"]);
51  }
52 
53  if(algorithm.hasKeyword("Thresh")) {
54  SetNormThresh(algorithm["Thresh"]);
55  }
56 
57  if(algorithm.hasKeyword("Albedo")) {
58  SetNormAlbedo(algorithm["Albedo"]);
59  }
60 
61  // First-time setup
62  // Calculate normalization at standard conditions
63  // Turn off Hapke opposition effect
64  GetPhotoModel()->SetStandardConditions(true);
65  p_psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
66  double pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
67 
68  if(p_psurfref == 0.0) {
69  std::string err = "Divide by zero error";
70  throw IException(IException::Unknown, err, _FILEINFO_);
71  }
72  else {
73  p_rhobar = p_normAlbedo / p_psurfref;
74  }
75 
76  // Calculate brightness and topo derivative at matchpoint incidence
77  p_psurfmatch = GetPhotoModel()->CalcSurfAlbedo(p_normPhamat, p_normIncmat, p_normEmamat);
78  p_pprimematch = GetPhotoModel()->PhtTopder(p_normPhamat, p_normIncmat, p_normEmamat);
79 
80  // Calculate numerator of the stretch coeff. a; if it is very
81  // large or small we haven't chosen a good reference state
82  double arg = pow(p_psurfref, 2.0) + pow(p_psurfmatch * pprimeref / std::max(1.0e-30, p_pprimematch), 2.0);
83  if((arg < 1.0e-10) || (arg > 1.0e10)) {
84  std::string err = "Bad reference state encountered";
85  throw IException(IException::Unknown, err, _FILEINFO_);
86  }
87 
88  p_anum = sqrt(arg);
89  GetPhotoModel()->SetStandardConditions(false);
90  }
91 
92  void Mixed::NormModelAlgorithm(double phase, double incidence, double emission,
93  double demincidence, double dememission, double dn,
94  double &albedo, double &mult, double &base) {
95  static double psurf;
96  static double pprime;
97  static double aden;
98 
99  static double old_phase = -9999;
100  static double old_incidence = -9999;
101  static double old_emission = -9999;
102  static double old_demincidence = -9999;
103  static double old_dememission = -9999;
104 
105  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
106  old_demincidence != demincidence || old_dememission != dememission) {
107 
108  // code for scaling each pixel
109  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
110  pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission);
111  double arg = pow(psurf, 2.0) + pow(p_psurfmatch * pprime / std::max(1.0e-30, p_pprimematch), 2.0);
112  aden = sqrt(std::max(1.0e-30, arg));
113 
114  old_phase = phase;
115  old_incidence = incidence;
116  old_emission = emission;
117  old_demincidence = demincidence;
118  old_dememission = dememission;
119  }
120 
121  // thresh is a parameter limiting how much we amplify the dns
122  // shouldn't actually get a large amplification in this mode because
123  // of the growing pprime term in the denominator.
124 
125  if(aden > p_anum * p_normThresh) {
126  albedo = NULL8;
127  }
128  else {
129  albedo = dn * p_anum / aden + p_rhobar * (p_psurfref - p_anum / aden * psurf);
130  }
131  }
132 
142  void Mixed::SetNormPharef(const double pharef) {
143  if(pharef < 0.0 || pharef >= 180.0) {
144  std::string msg = "Invalid value of normalization pharef [" +
145  IString(pharef) + "]";
146  throw IException(IException::User, msg, _FILEINFO_);
147  }
148 
149  p_normPharef = pharef;
150  }
151 
161  void Mixed::SetNormIncref(const double incref) {
162  if(incref < 0.0 || incref >= 90.0) {
163  std::string msg = "Invalid value of normalization incref [" +
164  IString(incref) + "]";
165  throw IException(IException::User, msg, _FILEINFO_);
166  }
167 
168  p_normIncref = incref;
169  }
170 
180  void Mixed::SetNormEmaref(const double emaref) {
181  if(emaref < 0.0 || emaref >= 90.0) {
182  std::string msg = "Invalid value of normalization emaref [" +
183  IString(emaref) + "]";
184  throw IException(IException::User, msg, _FILEINFO_);
185  }
186 
187  p_normEmaref = emaref;
188  }
189 
200  void Mixed::SetNormPhamat(const double phamat) {
201  if(phamat < 0.0 || phamat >= 180.0) {
202  std::string msg = "Invalid value of normalization phamat [" +
203  IString(phamat) + "]";
204  throw IException(IException::User, msg, _FILEINFO_);
205  }
206 
207  p_normPhamat = phamat;
208  }
209 
220  void Mixed::SetNormIncmat(const double incmat) {
221  if(incmat < 0.0 || incmat >= 90.0) {
222  std::string msg = "Invalid value of normalization incmat [" +
223  IString(incmat) + "]";
224  throw IException(IException::User, msg, _FILEINFO_);
225  }
226 
227  p_normIncmat = incmat;
228  }
229 
240  void Mixed::SetNormEmamat(const double emamat) {
241  if(emamat < 0.0 || emamat >= 90.0) {
242  std::string msg = "Invalid value of normalization emamat [" +
243  IString(emamat) + "]";
244  throw IException(IException::User, msg, _FILEINFO_);
245  }
246 
247  p_normEmamat = emamat;
248  }
249 
256  void Mixed::SetNormAlbedo(const double albedo) {
257  p_normAlbedo = albedo;
258  }
259 
274  void Mixed::SetNormThresh(const double thresh) {
275  p_normThresh = thresh;
276  }
277 }
278 
279 extern "C" Isis::NormModel *MixedPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
280  return new Isis::Mixed(pvl, pmodel);
281 }
Isis::PhotoModel
Definition: PhotoModel.h:41
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
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::PhotoModel::PhtTopder
double PhtTopder(double phase, double incidence, double emission)
Obtain topographic derivative of an arbitrary photometric function.
Definition: PhotoModel.cpp:64
Isis::Mixed::SetNormPhamat
void SetNormPhamat(const double phamat)
Set the normalization function parameter.
Definition: Mixed.cpp:200
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Mixed::SetNormThresh
void SetNormThresh(const double thresh)
Set the normalization function parameter.
Definition: Mixed.cpp:274
Isis::NormModel
Definition: NormModel.h:36
Isis::Mixed::SetNormIncmat
void SetNormIncmat(const double incmat)
Set the normalization function parameter.
Definition: Mixed.cpp:220
Isis::Mixed::SetNormPharef
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition: Mixed.cpp:142
Isis::Mixed::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Mixed.cpp:180
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Mixed::SetNormEmamat
void SetNormEmamat(const double emamat)
Set the normalization function parameter.
Definition: Mixed.cpp:240
Isis::Mixed::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Mixed.cpp:256
Isis::Mixed::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Mixed.cpp:161
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
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
Isis::Mixed
Mixed albedo/topo normalization without atmosphere.
Definition: Mixed.h:47

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:16:52