Commit f7764a11 authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Merged from trunk.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7229 41f8697f-d340-4b68-9986-7bafba869bb8
parent 3bc09260
Loading
Loading
Loading
Loading
+19 −67
Original line number Diff line number Diff line
@@ -16,14 +16,15 @@
#include "Cube.h"
#include "IString.h"
#include "LeastSquares.h"
#include "NaifStatus.h"
#include "nocam2map.h"
#include "PolynomialBivariate.h"
#include "ProcessRubberSheet.h"
#include "ProjectionFactory.h"
#include "Statistics.h"
#include "Target.h"
#include "TextFile.h"
#include "TProjection.h"
#include "NaifStatus.h"

using namespace std;
using namespace Isis;
@@ -71,6 +72,7 @@ void IsisMain() {
  if (ui.WasEntered("LINC")) {
    linc = ui.GetInteger("LINC");
  }

  //Set the degree of the polynomial to use in our functions
  int degree = ui.GetInteger("DEGREE");

@@ -82,7 +84,6 @@ void IsisMain() {
  LeastSquares sampSol(sampFunct);
  LeastSquares lineSol(lineFunct);


  //Setup the variables for solving the stereographic projection
  //x = cos(latitude) * sin(longitude - lon_center)
  //y = cos(lat_center) * sin(latitude) - sin(lat_center) * cos(latitude) * cos(longitude - lon_center)
@@ -90,6 +91,8 @@ void IsisMain() {
  //Get the center lat and long from the input cubes
  double lat_center = latCube->statistics()->Average() * PI / 180.0;
  double lon_center = lonCube->statistics()->Average() * PI / 180.0;


  /**
   * Loop through lines and samples projecting the latitude and longitude at those
   * points to stereographic x and y and adding these points to the LeastSquares
@@ -149,6 +152,7 @@ void IsisMain() {
    oFile.Open(ui.GetFileName("RESIDUALS"), "overwrite");
    oFile.PutLine("Sample,\tLine,\tX,\tY,\tSample Error,\tLine Error\n");
  }

  //Gather the statistics for the residuals from the least squares solutions
  Statistics sampErr;
  Statistics lineErr;
@@ -230,8 +234,6 @@ void IsisMain() {

    PvlKeyword equRadius;
    PvlKeyword polRadius;


    //If the user entered the equatorial and polar radii
    if (ui.WasEntered("EQURADIUS") && ui.WasEntered("POLRADIUS")) {
      equRadius = PvlKeyword("EquatorialRadius", toString(ui.GetDouble("EQURADIUS")));
@@ -239,36 +241,10 @@ void IsisMain() {
    }
    //Else read them from the pck
    else {
      FileName pckFile("$base/kernels/pck/pck?????.tpc");
      pckFile = pckFile.highestVersion();

      QString pckFileName = pckFile.expanded();

      NaifStatus::CheckErrors();
      furnsh_c(pckFileName.toLatin1().data());

      QString target = targetName[0];
      SpiceInt code;
      SpiceBoolean found;

      bodn2c_c(target.toLatin1().data(), &code, &found);
      NaifStatus::CheckErrors();

      if (!found) {
        QString msg = "Could not convert Target [" + target +
                     "] to NAIF code";
        throw IException(IException::Io, msg, _FILEINFO_);
      PvlGroup radii = Target::radiiGroup(targetName[0]);
      equRadius = radii["EquatorialRadius"];
      polRadius = radii["PolarRadius"];
    }

      SpiceInt n;
      SpiceDouble radii[3];

      bodvar_c(code, "RADII", &n, radii);

      equRadius = PvlKeyword("EquatorialRadius", toString(radii[0] * 1000));
      polRadius = PvlKeyword("PolarRadius", toString(radii[2] * 1000));
    }

    mapGrp.addKeyword(equRadius, Pvl::Replace);
    mapGrp.addKeyword(polRadius, Pvl::Replace);

@@ -909,14 +885,6 @@ void ComputeInputRange() {
    }
    //Else read them from the pck
    else {
      FileName pckFile("$base/kernels/pck/pck?????.tpc");
      pckFile = pckFile.highestVersion();

      QString pckFileName = pckFile.expanded();

      NaifStatus::CheckErrors();
      furnsh_c(pckFileName.toLatin1().data());

      QString target;

      //If user entered target
@@ -930,25 +898,9 @@ void ComputeInputRange() {
        target = (QString)fromFile.findKeyword("TargetName", Pvl::Traverse);
      }

      SpiceInt code;
      SpiceBoolean found;

      bodn2c_c(target.toLatin1().data(), &code, &found);
      NaifStatus::CheckErrors();

      if (!found) {
        QString msg = "Could not convert Target [" + target +
                     "] to NAIF code";
        throw IException(IException::Io, msg, _FILEINFO_);
      }

      SpiceInt n;
      SpiceDouble radii[3];

      bodvar_c(code, "RADII", &n, radii);

      equRadius = radii[0] * 1000;
      polRadius = radii[2] * 1000;
      PvlGroup radii = Target::radiiGroup(target);
      equRadius = double(radii["EquatorialRadius"]);
      polRadius = double(radii["PolarRadius"]);
    }

    if (isOcentric) {
+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,10 @@
    <change name="Kristin Berry" date="2015-07-22">
      Added NaifStatus::CheckErrors() to see if any NAIF errors were signaled. References #2248
    </change>
    <change name="Jeannie Backer" date="2016-05-10">
      Replaced calls to NAIF routines (bodn2c and bodvar) with call to static method
      Isis::Target::radiiGroup. References #3934
    </change>
    <change name="Curtis Rose" date="2016-05-16">
      Fixed an issue with small cubes (9x9 or less) causing application to become stuck in an infinite loop. References #2284.
      Also added to the description a message about why the application fails on small cubes (5x1, 1x5, or less).
+22 −11
Original line number Diff line number Diff line
@@ -1886,7 +1886,6 @@ void photomet(Buffer &in, Buffer &out) {

    // otherwise, compute angle values
    else {

      bool success = true;
      if (angleSource == "CENTER_FROM_IMAGE" ||
          angleSource == "CENTER_FROM_LABEL" ||
@@ -1918,22 +1917,34 @@ void photomet(Buffer &in, Buffer &out) {
      if(!success) {
        out[i] = NULL8;
      }
      else if(deminc >= 90.0 || demema >= 90.0) {
        out[i] = NULL8;
      // otherwise, do photometric correction
      else {
        pho->Compute(ellipsoidpha, ellipsoidinc, ellipsoidema, deminc, demema, in[i], out[i], mult, base);
      }
      // if angles greater than max allowed by user, set to null
      else if(usedem && (deminc > maxinc || demema > maxema)) {
        out[i] = NULL8;
    }
      else if(!usedem && (ellipsoidinc > maxinc || ellipsoidema > maxema)) {
  }
  // Trim
  if (!usedem) {
    cam->IgnoreElevationModel(true);
  }
  double trimInc = 0, trimEma = 0;
  //bool success = true;
  for (int i = 0; i < in.size(); i++) {
    // if off the target, set to null
    if(!cam->SetImage(in.Sample(i), in.Line(i))) {
      out[i] = NULL8;
      //success = false;
    }
      // otherwise, do photometric correction
    else {
        pho->Compute(ellipsoidpha, ellipsoidinc, ellipsoidema, deminc, demema, in[i], out[i], mult, base);
      trimInc = cam->IncidenceAngle();
      trimEma = cam->EmissionAngle();
    }
    
    if(trimInc > maxinc || trimEma > maxema) {
        out[i] = NULL8;
    }
  }
  cam->IgnoreElevationModel(false);
}

/**
+510 −431
Original line number Diff line number Diff line
@@ -1139,10 +1139,22 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
          <item>FALSE</item>
        </default>
        <description>
          <p>
            This specifies if the image will be trimmed based on the photometric 
	  angles obtained from the DEM surface or the ellipsoid. If this parameter
	  is set to false, then the photometric angles will be obtained from the
          ellipsoidal surface.
            angles obtained from the ellipsoid (default) or the DEM surface. 
          </p>
           <p>
            The ellipsoid is retrieved from the IAU/NAIF target body file, 
            which is defined within the cube's kernel group as the TargetAttitudeShape. 
            If this parameter is set to false, then the photometric angles will be obtained 
            from the ellipsoidal surface.
          </p>
          <p>
            The photometric angles obtained from the DEM surface (shape model)
            for each pixel are obtained using an ellipsoid 
            defined by the radius obtained from the DEM shape model.
            <i>Note that photomet does not trim using local slopes.</i>
          </p>
        </description>
      </parameter>
    </group>
@@ -1163,15 +1175,15 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
          <dl>
          <dt><b>ELLIPSOID (default)</b></dt>
          <dd>
            The photometric angles for each pixel are obtained using the ellipsoid
            shape model.
            The photometric angles for each pixel are obtained using an ellipsoid 
            defined by the radius obtained from the DEM shape model.
          </dd>
          <dt><b>DEM</b></dt>
          <dd>
            The photometric angles for each pixel are obtained using the DEM shape
            model (if one is defined in the image labels).  The surface roughness 
            is taken into account to calculate a surface normal, which is used to 
	    calculate the photometric angles.
            calculate the photometric angles. i.e. slope, local emission, local incidence.
          </dd>
          <dt><b>CENTER_FROM_IMAGE</b></dt>
          <dd>
@@ -1217,8 +1229,8 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
          <option value="ELLIPSOID">
            <brief>Get angles from ELLIPSOID</brief>
            <description>
              The photometric angles for each pixel are obtained using the ellipsoid
              shape model.
              The photometric angles for each pixel are obtained using an ellipsoid 
              defined by the radius obtained from the DEM surface (shape model).
            </description>
            <exclusions>
              <item>PHASE_ANGLE_FILE</item>
@@ -1232,8 +1244,8 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
          <option value="DEM">
            <brief>Get angles from DEM</brief>
            <description>
              The photometric angles for each pixel are obtained using the DEM shape
              model.
              The photometric angles for each pixel are obtained using the DEM surface (shape
              model).
            </description>
            <exclusions>
              <item>PHASE_ANGLE_FILE</item>
@@ -3138,7 +3150,7 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
      </description>
      <terminalInterface>
        <commandLine>
	 from=EW0131773041G_cal.cub to=EW0131773041G_cal_hapkehen_mixed.cub
          0131773041G_cal.cub to=EW0131773041G_cal_hapkehen_mixed.cub 
         frompvl=photomG.pvl phtname=hapkehen theta=9 wh=0.218651 hg1=0.178965 
         hg2=0.971493 hh=0.085 b0=2.7 normname=mixed incref=0 incmat=75 
         thresh=30.0 albedo=0.0
@@ -3349,6 +3361,72 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
      </outputImages>
    </example>
    
    <example>
      <brief>Photometric correction using maximum emission and incidence angle parameters as 
        well as anglesource and usedem parameters.</brief>
      <description>
        <p>
        This example shows the photometric correction of a cube file by setting the maximum 
        emission angle to 75.0 degrees and the maximum incidence angle to 85.0 degrees.  The photometric
        model being used is MINNAERT and the normilization model is ALBEDO.
        The usedem parameter is describing how to trim the image. In this case the trimming is being done using the
        radius obtained from the DEM. The anglesource parameter describes how to calculate the photometric angles. In
        this example the calculation is also being done using the DEM.
      </p>
      </description>
      <terminalInterface>
        <commandLine>
          photomet from=uncropped.cub to=TrimmedTestAngleSourceDemUsedemFalse.cub maxemission=87.0 anglesource=dem 
          phtname=minnaert k=0.5 normname=albedo incref=0 incmat=80 thresh=30 albedo=1.0
        </commandLine>
        <description>
          Run photomet with maximum incidence at 90 degrees and maximum emission less than 90 degrees.
          Photometric model is MINNAERT and normilization model is ALBEDO.
          Usedem is false and anglesource is set to DEM.
        </description>
      </terminalInterface>
      <guiInterfaces>
        <guiInterface>
          <image src="assets/images/Example5GUI.png " width="772" height="1229">
            <brief>Example GUI</brief>
            <description>
              Screenshot of GUI version of the application.  Notice the 
              MAXEMISSION has changed from the default value of 90.0, usedem is set to it's default, 
              and anglesource is set to DEM.
            </description>
            <thumbnail src="assets/thumbs/Example5GUI_thumb.png" caption="photomet GUI" width="176" height="300"/>
          </image>
        </guiInterface>
      </guiInterfaces>
      <inputImages>
        <image src="assets/images/usedemInput.png" width="497" height="497">
          <brief>Input file </brief>
          <description>
            Screenshot of the input image before the photometric correction has been 
            performed. 
          </description>
          <thumbnail src="assets/thumbs/usedemInput_thumb.png" caption="Input image" width="200" height="200"/>
          <parameterName>
            FROM
          </parameterName>
        </image>
      </inputImages>
      <outputImages>
        <image src="assets/images/photometUsedem.png" width="497" height="497">
          <brief>Output file </brief>
          <description> 
            Screenshot of the output image after the photometric correction.  Notice 
            the output image has been trimmed based on the photometric angles 
            defined by the user.
          </description>
          <thumbnail src="assets/thumbs/photometUsedem_thumb.png" caption="Output image" width="200" height="200"/>
          <parameterName>
            TO
          </parameterName>
        </image>
      </outputImages>
    </example>

   <example>
      <brief>Photometric corrections using a three-step approach for MDIM2.1 of Mars</brief>
      <description>
@@ -3411,5 +3489,6 @@ incidence</def> and <def link="Emission Angle">emission angles</def>, respective
       </image>
      </outputImages>
    </example>

  </examples>
</application>
+50 −0
Original line number Diff line number Diff line
APPNAME = photomet

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/cropped.cub \
	to=$(OUTPUT)/angleSourceDemUsedemFalse.cub \
	maxemission=87.0 \
	anglesource=dem \
	phtname=minnaert \
	k=0.5 \
	normname=albedo \
	incref=0 \
	incmat=80 \
	thresh=30 \
	albedo=1.0 > /dev/null;
	$(APPNAME) from=$(INPUT)/cropped.cub \
	to=$(OUTPUT)/angleSourceEllipsoidUsedemFalse.cub \
	maxemission=87.0 \
	phtname=minnaert \
	k=0.5 \
	normname=albedo \
	incref=0 \
	incmat=80 \
	thresh=30 \
	albedo=1.0 > /dev/null;
	$(APPNAME) from=$(INPUT)/cropped.cub \
	to=$(OUTPUT)/angleSourceEllipsoidUsedemTrue.cub \
	maxemission=87.0 \
	usedem=yes \
	phtname=minnaert \
	k=0.5 \
	normname=albedo \
	incref=0 \
	incmat=80 \
	thresh=30 \
	albedo=1.0 > /dev/null;
	$(APPNAME) from=$(INPUT)/cropped.cub \
	to=$(OUTPUT)/angleSourceDemUsedemTrue.cub \
	maxemission=87.0 \
	anglesource=dem \
	usedem=yes \
	phtname=minnaert \
	k=0.5 \
	normname=albedo \
	incref=0 \
	incmat=80 \
	thresh=30 \
	albedo=1.0 > /dev/null;
	
 No newline at end of file
Loading