|
Isis 3.0 Object Programmers' Reference |
Home |
00001 #include "Albedo.h" 00002 #include "SpecialPixel.h" 00003 #include "iException.h" 00004 00005 #define MIN(x,y) (((x) < (y)) ? (x) : (y)) 00006 #define MAX(x,y) (((x) > (y)) ? (x) : (y)) 00007 00008 namespace Isis { 00009 Albedo::Albedo (Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl,pmodel) { 00010 PvlGroup &algorithm = pvl.FindObject("NormalizationModel").FindGroup("Algorithm", Pvl::Traverse); 00011 00012 SetNormIncref(0.0); 00013 SetNormIncmat(0.0); 00014 SetNormThresh(30.0); 00015 SetNormAlbedo(1.0); 00016 00017 // Get value from user 00018 if (algorithm.HasKeyword("Incref")) { 00019 SetNormIncref(algorithm["Incref"]); 00020 } 00021 00022 if (algorithm.HasKeyword("Incmat")) { 00023 SetNormIncmat(algorithm["Incmat"]); 00024 } 00025 00026 if (algorithm.HasKeyword("Thresh")) { 00027 SetNormThresh(algorithm["Thresh"]); 00028 } 00029 00030 if (algorithm.HasKeyword("Albedo")) { 00031 SetNormAlbedo(algorithm["Albedo"]); 00032 } 00033 00034 // Calculate normalization at standard conditions 00035 GetPhotoModel()->SetStandardConditions(true); 00036 p_normPsurfref = GetPhotoModel()->CalcSurfAlbedo(p_normIncref, p_normIncref, 0.0); 00037 GetPhotoModel()->SetStandardConditions(false); 00038 } 00039 00040 void Albedo::NormModelAlgorithm (double phase, double incidence, 00041 double emission, double dn, double &albedo, double &mult, 00042 double &base) 00043 { 00044 double psurf; 00045 double result; 00046 00047 // code for scaling each pixel 00048 psurf = GetPhotoModel()->CalcSurfAlbedo(phase, incidence, emission); 00049 00050 // thresh is a parameter limiting how much we amplify the dns 00051 if (p_normPsurfref > psurf*p_normThresh) { 00052 result = NULL8; 00053 albedo = NULL8; 00054 mult = 0.0; 00055 base = 0.0; 00056 } 00057 else { 00058 if (psurf == 0.0) { 00059 std::string msg = "Divide by zero error"; 00060 throw iException::Message(iException::Math,msg,_FILEINFO_); 00061 } 00062 else { 00063 result = dn * p_normPsurfref / psurf; 00064 albedo = result; 00065 mult = p_normPsurfref / psurf; 00066 base = 0.0; 00067 } 00068 } 00069 } 00070 00080 void Albedo::SetNormIncref (const double incref) { 00081 if (incref < 0.0 || incref >= 90.0) { 00082 std::string msg = "Invalid value of normalization incref [" + 00083 iString(incref) + "]"; 00084 throw iException::Message(iException::User,msg,_FILEINFO_); 00085 } 00086 p_normIncref = incref; 00087 } 00088 00095 void Albedo::SetNormIncmat (const double incmat) { 00096 if (incmat < 0.0 || incmat >= 90.0) { 00097 std::string msg = "Invalid value of normalization incmat [" + 00098 iString(incmat) + "]"; 00099 throw iException::Message(iException::User,msg,_FILEINFO_); 00100 } 00101 p_normIncmat = incmat; 00102 } 00103 00112 void Albedo::SetNormAlbedo (const double albedo) { 00113 p_normAlbedo = albedo; 00114 } 00115 00130 void Albedo::SetNormThresh (const double thresh) { 00131 p_normThresh = thresh; 00132 } 00133 } 00134 00135 extern "C" Isis::NormModel *AlbedoPlugin (Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { 00136 return new Isis::Albedo(pvl,pmodel); 00137 }