Isis 3 Programmer Reference
Shade.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Shade.h"
8#include "IException.h"
9
10
11namespace Isis {
12 Shade::Shade(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
13 PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
14
15 SetNormPharef(0.0);
16 SetNormIncref(0.0);
17 SetNormEmaref(0.0);
18 SetNormAlbedo(1.0);
19
20 if(algorithm.hasKeyword("Incref")) {
21 SetNormIncref(algorithm["Incref"]);
22 }
23
24 if(algorithm.hasKeyword("Pharef")) {
25 SetNormPharef(algorithm["Pharef"]);
26 }
27 else {
28 p_normPharef = p_normIncref;
29 }
30
31 if(algorithm.hasKeyword("Emaref")) {
32 SetNormEmaref(algorithm["Emaref"]);
33 }
34
35 if(algorithm.hasKeyword("Albedo")) {
36 SetNormAlbedo(algorithm["Albedo"]);
37 }
38 }
39
40 void Shade::NormModelAlgorithm(double phase, double incidence, double emission,
41 double demincidence, double dememission, double dn,
42 double &albedo, double &mult, double &base) {
43 double rho;
44 double psurfref;
45
46 // Calculate normalization at standard conditions
47 GetPhotoModel()->SetStandardConditions(true);
48 psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
49 GetPhotoModel()->SetStandardConditions(false);
50
51 if(psurfref == 0.0) {
52 std::string msg = "Divide by zero error";
53 throw IException(IException::Unknown, msg, _FILEINFO_);
54 }
55
56 rho = p_normAlbedo / psurfref;
57
58 albedo = rho * GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
59 }
60
70 void Shade::SetNormPharef(const double pharef) {
71 if(pharef < 0.0 || pharef >= 180.0) {
72 std::string msg = "Invalid value of normalization pharef [" + IString(pharef) + "]";
73 throw IException(IException::User, msg, _FILEINFO_);
74 }
75
76 p_normPharef = pharef;
77 }
78
88 void Shade::SetNormIncref(const double incref) {
89 if(incref < 0.0 || incref >= 90.0) {
90 std::string msg = "Invalid value of normalization incref [" + IString(incref) + "]";
91 throw IException(IException::User, msg, _FILEINFO_);
92 }
93
94 p_normIncref = incref;
95 }
96
106 void Shade::SetNormEmaref(const double emaref) {
107 if(emaref < 0.0 || emaref >= 90.0) {
108 std::string msg = "Invalid value of normalization emaref [" + IString(emaref) + "]";
109 throw IException(IException::User, msg, _FILEINFO_);
110 }
111
112 p_normEmaref = emaref;
113 }
114
124 void Shade::SetNormAlbedo(const double albedo) {
125 p_normAlbedo = albedo;
126 }
127}
128
129extern "C" Isis::NormModel *ShadePlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
130 return new Isis::Shade(pvl, pmodel);
131}
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
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16