Isis 3 Programmer Reference
Albedo.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include "Albedo.h"
9#include "SpecialPixel.h"
10#include "IException.h"
11#include "IString.h"
12#include "NormModel.h"
13
14namespace Isis {
21 Albedo::Albedo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
22 PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
23
24 SetNormPharef(0.0);
25 SetNormIncref(0.0);
26 SetNormEmaref(0.0);
27 SetNormIncmat(0.0);
28 SetNormThresh(30.0);
29 SetNormAlbedo(1.0);
30
31 // Get value from user
32 if(algorithm.hasKeyword("Incref")) {
33 SetNormIncref(algorithm["Incref"]);
34 }
35
36 if(algorithm.hasKeyword("Pharef")) {
37 SetNormPharef(algorithm["Pharef"]);
38 } else {
40 }
41
42 if(algorithm.hasKeyword("Emaref")) {
43 SetNormEmaref(algorithm["Emaref"]);
44 }
45
46 if(algorithm.hasKeyword("Incmat")) {
47 SetNormIncmat(algorithm["Incmat"]);
48 }
49
50 if(algorithm.hasKeyword("Thresh")) {
51 SetNormThresh(algorithm["Thresh"]);
52 }
53
54 if(algorithm.hasKeyword("Albedo")) {
55 SetNormAlbedo(algorithm["Albedo"]);
56 }
57
58 // Calculate normalization at standard conditions.
59 GetPhotoModel()->SetStandardConditions(true);
61 GetPhotoModel()->SetStandardConditions(false);
62 }
63
64
78 void Albedo::NormModelAlgorithm(double phase, double incidence,
79 double emission, double demincidence, double dememission,
80 double dn, double &albedo, double &mult, double &base) {
81 double psurf;
82 double result;
83
84 // code for scaling each pixel
85 psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
86
87 // thresh is a parameter limiting how much we amplify the dns
88 if(p_normPsurfref > psurf * p_normThresh) {
89 result = NULL8;
90 albedo = NULL8;
91 mult = 0.0;
92 base = 0.0;
93 }
94 else {
95 if(psurf == 0.0) {
96 QString msg = "Albedo math divide by zero error";
97 throw IException(IException::Unknown, msg, _FILEINFO_);
98 }
99 else {
100 result = dn * p_normPsurfref / psurf;
101 albedo = result;
102 mult = p_normPsurfref / psurf;
103 base = 0.0;
104 }
105 }
106 }
107
108
118 void Albedo::SetNormPharef(const double pharef) {
119 if(pharef < 0.0 || pharef >= 180.0) {
120 QString msg = "Invalid value of normalization pharef [" +
121 toString(pharef) + "]";
122 throw IException(IException::User, msg, _FILEINFO_);
123 }
124 p_normPharef = pharef;
125 }
126
136 void Albedo::SetNormIncref(const double incref) {
137 if(incref < 0.0 || incref >= 90.0) {
138 QString msg = "Invalid value of normalization incref [" +
139 toString(incref) + "]";
140 throw IException(IException::User, msg, _FILEINFO_);
141 }
142 p_normIncref = incref;
143 }
144
154 void Albedo::SetNormEmaref(const double emaref) {
155 if(emaref < 0.0 || emaref >= 90.0) {
156 QString msg = "Invalid value of normalization emaref [" +
157 toString(emaref) + "]";
158 throw IException(IException::User, msg, _FILEINFO_);
159 }
160 p_normEmaref = emaref;
161 }
162
169 void Albedo::SetNormIncmat(const double incmat) {
170 if(incmat < 0.0 || incmat >= 90.0) {
171 QString msg = "Invalid value of normalization incmat [" +
172 toString(incmat) + "]";
173 throw IException(IException::User, msg, _FILEINFO_);
174 }
175 p_normIncmat = incmat;
176 }
177
186 void Albedo::SetNormAlbedo(const double albedo) {
187 p_normAlbedo = albedo;
188 }
189
204 void Albedo::SetNormThresh(const double thresh) {
205 p_normThresh = thresh;
206 }
207}
208
209extern "C" Isis::NormModel *AlbedoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
210 return new Isis::Albedo(pvl, pmodel);
211}
Albedo normalization.
Definition Albedo.h:43
double p_normPsurfref
???
Definition Albedo.h:75
double p_normPharef
The reference phase angle.
Definition Albedo.h:76
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition Albedo.cpp:136
Albedo(Pvl &pvl, PhotoModel &pmodel)
Constructs an Albedo object.
Definition Albedo.cpp:21
double p_normAlbedo
The albedo.
Definition Albedo.h:81
void SetNormThresh(const double thresh)
Set the normalization function parameter.
Definition Albedo.cpp:204
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition Albedo.cpp:118
double p_normEmaref
The reference emission angle.
Definition Albedo.h:78
void SetNormIncmat(const double incmat)
Set the normalization function parameter.
Definition Albedo.cpp:169
virtual void NormModelAlgorithm(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Performs the normalization.
Definition Albedo.h:60
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition Albedo.cpp:154
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition Albedo.cpp:186
double p_normThresh
Used to amplify variations in the input image.
Definition Albedo.h:79
double p_normIncmat
Incmat.
Definition Albedo.h:80
double p_normIncref
The reference incidence angle.
Definition Albedo.h:77
Isis exception class.
Definition IException.h:91
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
double CalcSurfAlbedo(double pha, double inc, double ema)
Calculate the surface brightness using photometric angle information.
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211