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 
14 namespace 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 
209 extern "C" Isis::NormModel *AlbedoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
210  return new Isis::Albedo(pvl, pmodel);
211 }
Isis::Albedo
Albedo normalization.
Definition: Albedo.h:43
Isis::Albedo::p_normIncref
double p_normIncref
The reference incidence angle.
Definition: Albedo.h:77
Isis::PhotoModel
Definition: PhotoModel.h:41
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
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::Albedo::p_normThresh
double p_normThresh
Used to amplify variations in the input image.
Definition: Albedo.h:79
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::Albedo::SetNormPharef
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition: Albedo.cpp:118
Isis::Albedo::Albedo
Albedo(Pvl &pvl, PhotoModel &pmodel)
Constructs an Albedo object.
Definition: Albedo.cpp:21
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Albedo::NormModelAlgorithm
virtual void NormModelAlgorithm(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Performs the normalization.
Definition: Albedo.h:60
Isis::NormModel
Definition: NormModel.h:36
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Albedo::p_normAlbedo
double p_normAlbedo
The albedo.
Definition: Albedo.h:81
Isis::Albedo::p_normIncmat
double p_normIncmat
Incmat.
Definition: Albedo.h:80
Isis::Albedo::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Albedo.cpp:136
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Albedo::p_normEmaref
double p_normEmaref
The reference emission angle.
Definition: Albedo.h:78
Isis::PhotoModel::SetStandardConditions
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:50
Isis::Albedo::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Albedo.cpp:186
Isis::Albedo::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Albedo.cpp:154
Isis::Albedo::SetNormThresh
void SetNormThresh(const double thresh)
Set the normalization function parameter.
Definition: Albedo.cpp:204
Isis::Albedo::SetNormIncmat
void SetNormIncmat(const double incmat)
Set the normalization function parameter.
Definition: Albedo.cpp:169
Isis::Albedo::p_normPharef
double p_normPharef
The reference phase angle.
Definition: Albedo.h:76
Isis::Albedo::p_normPsurfref
double p_normPsurfref
???
Definition: Albedo.h:75
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