Isis 3 Programmer Reference
Shade.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "Shade.h"
8 #include "IException.h"
9 
10 
11 namespace 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 
129 extern "C" Isis::NormModel *ShadePlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
130  return new Isis::Shade(pvl, pmodel);
131 }
Isis::Shade
Definition: Shade.h:29
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::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::Shade::SetNormAlbedo
void SetNormAlbedo(const double albedo)
Set the normalization function parameter.
Definition: Shade.cpp:124
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Shade::SetNormIncref
void SetNormIncref(const double incref)
Set the normalization function parameter.
Definition: Shade.cpp:88
Isis::NormModel
Definition: NormModel.h:36
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PhotoModel::SetStandardConditions
virtual void SetStandardConditions(bool standard)
Sets whether standard conditions will be used.
Definition: PhotoModel.cpp:50
Isis::Shade::SetNormPharef
void SetNormPharef(const double pharef)
Set parameters needed for albedo normalization.
Definition: Shade.cpp:70
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::Shade::SetNormEmaref
void SetNormEmaref(const double emaref)
Set the normalization function parameter.
Definition: Shade.cpp:106
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