Isis 3 Programmer Reference
Topo.cpp
1 #include "Topo.h"
2 #include "SpecialPixel.h"
3 #include "IException.h"
4 
5 using std::min;
6 using std::max;
7 
8 namespace Isis {
9  Topo::Topo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
10  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
11 
12  SetNormPharef(0.0);
13  SetNormIncref(0.0);
14  SetNormEmaref(0.0);
15  SetNormThresh(30.0);
16  SetNormAlbedo(1.0);
17 
18  if(algorithm.hasKeyword("Incref")) {
19  SetNormIncref(algorithm["Incref"]);
20  }
21 
22  if(algorithm.hasKeyword("Pharef")) {
23  SetNormPharef(algorithm["Pharef"]);
24  } else {
25  p_normPharef = p_normIncref;
26  }
27 
28  if(algorithm.hasKeyword("Emaref")) {
29  SetNormEmaref(algorithm["Emaref"]);
30  }
31 
32  if(algorithm.hasKeyword("Thresh")) {
33  SetNormThresh(algorithm["Thresh"]);
34  }
35 
36  if(algorithm.hasKeyword("Albedo")) {
37  SetNormAlbedo(algorithm["Albedo"]);
38  }
39  }
40 
41  void Topo::NormModelAlgorithm(double phase, double incidence, double emission,
42  double demincidence, double dememission, double dn,
43  double &albedo, double &mult, double &base) {
44  static double rhobar;
45  static double pprimeref;
46  static double psurfref;
47  static double psurf;
48  static double psurf0;
49  static double pprime;
50 
51  static double old_phase = -9999;
52  static double old_incidence = -9999;
53  static double old_emission = -9999;
54  static double old_demincidence = -9999;
55  static double old_dememission = -9999;
56 
57  if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
58  old_demincidence != demincidence || old_dememission != dememission) {
59 
60  GetPhotoModel()->SetStandardConditions(true);
61  psurf0 = GetPhotoModel()->CalcSurfAlbedo(0.0, 0.0, 0.0);
62 
63  if(psurf0 == 0.0) {
64  std::string msg = "Divide by zero error";
65  throw IException(IException::Unknown, msg, _FILEINFO_);
66  }
67  else {
68  rhobar = p_normAlbedo / psurf0;
69  }
70 
71  psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
72  pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
73  GetPhotoModel()->SetStandardConditions(false);
74 
75  // code for scaling each pixel
76  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
77  pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission);
78 
79  old_phase = phase;
80  old_incidence = incidence;
81  old_emission = emission;
82  old_demincidence = demincidence;
83  old_dememission = dememission;
84  }
85 
86  if(psurf * pprimeref > pprime * p_normThresh) {
87  albedo = NULL8;
88  }
89  else {
90  if(pprime == 0.0) {
91  std::string msg = "Divide by zero error";
92  throw IException(IException::Unknown, msg, _FILEINFO_);
93  }
94  else {
95  albedo = dn * rhobar * (psurf * pprimeref) / pprime +
96  rhobar * psurfref - rhobar * (psurf * pprimeref) / pprime;
97  }
98  }
99  }
100 
110  void Topo::SetNormPharef(const double pharef) {
111  if(pharef < 0.0 || pharef >= 180.0) {
112  std::string msg = "Invalid value of normalization pharef [" +
113  IString(pharef) + "]";
115  }
116 
117  p_normPharef = pharef;
118  }
119 
129  void Topo::SetNormIncref(const double incref) {
130  if(incref < 0.0 || incref >= 90.0) {
131  std::string msg = "Invalid value of normalization incref [" +
132  IString(incref) + "]";
134  }
135 
136  p_normIncref = incref;
137  }
138 
148  void Topo::SetNormEmaref(const double emaref) {
149  if(emaref < 0.0 || emaref >= 90.0) {
150  std::string msg = "Invalid value of normalization emaref [" +
151  IString(emaref) + "]";
153  }
154 
155  p_normEmaref = emaref;
156  }
157 
166  void Topo::SetNormAlbedo(const double albedo) {
167  p_normAlbedo = albedo;
168  }
169 
175  void Topo::SetNormThresh(const double thresh) {
176  p_normThresh = thresh;
177  }
178 }
179 
180 extern "C" Isis::NormModel *TopoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
181  return new Isis::Topo(pvl, pmodel);
182 }
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Topo.cpp:166
double CalcSurfAlbedo(double pha, double inc, double ema)
Calculate the surface brightness using photometric angle information.
Definition: PhotoModel.cpp:171
Search child objects.
Definition: PvlObject.h:170
double PhtTopder(double phase, double incidence, double emission)
Obtain topographic derivative of an arbitrary photometric function.
Definition: PhotoModel.cpp:58
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
void SetNormThresh(const double thresh)
Set the normalization function parameter.
Definition: Topo.cpp:175
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
Topographic derivative of an arbitrary photometric function.
Definition: Topo.h:47
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
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
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:44