File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Topo.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "Topo.h"
8 #include "SpecialPixel.h"
9 #include "IException.h"
10 
11 using std::min;
12 using std::max;
13 
14 namespace Isis {
15  Topo::Topo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
16  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
17 
18  SetNormPharef(0.0);
19  SetNormIncref(0.0);
20  SetNormEmaref(0.0);
21  SetNormThresh(30.0);
22  SetNormAlbedo(1.0);
23 
24  if(algorithm.hasKeyword("Incref")) {
25  SetNormIncref(algorithm["Incref"]);
26  }
27 
28  if(algorithm.hasKeyword("Pharef")) {
29  SetNormPharef(algorithm["Pharef"]);
30  } else {
31  p_normPharef = p_normIncref;
32  }
33 
34  if(algorithm.hasKeyword("Emaref")) {
35  SetNormEmaref(algorithm["Emaref"]);
36  }
37 
38  if(algorithm.hasKeyword("Thresh")) {
39  SetNormThresh(algorithm["Thresh"]);
40  }
41 
42  if(algorithm.hasKeyword("Albedo")) {
43  SetNormAlbedo(algorithm["Albedo"]);
44  }
45  }
46 
47  void Topo::NormModelAlgorithm(double phase, double incidence, double emission,
48  double demincidence, double dememission, double dn,
49  double &albedo, double &mult, double &base) {
50  static double rhobar;
51  static double pprimeref;
52  static double psurfref;
53  static double psurf;
54  static double psurf0;
55  static double pprime;
56 
57  static double old_phase = -9999;
58  static double old_incidence = -9999;
59  static double old_emission = -9999;
60  static double old_demincidence = -9999;
61  static double old_dememission = -9999;
62 
63  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
64  old_demincidence != demincidence || old_dememission != dememission) {
65 
66  GetPhotoModel()->SetStandardConditions(true);
67  psurf0 = GetPhotoModel()->CalcSurfAlbedo(0.0, 0.0, 0.0);
68 
69  if(psurf0 == 0.0) {
70  std::string msg = "Divide by zero error";
71  throw IException(IException::Unknown, msg, _FILEINFO_);
72  }
73  else {
74  rhobar = p_normAlbedo / psurf0;
75  }
76 
77  psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
78  pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
79  GetPhotoModel()->SetStandardConditions(false);
80 
81  // code for scaling each pixel
82  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
83  pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission);
84 
85  old_phase = phase;
86  old_incidence = incidence;
87  old_emission = emission;
88  old_demincidence = demincidence;
89  old_dememission = dememission;
90  }
91 
92  if(psurf * pprimeref > pprime * p_normThresh) {
93  albedo = NULL8;
94  }
95  else {
96  if(pprime == 0.0) {
97  std::string msg = "Divide by zero error";
98  throw IException(IException::Unknown, msg, _FILEINFO_);
99  }
100  else {
101  albedo = dn * rhobar * (psurf * pprimeref) / pprime +
102  rhobar * psurfref - rhobar * (psurf * pprimeref) / pprime;
103  }
104  }
105  }
106 
116  void Topo::SetNormPharef(const double pharef) {
117  if(pharef < 0.0 || pharef >= 180.0) {
118  std::string msg = "Invalid value of normalization pharef [" +
119  IString(pharef) + "]";
120  throw IException(IException::User, msg, _FILEINFO_);
121  }
122 
123  p_normPharef = pharef;
124  }
125 
135  void Topo::SetNormIncref(const double incref) {
136  if(incref < 0.0 || incref >= 90.0) {
137  std::string msg = "Invalid value of normalization incref [" +
138  IString(incref) + "]";
139  throw IException(IException::User, msg, _FILEINFO_);
140  }
141 
142  p_normIncref = incref;
143  }
144 
154  void Topo::SetNormEmaref(const double emaref) {
155  if(emaref < 0.0 || emaref >= 90.0) {
156  std::string msg = "Invalid value of normalization emaref [" +
157  IString(emaref) + "]";
158  throw IException(IException::User, msg, _FILEINFO_);
159  }
160 
161  p_normEmaref = emaref;
162  }
163 
172  void Topo::SetNormAlbedo(const double albedo) {
173  p_normAlbedo = albedo;
174  }
175 
181  void Topo::SetNormThresh(const double thresh) {
182  p_normThresh = thresh;
183  }
184 }
185 
186 extern "C" Isis::NormModel *TopoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
187  return new Isis::Topo(pvl, pmodel);
188 }
Isis::PhotoModel
Definition: PhotoModel.h:41
Isis::Topo::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Topo.cpp:135
Isis::Topo::SetNormPharef
void SetNormPharef(const double pharef)
Set the normalization function parameter.
Definition: Topo.cpp:116
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::Topo::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Topo.cpp:154
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::Topo::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Topo.cpp:172
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::NormModel
Definition: NormModel.h:36
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Topo::SetNormThresh
void SetNormThresh(const double thresh)
Set the normalization function parameter.
Definition: Topo.cpp:181
Isis::PhotoModel::SetStandardConditions
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:50
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::Topo
Topographic derivative of an arbitrary photometric function.
Definition: Topo.h:31
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:24