Isis 3 Programmer Reference
ShadeAtm.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include <cmath>
8#include "ShadeAtm.h"
9#include "AtmosModel.h"
10#include "NumericalApproximation.h"
11#include "IException.h"
12
13namespace Isis {
14 ShadeAtm::ShadeAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : NormModel(pvl, pmodel, amodel) {
15 PvlGroup &algorithm = pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse);
16
17 SetNormPharef(0.0);
18 SetNormIncref(0.0);
19 SetNormEmaref(0.0);
20 SetNormAlbedo(1.0);
21
22 if(algorithm.hasKeyword("Incref")) {
23 SetNormIncref(algorithm["Incref"]);
24 }
25
26 if(algorithm.hasKeyword("Pharef")) {
27 SetNormPharef(algorithm["Pharef"]);
28 } else {
29 p_normPharef = p_normIncref;
30 }
31
32 if(algorithm.hasKeyword("Emaref")) {
33 SetNormEmaref(algorithm["Emaref"]);
34 }
35
36 if(algorithm.hasKeyword("Albedo")) {
37 SetNormAlbedo(algorithm["Albedo"]);
38 }
39 }
40
41 /*
42 * @param phase Phase angle
43 * @param incidence Incidence angle
44 * @param emission Emission angle
45 * @param dn
46 * @param albedo
47 * @param mult
48 * @param base
49 *
50 * @history 2008-11-05 Jeannie Walldren - Modified references
51 * to NumericalMethods class and replaced Isis::PI
52 * with PI since this is in Isis namespace.
53 *
54 */
55 void ShadeAtm::NormModelAlgorithm(double phase, double incidence, double emission,
56 double demincidence, double dememission, double dn,
57 double &albedo, double &mult, double &base) {
58 double rho;
59 double psurfref;
60 static double psurf;
61 static double ahInterp;
62 static double munot;
63 double pstd;
64 double trans;
65 double trans0;
66 double transs;
67 double sbar;
68
69 static double old_phase = -9999;
70 static double old_incidence = -9999;
71 static double old_emission = -9999;
72 static double old_demincidence = -9999;
73 static double old_dememission = -9999;
74
75 // Calculate normalization at standard conditions
76 GetPhotoModel()->SetStandardConditions(true);
77 psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
78 GetPhotoModel()->SetStandardConditions(false);
79
80 // Get reference hemispheric albedo (Hapke opposition effect doesn't influence it much)
81 GetAtmosModel()->GenerateAhTable();
82
83 if(psurfref == 0.0) {
84 std::string msg = "Divide by zero error";
85 throw IException(IException::Unknown, msg, _FILEINFO_);
86 }
87
88 rho = p_normAlbedo / psurfref;
89
90 if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
91 old_demincidence != demincidence || old_dememission != dememission) {
92
93 psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
94
95 ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate);
96
97 munot = cos(incidence * (PI / 180.0));
98
99 old_phase = phase;
100 old_incidence = incidence;
101 old_emission = emission;
102 old_demincidence = demincidence;
103 old_dememission = dememission;
104 }
105
106 GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &sbar,
107 &transs);
108
109 albedo = pstd + rho * (ahInterp * munot * trans /
110 (1.0 - rho * GetAtmosModel()->AtmosAb() * sbar) + (psurf - ahInterp * munot) * trans0);
111 }
112
122 void ShadeAtm::SetNormPharef(const double pharef) {
123 if(pharef < 0.0 || pharef >= 180.0) {
124 std::string msg = "Invalid value of normalization pharef [" +
125 IString(pharef) + "]";
126 throw IException(IException::User, msg, _FILEINFO_);
127 }
128
129 p_normPharef = pharef;
130 }
131
141 void ShadeAtm::SetNormIncref(const double incref) {
142 if(incref < 0.0 || incref >= 90.0) {
143 std::string msg = "Invalid value of normalization incref [" +
144 IString(incref) + "]";
145 throw IException(IException::User, msg, _FILEINFO_);
146 }
147
148 p_normIncref = incref;
149 }
150
160 void ShadeAtm::SetNormEmaref(const double emaref) {
161 if(emaref < 0.0 || emaref >= 90.0) {
162 std::string msg = "Invalid value of normalization emaref [" +
163 IString(emaref) + "]";
164 throw IException(IException::User, msg, _FILEINFO_);
165 }
166
167 p_normEmaref = emaref;
168 }
169
178 void ShadeAtm::SetNormAlbedo(const double albedo) {
179 p_normAlbedo = albedo;
180 }
181}
182
183extern "C" Isis::NormModel *ShadeAtmPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) {
184 return new Isis::ShadeAtm(pvl, pmodel, amodel);
185}
Isotropic atmos scattering model.
Definition AtmosModel.h:60
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