USGS

Isis 3.0 Object Programmers' Reference

Home

Albedo.cpp
1 #include "Albedo.h"
2 #include "SpecialPixel.h"
3 #include "IException.h"
4 #include "IString.h"
5 
6 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
7 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
8 
9 namespace Isis {
10  Albedo::Albedo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
11  PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
12 
13  SetNormPharef(0.0);
14  SetNormIncref(0.0);
15  SetNormEmaref(0.0);
16  SetNormIncmat(0.0);
17  SetNormThresh(30.0);
18  SetNormAlbedo(1.0);
19 
20  // Get value from user
21  if(algorithm.hasKeyword("Incref")) {
22  SetNormIncref(algorithm["Incref"]);
23  }
24 
25  if(algorithm.hasKeyword("Pharef")) {
26  SetNormPharef(algorithm["Pharef"]);
27  } else {
28  p_normPharef = p_normIncref;
29  }
30 
31  if(algorithm.hasKeyword("Emaref")) {
32  SetNormEmaref(algorithm["Emaref"]);
33  }
34 
35  if(algorithm.hasKeyword("Incmat")) {
36  SetNormIncmat(algorithm["Incmat"]);
37  }
38 
39  if(algorithm.hasKeyword("Thresh")) {
40  SetNormThresh(algorithm["Thresh"]);
41  }
42 
43  if(algorithm.hasKeyword("Albedo")) {
44  SetNormAlbedo(algorithm["Albedo"]);
45  }
46 
47  // Calculate normalization at standard conditions.
48  GetPhotoModel()->SetStandardConditions(true);
49  p_normPsurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
50  GetPhotoModel()->SetStandardConditions(false);
51  }
52 
53  void Albedo::NormModelAlgorithm(double phase, double incidence,
54  double emission, double demincidence, double dememission,
55  double dn, double &albedo, double &mult, double &base) {
56  double psurf;
57  double result;
58 
59  // code for scaling each pixel
60  psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
61 
62  // thresh is a parameter limiting how much we amplify the dns
63  if(p_normPsurfref > psurf * p_normThresh) {
64  result = NULL8;
65  albedo = NULL8;
66  mult = 0.0;
67  base = 0.0;
68  }
69  else {
70  if(psurf == 0.0) {
71  QString msg = "Albedo math divide by zero error";
72  throw IException(IException::Unknown, msg, _FILEINFO_);
73  }
74  else {
75  result = dn * p_normPsurfref / psurf;
76  albedo = result;
77  mult = p_normPsurfref / psurf;
78  base = 0.0;
79  }
80  }
81  }
82 
92  void Albedo::SetNormPharef(const double pharef) {
93  if(pharef < 0.0 || pharef >= 180.0) {
94  QString msg = "Invalid value of normalization pharef [" +
95  toString(pharef) + "]";
97  }
98  p_normPharef = pharef;
99  }
100 
110  void Albedo::SetNormIncref(const double incref) {
111  if(incref < 0.0 || incref >= 90.0) {
112  QString msg = "Invalid value of normalization incref [" +
113  toString(incref) + "]";
115  }
116  p_normIncref = incref;
117  }
118 
128  void Albedo::SetNormEmaref(const double emaref) {
129  if(emaref < 0.0 || emaref >= 90.0) {
130  QString msg = "Invalid value of normalization emaref [" +
131  toString(emaref) + "]";
133  }
134  p_normEmaref = emaref;
135  }
136 
143  void Albedo::SetNormIncmat(const double incmat) {
144  if(incmat < 0.0 || incmat >= 90.0) {
145  QString msg = "Invalid value of normalization incmat [" +
146  toString(incmat) + "]";
148  }
149  p_normIncmat = incmat;
150  }
151 
160  void Albedo::SetNormAlbedo(const double albedo) {
161  p_normAlbedo = albedo;
162  }
163 
178  void Albedo::SetNormThresh(const double thresh) {
179  p_normThresh = thresh;
180  }
181 }
182 
183 extern "C" Isis::NormModel *AlbedoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) {
184  return new Isis::Albedo(pvl, pmodel);
185 }