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
11using std::min;
12using std::max;
13
14namespace 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
186extern "C" Isis::NormModel *TopoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
187 return new Isis::Topo(pvl, pmodel);
188}
Isis exception class.
Definition IException.h:91
Adds specific functionality to C++ strings.
Definition IString.h:165
Container for cube-like labels.
Definition Pvl.h:119
Topographic derivative of an arbitrary photometric function.
Definition Topo.h:31
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16