Isis 3.0 Object Programmers' Reference |
Home |
00001 #include "Topo.h" 00002 #include "SpecialPixel.h" 00003 #include "IException.h" 00004 00005 using std::min; 00006 using std::max; 00007 00008 namespace Isis { 00009 Topo::Topo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) { 00010 PvlGroup &algorithm = pvl.FindObject("NormalizationModel").FindGroup("Algorithm", Pvl::Traverse); 00011 00012 SetNormPharef(0.0); 00013 SetNormIncref(0.0); 00014 SetNormEmaref(0.0); 00015 SetNormThresh(30.0); 00016 SetNormAlbedo(1.0); 00017 00018 if(algorithm.HasKeyword("Incref")) { 00019 SetNormIncref(algorithm["Incref"]); 00020 } 00021 00022 if(algorithm.HasKeyword("Pharef")) { 00023 SetNormPharef(algorithm["Pharef"]); 00024 } else { 00025 p_normPharef = p_normIncref; 00026 } 00027 00028 if(algorithm.HasKeyword("Emaref")) { 00029 SetNormEmaref(algorithm["Emaref"]); 00030 } 00031 00032 if(algorithm.HasKeyword("Thresh")) { 00033 SetNormThresh(algorithm["Thresh"]); 00034 } 00035 00036 if(algorithm.HasKeyword("Albedo")) { 00037 SetNormAlbedo(algorithm["Albedo"]); 00038 } 00039 } 00040 00041 void Topo::NormModelAlgorithm(double phase, double incidence, double emission, 00042 double demincidence, double dememission, double dn, 00043 double &albedo, double &mult, double &base) { 00044 static double rhobar; 00045 static double pprimeref; 00046 static double psurfref; 00047 static double psurf; 00048 static double psurf0; 00049 static double pprime; 00050 00051 static double old_phase = -9999; 00052 static double old_incidence = -9999; 00053 static double old_emission = -9999; 00054 static double old_demincidence = -9999; 00055 static double old_dememission = -9999; 00056 00057 if (old_phase != phase || old_incidence != incidence || old_emission != emission || 00058 old_demincidence != demincidence || old_dememission != dememission) { 00059 00060 GetPhotoModel()->SetStandardConditions(true); 00061 psurf0 = GetPhotoModel()->CalcSurfAlbedo(0.0, 0.0, 0.0); 00062 00063 if(psurf0 == 0.0) { 00064 std::string msg = "Divide by zero error"; 00065 throw IException(IException::Unknown, msg, _FILEINFO_); 00066 } 00067 else { 00068 rhobar = p_normAlbedo / psurf0; 00069 } 00070 00071 psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref); 00072 pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref); 00073 GetPhotoModel()->SetStandardConditions(false); 00074 00075 // code for scaling each pixel 00076 psurf = GetPhotoModel()->CalcSurfAlbedo(phase, demincidence, dememission); 00077 pprime = GetPhotoModel()->PhtTopder(phase, demincidence, dememission); 00078 00079 old_phase = phase; 00080 old_incidence = incidence; 00081 old_emission = emission; 00082 old_demincidence = demincidence; 00083 old_dememission = dememission; 00084 } 00085 00086 if(psurf * pprimeref > pprime * p_normThresh) { 00087 albedo = NULL8; 00088 } 00089 else { 00090 if(pprime == 0.0) { 00091 std::string msg = "Divide by zero error"; 00092 throw IException(IException::Unknown, msg, _FILEINFO_); 00093 } 00094 else { 00095 albedo = dn * rhobar * (psurf * pprimeref) / pprime + 00096 rhobar * psurfref - rhobar * (psurf * pprimeref) / pprime; 00097 } 00098 } 00099 } 00100 00110 void Topo::SetNormPharef(const double pharef) { 00111 if(pharef < 0.0 || pharef >= 180.0) { 00112 std::string msg = "Invalid value of normalization pharef [" + 00113 IString(pharef) + "]"; 00114 throw IException(IException::User, msg, _FILEINFO_); 00115 } 00116 00117 p_normPharef = pharef; 00118 } 00119 00129 void Topo::SetNormIncref(const double incref) { 00130 if(incref < 0.0 || incref >= 90.0) { 00131 std::string msg = "Invalid value of normalization incref [" + 00132 IString(incref) + "]"; 00133 throw IException(IException::User, msg, _FILEINFO_); 00134 } 00135 00136 p_normIncref = incref; 00137 } 00138 00148 void Topo::SetNormEmaref(const double emaref) { 00149 if(emaref < 0.0 || emaref >= 90.0) { 00150 std::string msg = "Invalid value of normalization emaref [" + 00151 IString(emaref) + "]"; 00152 throw IException(IException::User, msg, _FILEINFO_); 00153 } 00154 00155 p_normEmaref = emaref; 00156 } 00157 00166 void Topo::SetNormAlbedo(const double albedo) { 00167 p_normAlbedo = albedo; 00168 } 00169 00175 void Topo::SetNormThresh(const double thresh) { 00176 p_normThresh = thresh; 00177 } 00178 } 00179 00180 extern "C" Isis::NormModel *TopoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { 00181 return new Isis::Topo(pvl, pmodel); 00182 }