9 #include "PhotoModel.h"
12 #include "IException.h"
26 PhotoModel::PhotoModel(
Pvl &pvl) {
27 PvlGroup &algorithm = pvl.
findObject(
"PhotometricModel").findGroup(
"Algorithm", Pvl::Traverse);
32 p_photoAlgorithmName = algorithm[
"PhtName"][0];
35 p_photoAlgorithmName = algorithm[
"Name"][0];
38 IString msg =
"Keyword [Name] or keyword [PhtName] must ";
39 msg +=
"exist in [Group = Algorithm]";
40 throw IException(IException::User, msg, _FILEINFO_);
43 p_standardConditions =
false;
50 void PhotoModel::SetStandardConditions(
bool standard) {
51 p_standardConditions = standard;
64 double PhotoModel::PhtTopder(
double phase,
double incidence,
73 double inc1, inc2, inc3, inc4;
75 double ema1, ema2, ema3, ema4;
83 xi = sin((
Isis::PI / 180.0) * incidence);
84 zi = cos((
Isis::PI / 180.0) * incidence);
89 if((incidence == 0.0) || (emission == 0.0)) {
93 cphi = (cos((
Isis::PI / 180.0) * phase) -
94 cos((
Isis::PI / 180.0) * incidence) *
95 cos((
Isis::PI / 180.0) * emission)) /
96 (sin((
Isis::PI / 180.0) * incidence) *
101 phi = PhtAcos(cphi) * (180.0 /
Isis::PI);
102 xe = cphi * sin((
Isis::PI / 180.0) * emission);
104 ze = cos((
Isis::PI / 180.0) * emission);
108 xy = sin((
Isis::PI / 180.0) * epsh);
111 cinc = max(-1.0, min(xy * xi + z * zi, 1.0));
112 inc1 = PhtAcos(cinc) * (180.0 /
Isis::PI);
113 cema = max(-1.0, min(xy * xe + z * ze, 1.0));
114 ema1 = PhtAcos(cema) * (180.0 /
Isis::PI);
116 cinc = max(-1.0, min(-xy * xi + z * zi, 1.0));
117 inc2 = PhtAcos(cinc) * (180.0 /
Isis::PI);
118 cema = max(-1.0, min(-xy * xe + z * ze, 1.0));
119 ema2 = PhtAcos(cema) * (180.0 /
Isis::PI);
121 cinc = max(-1.0, min(z * zi, 1.0));
122 inc3 = PhtAcos(cinc) * (180.0 /
Isis::PI);
123 cema = max(-1.0, min(xy * ye + z * ze, 1.0));
124 ema3 = PhtAcos(cema) * (180.0 /
Isis::PI);
126 cinc = max(-1.0, min(z * zi, 1.0));
127 inc4 = PhtAcos(cinc) * (180.0 /
Isis::PI);
128 cema = max(-1.0, min(-xy * ye + z * ze, 1.0));
129 ema4 = PhtAcos(cema) * (180.0 /
Isis::PI);
131 d1 = (CalcSurfAlbedo(phase, inc1, ema1) - CalcSurfAlbedo(phase, inc2, ema2)) / eps;
132 d2 = (CalcSurfAlbedo(phase, inc3, ema3) - CalcSurfAlbedo(phase, inc4, ema4)) / eps;
135 result = sqrt(max(1.0e-30, d1 * d1 + d2 * d2));
150 double PhotoModel::PhtAcos(
double cosang) {
153 if(fabs(cosang) <= 1.0) {
154 result = acos(cosang);
177 double PhotoModel::CalcSurfAlbedo(
double pha,
double inc,
double ema) {
187 double albedo = PhotoModelAlgorithm(pha, inc, ema);