9#include "NumericalApproximation.h"
10#include "IException.h"
18 TopoAtm::TopoAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : NormModel(pvl, pmodel, amodel) {
30 PvlGroup &algorithm = pvl.findObject(
"NormalizationModel").findGroup(
"Algorithm", Pvl::Traverse);
37 if(algorithm.hasKeyword(
"Incref")) {
38 SetNormIncref(algorithm[
"Incref"]);
41 if(algorithm.hasKeyword(
"Pharef")) {
42 SetNormPharef(algorithm[
"Pharef"]);
45 p_normPharef = p_normIncref;
48 if(algorithm.hasKeyword(
"Emaref")) {
49 SetNormEmaref(algorithm[
"Emaref"]);
52 if(algorithm.hasKeyword(
"Albedo")) {
53 SetNormAlbedo(algorithm[
"Albedo"]);
58 GetPhotoModel()->SetStandardConditions(
true);
59 psurf0 = GetPhotoModel()->CalcSurfAlbedo(0.0, 0.0, 0.0);
62 std::string msg =
"Divide by zero encountered";
63 throw IException(IException::Unknown, msg, _FILEINFO_);
66 p_normRhobar = p_normAlbedo / psurf0;
69 psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
70 pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
71 GetPhotoModel()->SetStandardConditions(
false);
74 GetAtmosModel()->GenerateAhTable();
76 ahref = (GetAtmosModel()->AtmosAhSpline()).Evaluate(p_normIncref, NumericalApproximation::Extrapolate);
78 munotref = cos((PI / 180.0) * p_normIncref);
81 GetAtmosModel()->SetStandardConditions(
true);
82 GetAtmosModel()->CalcAtmEffect(p_normPharef, p_normIncref, p_normEmaref, &pstdref, &transref,
83 &trans0ref, &sbar, &transs);
84 GetAtmosModel()->SetStandardConditions(
false);
89 p_normAout = p_normRhobar * pprimeref * trans0ref;
90 p_normBout = pstdref + p_normRhobar * (transref * ahref * munotref /
91 (1.0 - p_normRhobar * GetAtmosModel()->AtmosAb() * sbar) + trans0ref *
92 (psurfref - ahref * munotref));
100 void TopoAtm::NormModelAlgorithm(
double phase,
double incidence,
double emission,
101 double demincidence,
double dememission,
double dn,
102 double &albedo,
double &mult,
double &base) {
105 static double pprime;
106 static double ahInterp;
123 static double old_phase = -9999;
124 static double old_incidence = -9999;
125 static double old_emission = -9999;
126 static double old_demincidence = -9999;
127 static double old_dememission = -9999;
129 if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
130 old_demincidence != demincidence || old_dememission != dememission) {
132 psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission);
133 pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission);
134 ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate);
136 munot = cos(incidence * (PI / 180.0));
139 old_incidence = incidence;
140 old_emission = emission;
141 old_demincidence = demincidence;
142 old_dememission = dememission;
145 GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &sbar,
147 pflat = pstd + p_normRhobar * (trans * ahInterp * munot /
148 (1.0 - p_normRhobar * GetAtmosModel()->AtmosAb() * sbar) + trans0 * (psurf -
150 ptilt = pflat + p_normRhobar * pprime * trans0 * eps;
152 dpm = (psurf - ahInterp * munot) * trans0;
153 q = ahInterp * munot * trans + GetAtmosModel()->AtmosAb() * sbar * dpo + dpm;
154 rhotlt = 2.0 * dpo / (q + sqrt(pow(q, 2.0) - 4.0 * GetAtmosModel()->AtmosAb() * sbar * dpo * dpm));
156 q = ahInterp * munot * trans + GetAtmosModel()->AtmosAb() * sbar * dpo + dpm;
157 rhoflat = 2.0 * dpo / (q + sqrt(pow(q, 2.0) - 4.0 * GetAtmosModel()->AtmosAb() * sbar * dpo * dpm));
158 pprimeeff = (rhotlt - rhoflat) / (rhoflat * eps);
159 slope = (dn - 1.0) / pprimeeff;
160 albedo = p_normAout * slope + p_normBout;
172 void TopoAtm::SetNormPharef(
const double pharef) {
173 if(pharef < 0.0 || pharef >= 180.0) {
174 std::string msg =
"Invalid value of normalization pharef [" +
IString(pharef) +
"]";
175 throw IException(IException::User, msg, _FILEINFO_);
178 p_normPharef = pharef;
190 void TopoAtm::SetNormIncref(
const double incref) {
191 if(incref < 0.0 || incref >= 90.0) {
192 std::string msg =
"Invalid value of normalization incref [" +
IString(incref) +
"]";
193 throw IException(IException::User, msg, _FILEINFO_);
196 p_normIncref = incref;
208 void TopoAtm::SetNormEmaref(
const double emaref) {
209 if(emaref < 0.0 || emaref >= 90.0) {
210 std::string msg =
"Invalid value of normalization emaref [" +
IString(emaref) +
"]";
211 throw IException(IException::User, msg, _FILEINFO_);
214 p_normEmaref = emaref;
225 void TopoAtm::SetNormAlbedo(
const double albedo) {
226 p_normAlbedo = albedo;
Isotropic atmos scattering model.
Adds specific functionality to C++ strings.
Container for cube-like labels.
As in the case without an atmosphere, processing proceeds in three steps, a pass 1 PHOTOM followed by...
This is free and unencumbered software released into the public domain.