Unverified Commit 3fe2d968 authored by Amy Stamile's avatar Amy Stamile Committed by GitHub
Browse files

Added AllowError option to campt (#5437)



* Added AllowError option to campt

* added changelog

* Adds ephemeris data to results

* small fixes

* fixed failing test

* Fixed returning info from previous SetImage

---------

Co-authored-by: default avataracpaquette <acpaquette@usgs.gov>
parent d9e91ffc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ release.
- Added new option in `ctxcal` to use monthly computed flatfield files for "Frown" removal in CTX images. [#5338](https://github.com/DOI-USGS/ISIS3/pull/5338)
- CSMCamera can now read and use the body rotation from ALE produced ISDs [#5072](https://github.com/DOI-USGS/ISIS3/pull/5072)
- CSMSkyMap added to CSMCamera for use with local rover projections in ISIS [#5072](https://github.com/DOI-USGS/ISIS3/pull/5072)
- Added ALLOWERROR parameter to campt [#5393](https://github.com/DOI-USGS/ISIS3/pull/5393)
- OSIRIS-REx Tagcams instrument support, tests, and test data added [#5424](https://github.com/DOI-USGS/ISIS3/issues/5424)


## [8.1.0] - 2024-01-08

### Changed
+11 −5
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ namespace Isis{
    QList<PvlGroup*> cameraPoints;
    bool usePointList = ui.WasEntered("COORDLIST");
    bool allowOutside = ui.GetBoolean("ALLOWOUTSIDE");
    bool allowError = ui.GetBoolean("ALLOWERROR");
    QString type;
    if (ui.WasEntered("COORDLIST")) {
      type = ui.GetString("COORDTYPE");
@@ -131,25 +132,30 @@ namespace Isis{

      QPair<double, double> pt = points[i];
      if (type == "GROUND") {
        if (allowError) {
          camPoint = campt.SetGround(pt.first, pt.second, allowOutside, allowError);
        }
        else {
          camPoint = campt.SetGround(pt.first, pt.second, allowOutside, usePointList);
        }      
      }
      else {
        if (usePointList) {
          camPoint = campt.SetImage(pt.first, pt.second, allowOutside, usePointList);
        }
        else {
          if (ui.WasEntered("SAMPLE") && ui.WasEntered("LINE")) {
            camPoint = campt.SetImage(pt.first, pt.second, allowOutside);
            camPoint = campt.SetImage(pt.first, pt.second, allowOutside, allowError);
          }
          else {
            if (ui.WasEntered("SAMPLE")) {
              camPoint = campt.SetSample(pt.first, allowOutside);
              camPoint = campt.SetSample(pt.first, allowOutside, allowError);
            }
            else if (ui.WasEntered("LINE")) {
              camPoint = campt.SetLine(pt.second, allowOutside);
              camPoint = campt.SetLine(pt.second, allowOutside, allowError);
            }
            else {
              camPoint = campt.SetCenter(allowOutside);
              camPoint = campt.SetCenter(allowOutside, allowError);
            }
          }
        }
+18 −7
Original line number Diff line number Diff line
@@ -115,13 +115,6 @@ Group = GroundPoint
  Error                      = NULL
End_Group
    </pre>

    <p>
    Note: The "Error" keyword will only appear when using a coordinate list. The value of
    "Error" will be NULL unless an error occurs during the processing of a coordinate in the
    <a href="#FilesCOORDLIST">coordinate list</a>. Then, the value of this keyword will be the error
    message.
    </p>
  </description>

  <category>
@@ -432,6 +425,24 @@ End_Group
        </description>
        <default><item>TRUE</item></default>
      </parameter>
      <parameter name="ALLOWERROR">
        <type>boolean</type>
        <brief>
          Allow campt to output results regardless of errors. 
        </brief>
        <description>
          The Allowerror parameter enables <i>campt</i> to return results despite any errors. 
          Errors will be listed under "Error" in the result table, providing the user with information 
          about points that may lack surface intersection.
          <p>
            By default, <i>campt</i> is set to False, causing it to throw an error if any occur.
          </p>
          <p>
            If <i>campt</i> is set to True, errors will be displayed in the error section of the results table instead of being thrown.
          </p>
        </description>
        <default><item>FALSE</item></default>
      </parameter>
    </group>

    <group name="Position">
+64 −10
Original line number Diff line number Diff line
@@ -349,6 +349,7 @@ namespace Isis {
    }

    if (!noErrors) {
      if (!allowErrors) {
        for (int i = 0; i < gp->keywords(); i++) {
          QString name = (*gp)[i].name();
          // These three keywords have 3 values, so they must have 3 NULLs
@@ -362,6 +363,59 @@ namespace Isis {
            (*gp)[i].setValue("NULL");
          }
        }
      }
      else {
        double pB[3], spB[3], sB[3];

        m_camera->instrumentPosition(spB);
        gp->findKeyword("SpacecraftPosition").addValue(toString(spB[0]), "km");
        gp->findKeyword("SpacecraftPosition").addValue(toString(spB[1]), "km");
        gp->findKeyword("SpacecraftPosition").addValue(toString(spB[2]), "km");

        try {
          m_camera->sunPosition(sB);
          gp->findKeyword("SunPosition").addValue(toString(sB[0]), "km");
          gp->findKeyword("SunPosition").addValue(toString(sB[1]), "km");
          gp->findKeyword("SunPosition").addValue(toString(sB[2]), "km");
        }
        catch (IException &e) {
          gp->findKeyword("SunPosition").addValue("Null");
          gp->findKeyword("SunPosition").addValue("Null");
          gp->findKeyword("SunPosition").addValue("Null");
        }

        std::vector<double>lookB = m_camera->lookDirectionBodyFixed();
        gp->findKeyword("LookDirectionBodyFixed").addValue(toString(lookB[0]), "DEGREE");
        gp->findKeyword("LookDirectionBodyFixed").addValue(toString(lookB[1]), "DEGREE");
        gp->findKeyword("LookDirectionBodyFixed").addValue(toString(lookB[2]), "DEGREE");

        try {
          std::vector<double>lookJ = m_camera->lookDirectionJ2000();
          gp->findKeyword("LookDirectionJ2000").addValue(toString(lookJ[0]), "DEGREE");
          gp->findKeyword("LookDirectionJ2000").addValue(toString(lookJ[1]), "DEGREE");
          gp->findKeyword("LookDirectionJ2000").addValue(toString(lookJ[2]), "DEGREE");
        }
        catch (IException &e) {
          gp->findKeyword("LookDirectionJ2000").addValue("Null");
          gp->findKeyword("LookDirectionJ2000").addValue("Null");
          gp->findKeyword("LookDirectionJ2000").addValue("Null");
        }

        try {
          double lookC[3];
          m_camera->LookDirection(lookC);
          gp->findKeyword("LookDirectionCamera").addValue(toString(lookC[0]), "DEGREE");
          gp->findKeyword("LookDirectionCamera").addValue(toString(lookC[1]), "DEGREE");
          gp->findKeyword("LookDirectionCamera").addValue(toString(lookC[2]), "DEGREE");
        }
        catch (IException &e) {
          gp->findKeyword("LookDirectionCamera").addValue("Null");
          gp->findKeyword("LookDirectionCamera").addValue("Null");
          gp->findKeyword("LookDirectionCamera").addValue("Null");
        }

      }

      // Set all keywords that still have valid information
      gp->findKeyword("Error").setValue(error);
      gp->findKeyword("FileName").setValue(m_currentCube->fileName());
+11 −0
Original line number Diff line number Diff line
@@ -266,6 +266,17 @@ TEST_F(DefaultCube, FunctionalTestCamptAllowOutside) {
  EXPECT_DOUBLE_EQ( (double) groundPoint.findKeyword("Line"), -1.0);
}

TEST_F(DefaultCube, FunctionalTestCamptAllowError) {
  QVector<QString> args = {"sample=-100", "line=-100", "allowerror=true"};
  UserInterface options(APP_XML, args);
  Pvl appLog;

  campt(testCube, options, &appLog);
  PvlGroup groundPoint = appLog.findGroup("GroundPoint");
  QString ErrorMsg = "Requested position does not project in camera model; no surface intersection";
  EXPECT_PRED_FORMAT2(AssertQStringsEqual, groundPoint.findKeyword("Error"), ErrorMsg);
}

TEST_F(CSMCubeFixture, FunctionalTestCamptCSMCamera) {

  double pointRadius = csm::Ellipsoid().getSemiMajorRadius();