9 #include "SpecialPixel.h" 
   10 #include "IException.h" 
   13   Mixed::Mixed(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) {
 
   14     PvlGroup &algorithm = pvl.findObject(
"NormalizationModel").findGroup(
"Algorithm", 
Pvl::Traverse);
 
   27     if(algorithm.hasKeyword(
"Pharef")) {
 
   28       SetNormPharef(algorithm[
"Pharef"]);
 
   31     if(algorithm.hasKeyword(
"Incref")) {
 
   32       SetNormIncref(algorithm[
"Incref"]);
 
   35     if(algorithm.hasKeyword(
"Emaref")) {
 
   36       SetNormEmaref(algorithm[
"Emaref"]);
 
   39     if(algorithm.hasKeyword(
"Incmat")) {
 
   40       SetNormIncmat(algorithm[
"Incmat"]);
 
   43     if(algorithm.hasKeyword(
"Phamat")) {
 
   44       SetNormPhamat(algorithm[
"Phamat"]);
 
   46       p_normPhamat = p_normIncmat;
 
   49     if(algorithm.hasKeyword(
"Emamat")) {
 
   50       SetNormEmamat(algorithm[
"Emamat"]);
 
   53     if(algorithm.hasKeyword(
"Thresh")) {
 
   54       SetNormThresh(algorithm[
"Thresh"]);
 
   57     if(algorithm.hasKeyword(
"Albedo")) {
 
   58       SetNormAlbedo(algorithm[
"Albedo"]);
 
   64     GetPhotoModel()->SetStandardConditions(
true);
 
   65     p_psurfref = GetPhotoModel()->CalcSurfAlbedo(p_normPharef, p_normIncref, p_normEmaref);
 
   66     double pprimeref = GetPhotoModel()->PhtTopder(p_normPharef, p_normIncref, p_normEmaref);
 
   68     if(p_psurfref == 0.0) {
 
   69       std::string err = 
"Divide by zero error";
 
   73       p_rhobar = p_normAlbedo / p_psurfref;
 
   77     p_psurfmatch = GetPhotoModel()->CalcSurfAlbedo(p_normPhamat, p_normIncmat, p_normEmamat);
 
   78     p_pprimematch = GetPhotoModel()->PhtTopder(p_normPhamat, p_normIncmat, p_normEmamat);
 
   82     double arg = pow(p_psurfref, 2.0) + pow(p_psurfmatch * pprimeref / std::max(1.0e-30, p_pprimematch), 2.0);
 
   83     if((arg < 1.0e-10) || (arg > 1.0e10)) {
 
   84       std::string err = 
"Bad reference state encountered";
 
   89     GetPhotoModel()->SetStandardConditions(
false);
 
   92   void Mixed::NormModelAlgorithm(
double phase, 
double incidence, 
double emission,
 
   93                                  double demincidence, 
double dememission, 
double dn,
 
   94                                  double &albedo, 
double &mult, 
double &base) {
 
   99     static double old_phase = -9999;
 
  100     static double old_incidence = -9999;
 
  101     static double old_emission = -9999;
 
  102     static double old_demincidence = -9999;
 
  103     static double old_dememission = -9999;
 
  105     if (old_phase != phase || old_incidence != incidence || old_emission != emission ||
 
  106         old_demincidence != demincidence || old_dememission != dememission) {
 
  109       psurf = GetPhotoModel()->
CalcSurfAlbedo(phase, demincidence, dememission);
 
  110       pprime = GetPhotoModel()->
PhtTopder(phase, demincidence, dememission);
 
  111       double arg = pow(psurf, 2.0) + pow(p_psurfmatch * pprime / std::max(1.0e-30, p_pprimematch), 2.0);
 
  112       aden = sqrt(std::max(1.0e-30, arg));
 
  115       old_incidence = incidence;
 
  116       old_emission = emission;
 
  117       old_demincidence = demincidence;
 
  118       old_dememission = dememission;
 
  125     if(aden > p_anum * p_normThresh) {
 
  129       albedo = dn * p_anum / aden + p_rhobar * (p_psurfref - p_anum / aden * psurf);
 
  143     if(pharef < 0.0 || pharef >= 180.0) {
 
  144       std::string msg = 
"Invalid value of normalization pharef [" +
 
  149     p_normPharef = pharef;
 
  162     if(incref < 0.0 || incref >= 90.0) {
 
  163       std::string msg = 
"Invalid value of normalization incref [" +
 
  168     p_normIncref = incref;
 
  181     if(emaref < 0.0 || emaref >= 90.0) {
 
  182       std::string msg = 
"Invalid value of normalization emaref [" +
 
  187     p_normEmaref = emaref;
 
  201     if(phamat < 0.0 || phamat >= 180.0) {
 
  202       std::string msg = 
"Invalid value of normalization phamat [" +
 
  207     p_normPhamat = phamat;
 
  221     if(incmat < 0.0 || incmat >= 90.0) {
 
  222       std::string msg = 
"Invalid value of normalization incmat [" +
 
  227     p_normIncmat = incmat;
 
  241     if(emamat < 0.0 || emamat >= 90.0) {
 
  242       std::string msg = 
"Invalid value of normalization emamat [" +
 
  247     p_normEmamat = emamat;
 
  257     p_normAlbedo = albedo;
 
  275     p_normThresh = thresh;