Commit 7eb8875b authored by Jesse Mapel's avatar Jesse Mapel Committed by Jesse Mapel
Browse files

Improved voycal error messages (#3373)

parent 6da30f84
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

#include <QList>
#include <QString>
#include <QStringList>

#include "Buffer.h"
#include "Camera.h"
@@ -22,7 +23,7 @@ using namespace Isis;
void calibration(vector<Buffer *> &in,
                 vector<Buffer *> &out);
PvlObject fetchCoefficients(Pvl &calibration, QList<QString> &hierarchy);
void checkCoefficient(PvlObject &coefficients, QString keyName);
void checkCoefficients(PvlObject &coefficients, QStringList keyNames);

// Linearity correction
bool linear;
@@ -103,11 +104,8 @@ void IsisMain() {

    calib = fetchCoefficients(calibra, hierarchy);

    checkCoefficient(calib, "OmegaNaught");
    checkCoefficient(calib, "SunDistance");
    checkCoefficient(calib, "GainCorrection");
    checkCoefficient(calib, "OffsetCorrection");
    checkCoefficient(calib, "DeltaExposureTime");
    checkCoefficients(calib, QStringList{"OmegaNaught", "SunDistance", "GainCorrection",
                                         "OffsetCorrection", "DeltaExposureTime"});
  }
  catch (IException &e) {
    string msg = "Could not find match in [voycal.pvl] calibration file,";
@@ -142,9 +140,9 @@ void IsisMain() {
      // Search voylin.pvl for appropriate object
      lin = fetchCoefficients(linearity, hierarchy);

      checkCoefficient(lin, "NormalizingPower");
      checkCoefficient(lin, "B_HighEndNon-LinearityCorrection");
      checkCoefficient(lin, "K_PowerOfNon-Linearity");
      checkCoefficients(lin ,QStringList{"NormalizingPower",
                                         "B_HighEndNon-LinearityCorrection",
                                         "K_PowerOfNon-Linearity"});
    }
    catch (IException &e) {
      string msg = "Could not find match in [voylin.pvl] calibration file,";
@@ -328,12 +326,18 @@ PvlObject fetchCoefficients(Pvl &calibration, QList<QString> &hierarchy) {
}


void checkCoefficient(PvlObject &coefficients, QString keyName) {
  if (!coefficients.hasKeyword(keyName))
void checkCoefficients(PvlObject &coefficients, QStringList keyNames) {
  QStringList missingCoeffs;
  foreach(const QString &key, keyNames) {
    if (!coefficients.hasKeyword(key)) {
      missingCoeffs.append(key);
    }
  }
  if (!missingCoeffs.isEmpty()) {
    throw IException(
        IException::Programmer,
        "Coefficient [" + keyName + "] was not found in the calibration PVL "
        "for the input data.  Consider adding a default.",
        "Coefficients [" + missingCoeffs.join(", ") + "] were not found in the "
        "calibration PVL for the input data.  Consider adding a default.",
        _FILEINFO_);
  }
}
+26 −23
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ The following linearity equation is used:</p>
    <change name="Debbie A. Cook" date="2012-07-06">
       Updated Spice members to be more compliant with Isis coding standards. References #972.
    </change>
    <change name="Jesse Mapel" date="2019-08-06">
       Updated error message when coefficients cannot be found. References #2685.
    </change>
  </history>

  <category>