8#include "MinnaertEmpirical.h"
12 MinnaertEmpirical::MinnaertEmpirical(Pvl &pvl) : PhotoModel(pvl) {
13 PvlGroup &algo = pvl.findObject(
"PhotometricModel")
14 .findGroup(
"Algorithm", Pvl::Traverse);
17 if (algo.hasKeyword(
"PhaseList")) {
18 SetPhotoPhaseList(algo[
"PhaseList"]);
20 std::string msg =
"The empirical Minnaert phase list was not provided by user";
21 throw IException(IException::User, msg, _FILEINFO_);
23 if (algo.hasKeyword(
"KList")) {
24 SetPhotoKList(algo[
"KList"]);
26 std::string msg =
"The empirical Minnaert k exponent list was not provided by user";
27 throw IException(IException::User, msg, _FILEINFO_);
29 if (algo.hasKeyword(
"PhaseCurveList")) {
30 SetPhotoPhaseCurveList(algo[
"PhaseCurveList"]);
32 std::string msg =
"The empirical Minnaert phase brightness list was not provided by user";
33 throw IException(IException::User, msg, _FILEINFO_);
37 p_photoPhaseAngleCount = (int)p_photoPhaseList.size();
39 if (p_photoPhaseAngleCount != (
int)p_photoKList.size()) {
40 std::string msg =
"Number of empirical Minnaert k list values must be equal";
41 msg +=
"to number of phase angles provided";
42 throw IException(IException::User, msg, _FILEINFO_);
45 if (p_photoPhaseAngleCount != (
int)p_photoPhaseCurveList.size()) {
46 std::string msg =
"Number of empirical Minnaert phase curve list values must be equal";
47 msg +=
"to number of phase angles provided";
48 throw IException(IException::User, msg, _FILEINFO_);
52 p_photoKSpline.Reset();
53 p_photoKSpline.SetInterpType(NumericalApproximation::CubicClamped);
54 p_photoKSpline.AddData(p_photoPhaseList,p_photoKList);
55 p_photoKSpline.SetCubicClampedEndptDeriv(1.0e30,1.0e30);
56 p_photoBSpline.Reset();
57 p_photoBSpline.SetInterpType(NumericalApproximation::CubicClamped);
58 p_photoBSpline.AddData(p_photoPhaseList,p_photoPhaseCurveList);
59 p_photoBSpline.SetCubicClampedEndptDeriv(1.0e30,1.0e30);
62 MinnaertEmpirical::~MinnaertEmpirical() {
63 p_photoKSpline.Reset();
64 p_photoBSpline.Reset();
65 p_photoPhaseList.clear();
67 p_photoPhaseCurveList.clear();
79 void MinnaertEmpirical::SetPhotoPhaseList(QString phasestrlist) {
82 p_photoPhaseList.clear();
84 while (strlist.length()) {
85 phaseangle = strlist.Token(
",");
86 if (phaseangle < 0.0 || phaseangle > 180.0) {
87 std::string msg =
"Invalid value of empirical Minnaert phase angle list value [" +
89 throw IException(IException::User, msg, _FILEINFO_);
91 p_photoPhaseList.push_back(phaseangle);
104 void MinnaertEmpirical::SetPhotoPhaseList(
PvlKeyword phaseList) {
107 if (phaseList.size() == 1) {
108 SetPhotoPhaseList(QString(phaseList));
113 p_photoPhaseList.clear();
115 for (
int i=0; i< phaseList.size(); i++) {
116 phaseAngle = phaseList[i].toDouble();
118 if (phaseAngle < 0.0 || phaseAngle > 180.0) {
119 QString msg =
"Invalid value of empirical Minnaert phase angle list value [" +
121 throw IException(IException::User, msg, _FILEINFO_);
123 p_photoPhaseList.push_back(phaseAngle);
136 void MinnaertEmpirical::SetPhotoKList(QString kstrlist) {
139 p_photoKList.clear();
141 while (strlist.length()) {
142 kvalue = strlist.Token(
",");
144 std::string msg =
"Invalid value of Minnaert k list value [" +
146 throw IException(IException::User, msg, _FILEINFO_);
148 p_photoKList.push_back(kvalue);
164 if (kstrList.size() == 1) {
165 SetPhotoKList(QString(kstrList));
169 p_photoKList.clear();
170 for (
int i=0; i<kstrList.size(); i++) {
171 p_photoKList.push_back(kstrList[i].
toDouble());
182 void MinnaertEmpirical::SetPhotoPhaseCurveList(QString phasecurvestrlist) {
184 IString strlist(phasecurvestrlist);
185 p_photoPhaseCurveList.clear();
187 while (strlist.length()) {
188 phasecurve = strlist.Token(
",");
189 p_photoPhaseCurveList.push_back(phasecurve);
201 void MinnaertEmpirical::SetPhotoPhaseCurveList(
PvlKeyword photocurvestrList) {
204 if (photocurvestrList.size() == 1) {
205 SetPhotoPhaseCurveList(QString(photocurvestrList));
209 p_photoPhaseCurveList.clear();
210 for (
int i=0; i<photocurvestrList.size(); i++) {
211 p_photoPhaseCurveList.push_back(photocurvestrList[i].
toDouble());
215 double MinnaertEmpirical::PhotoModelAlgorithm(
double phase,
double incidence,
217 static double pht_minnaert_empirical;
222 double kInterpolated = 0;
223 double bInterpolated = 0;
225 static double old_phase = -9999;
226 static double old_incidence = -9999;
227 static double old_emission= -9999;
230 if (old_phase == phase && old_incidence == incidence && old_emission == emission) {
231 return pht_minnaert_empirical;
234 old_incidence = incidence;
235 old_emission = emission;
237 incrad = incidence *
Isis::PI / 180.0;
238 emarad = emission *
Isis::PI / 180.0;
242 if (phase != old_phase) {
243 kInterpolated = p_photoKSpline.Evaluate(phase, NumericalApproximation::Extrapolate);
244 bInterpolated = p_photoBSpline.Evaluate(phase, NumericalApproximation::Extrapolate);
248 if(munot <= 0.0 || mu <= 0.0 || incidence == 90.0 ||
250 pht_minnaert_empirical = 0.0;
252 else if(kInterpolated == 1.0) {
253 pht_minnaert_empirical = munot * bInterpolated;
256 pht_minnaert_empirical = bInterpolated * munot * pow((munot * mu), (kInterpolated - 1.0));
259 return pht_minnaert_empirical;
Adds specific functionality to C++ strings.
Empirical Minnaert photometric model Derive model albedo using phase dependent Minnaert equation and ...
Container for cube-like labels.
A single keyword-value pair.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
double toDouble(const QString &string)
Global function to convert from a string to a double.
const double PI
The mathematical constant PI.