Commit d030211d authored by acpaquette's avatar acpaquette Committed by Jesse Mapel
Browse files

Updates to how bundleout.txt is being written cont'd. (#3404)

* Added column/unit descriptions to image header in outputHeader(...) function.

* More changes to clean up the bundleout.txt file.

* Added the locations of the cube list file/file_prefix to the bundleout.txt file.

* Added bundleOut output function to the BundleObservation class.

* Updated BundleObservation::bundleOutput(std::ofstream &fpOut,bool errorPropagation, bool imageCCSV)

* Added history entries/function documentation and minor tweaks to BundleSolutionInfo/BundleObservation

* Fixed a memory issue associated with attempting to set the output control network for BundleSettingsInfo in jigsaw.

* Added reviewer-requested changes.

* Added more updates to this PR per Summer's (the reviewer) request.

* Fixed some formatting in the parameter list ouput introduced by the refactor of the bundleOutputString function.

* Formatting tweaks in BundleSolutionInfo::outputText(...) and BundleObservation::bundleOutputString()... so the columns line-up nicely.

* Implemented more changes requested by Summer (the reviewer).

* Added BundleObservation::bundleoutCSV()/bundleoutputFetchData() functions.  Also changed precision of output, which necessitated formatting changs to the BundleSolutionInfo::outputText() function.  Full refactor per Summer's request not completed yet (needs to be tested).

* Removed BundleObservation::formatBundleOutputString and all references to it in ISIS3.

* Minor formatting changes requested by reviewers.

* Cleaning-up code and logic for changes made for bundleout.txt

* Adding logic to fix incorrect values in bundleout.txt

* Updated cisscal to output the version of cisscal that ISIS has ported over

* Added history to cisscal xml

* Fixing failing unit tests for bundleout logic.

* Minor reversal of modification to BundleObservation.cpp

* Minor typo fixes before PR creation

* Cleaning-up the output code as per reviewer request

* Added back in old formatBundleOutputString function

* Added deprication message for the old bundle output formatter

* Addressed PR comments
parent 14c49e3a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -273,6 +273,10 @@
      coordinate type for reports was set to Rectangular and vice versa.  
      References #501.
    </change>
    <change name="Tyler Wilson" date="2019-05-17">
      Cleaned up the bundleout.txt file and added new information in the header.
      Fixes #3267.
    </change>
  </history>

  <groups>
+3 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ void IsisMain() {
  // retrieve settings from jigsaw gui
  
  BundleSettingsQsp settings = bundleSettings(ui);
  settings->setCubeList(cubeList);
  BundleAdjust *bundleAdjustment = NULL;
  try {
    // Get the held list if entered and prep for bundle adjustment
@@ -81,7 +82,7 @@ void IsisMain() {
    QObject::connect( bundleAdjustment, SIGNAL( statusUpdate(QString) ),
                      bundleAdjustment, SLOT( outputBundleStatus(QString) ) );
    BundleSolutionInfo *bundleSolution = bundleAdjustment->solveCholeskyBR();    
    
    bundleSolution->setOutputControlName( FileName(ui.GetFileName("ONET")).expanded() );
    cout << "\nGenerating report files\n" << endl;

    // write output files
+24 −3
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

#include <QDataStream>
#include <QDebug>
//#include <QFile> currently only used in commented code
#include <QList>
#include <QString>
#include <QtGlobal> // qMax()
@@ -11,7 +10,6 @@
#include <QXmlInputSource>

#include "BundleObservationSolveSettings.h"
//#include "FileName.h"currently only used in commented code
#include "IException.h"
#include "IString.h"
#include "Project.h" // currently used for xml handler
@@ -49,7 +47,7 @@ namespace Isis {
    m_updateCubeLabel      = false;
    m_errorPropagation     = false;
    m_createInverseMatrix  = false;

    m_cubeList             =    "";
    m_outlierRejection     = false;
    m_outlierRejectionMultiplier = 3.0;

@@ -117,6 +115,7 @@ namespace Isis {
   */
  BundleSettings::BundleSettings(const BundleSettings &other)
      : m_validateNetwork(other.m_validateNetwork),
        m_cubeList(other.m_cubeList),
        m_solveObservationMode(other.m_solveObservationMode),
        m_solveRadius(other.m_solveRadius),
        m_updateCubeLabel(other.m_updateCubeLabel),
@@ -162,6 +161,7 @@ namespace Isis {
  BundleSettings &BundleSettings::operator=(const BundleSettings &other) {
    if (&other != this) {
      m_validateNetwork = other.m_validateNetwork;
      m_cubeList = other.m_cubeList;
      m_solveObservationMode = other.m_solveObservationMode;
      m_solveRadius = other.m_solveRadius;
      m_updateCubeLabel = other.m_updateCubeLabel;
@@ -217,6 +217,27 @@ namespace Isis {
  }


  /**
   * @brief BundleSettings::setCubeList
   *
   * @param cubeList
   *
   */
  void BundleSettings::setCubeList(QString cubeList)    {
    m_cubeList = cubeList;
  }


  /**
  * @brief BundleSettings::cubeList
  *
  * @return QString The name/path of the cube list.
  */
  QString BundleSettings::cubeList() const {
    return m_cubeList;
  }


  // =============================================================================================//
  // ======================== Solve Options ======================================================//
  // =============================================================================================//
+5 −0
Original line number Diff line number Diff line
@@ -121,6 +121,8 @@ namespace Isis {
   *                           accessor methods, CoordTypeReports() & CoordTypeBundle()
   *                           for the new coordinate type members.
   *                           References #4649 and #501.
   *   @history 2019-05-17 Tyler Wilson - Added QString m_cubeList member function as well
   *                           as get/set member functions.  References #3267.
   *  
   *   @todo Determine which XmlStackedHandlerReader constructor is preferred
   *   @todo Determine which XmlStackedHandler needs a Project pointer (see constructors)
@@ -294,6 +296,8 @@ namespace Isis {
      void setOutputFilePrefix(QString outputFilePrefix);
      void setSCPVLFilename(QString SCParamFilename);
      QString outputFilePrefix() const;
      void setCubeList(QString fileName);
      QString cubeList() const;
      QString SCPVLFilename() const;

      void save(QXmlStreamWriter &stream, const Project *project) const;
@@ -353,6 +357,7 @@ namespace Isis {
      };

      bool m_validateNetwork; //!< Indicates whether the network should be validated.
      QString m_cubeList;
      bool m_solveObservationMode; //!< Indicates whether to solve for observation mode.
      bool m_solveRadius; //!< Indicates whether to solve for point radii.
      bool m_updateCubeLabel; //!< Indicates whether to update cubes.
+99 −40
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <QXmlStreamWriter>

#include "BundleResults.h"
#include "Control.h"
#include "ControlList.h"
#include "ControlMeasure.h"
#include "ControlNet.h"
@@ -22,6 +23,7 @@
#include "PvlKeyword.h"
#include "PvlObject.h"
#include "StatCumProbDistDynCalc.h"
#include "Statistics.h"
#include "XmlStackedHandlerReader.h"

namespace Isis {
@@ -44,6 +46,7 @@ namespace Isis {
    m_name = m_runTime;
    m_inputControlNetFileName = new FileName(controlNetworkFileName);
    m_outputControl = NULL;
    m_outputControlName="";
    m_settings = inputSettings;
    m_statisticsResults = new BundleResults(outputStatistics);
    m_images = new QList<ImageList *>(imgList);
@@ -67,6 +70,7 @@ namespace Isis {
    m_name = m_runTime;
    m_inputControlNetFileName = NULL;
    m_outputControl = NULL;
    m_outputControlName="";
    m_statisticsResults = NULL;
    // what about the rest of the member data ? should we set defaults ??? CREATE INITIALIZE METHOD
    m_images = new QList<ImageList *>;
@@ -197,6 +201,7 @@ namespace Isis {
      delete m_outputControl;
    }
    m_outputControl = new Control(newOutputFileName.expanded());
    m_outputControlName = newOutputFileName.expanded();
  }


@@ -269,7 +274,11 @@ namespace Isis {
   * @return @b QString The name of the output control network.
   */
  QString BundleSolutionInfo::outputControlNetFileName() const {

    if (m_outputControl)
      return m_outputControl->fileName();
    else
      return m_outputControlName;
  }


@@ -283,6 +292,25 @@ namespace Isis {
  }
    
  
  /**
   * Sets m_outputControlName
   *
   * @param name QString of the new value
   */
  void BundleSolutionInfo::setOutputControlName(QString name) {
    m_outputControlName = name;
  }
  
  
  /**
   * Returns m_outputControlName
   *
   * @returns QString of the value
   */
  QString BundleSolutionInfo::outputControlName() const {
    return m_outputControlName;
  }

  /**
   * Returns bundle output Control object.
   *
@@ -547,6 +575,19 @@ namespace Isis {
    sprintf(buf, "\n                       Network Filename: %s",
                  m_inputControlNetFileName->expanded().toLatin1().data());
    fpOut << buf;

    sprintf(buf,"\n                       Cube List: %s",
                m_settings->cubeList().toStdString().c_str() );

    fpOut << buf;

    sprintf(buf, "\n                       Output Network Filename: %s",
                              outputControlName().toStdString().c_str() );
    fpOut << buf;
    sprintf(buf,"\n                       Output File Prefix: %s",
                m_settings->outputFilePrefix().toStdString().c_str() );
    fpOut <<buf;   

    sprintf(buf, "\n                       Network Id: %s",
                  m_statisticsResults->outputControlNet()->GetNetworkId().toLatin1().data());
    fpOut << buf;
@@ -1003,11 +1044,21 @@ namespace Isis {

    sprintf(buf, "\nIMAGE MEASURES SUMMARY\n==========================\n\n");
    fpOut << buf;
    sprintf(buf,"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tMeasures\t\t\t\t\t\t\t\tRMS(pixels)\n");
    fpOut << buf;
    sprintf(buf,"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t******************************  "
                "**************************************************\n");
    fpOut << buf;

    sprintf(buf,"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|Accepted\t\t|\t\tTotal|\t|Samples\t\t|\t\t"
                "Lines\t\t|\t\tTotal|\n");
    fpOut << buf;

    int numMeasures;
    int numRejectedMeasures;
    int numUsed;
    int imageIndex = 0;
    Statistics rmsSamplesTotal,rmsLinesTotal,rmsTotals;

    for (int i = 0; i < numObservations; i++) {

@@ -1023,34 +1074,40 @@ namespace Isis {
                                        rmsImageLineResiduals()[imageIndex].Rms();
        double rmsLandSResiduals =  m_statisticsResults->
                                        rmsImageResiduals()[imageIndex].Rms();
        rmsSamplesTotal.AddData(rmsSampleResiduals);
        rmsLinesTotal.AddData(rmsLineResiduals);
        rmsTotals.AddData(rmsLandSResiduals);

        numMeasures =         m_statisticsResults->outputControlNet()->
                                  GetNumberOfValidMeasuresInImage(
                                      bundleImage->serialNumber());
        numMeasures = m_statisticsResults->outputControlNet()->GetNumberOfValidMeasuresInImage
            (bundleImage->serialNumber());

        numRejectedMeasures = m_statisticsResults->outputControlNet()->
                                  GetNumberOfJigsawRejectedMeasuresInImage(
                                      bundleImage->serialNumber());
            GetNumberOfJigsawRejectedMeasuresInImage(bundleImage->serialNumber());

        numUsed = numMeasures - numRejectedMeasures;

        if (numUsed == numMeasures) {
          sprintf(buf, "%s   %5d of %5d %6.3lf %6.3lf %6.3lf\n",
                  bundleImage->fileName().toLatin1().data(),
                  (numMeasures-numRejectedMeasures), numMeasures,
                  rmsSampleResiduals, rmsLineResiduals, rmsLandSResiduals);
        }
        else {
          sprintf(buf, "%s   %5d of %5d* %6.3lf %6.3lf %6.3lf\n",
                  bundleImage->fileName().toLatin1().data(),
                  (numMeasures-numRejectedMeasures), numMeasures,
        sprintf(buf,"%-*s\t\t\t\t\t",45,bundleImage->fileName().toLatin1().data());
        fpOut << buf;

        sprintf(buf,"%*d\t\t\t%*d\t\t\t",5,numUsed,5,numMeasures);
        fpOut << buf;

        sprintf(buf,"%-15.4lf\t\t%-15.4lf\t\t%-15.4lf \n",
                rmsSampleResiduals,rmsLineResiduals,rmsLandSResiduals);
        }

        fpOut << buf;
        imageIndex++;
      }
    }

    sprintf(buf,"\nTotal RMS:");
    fpOut << buf;
    sprintf(buf,"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
    fpOut << buf;
    sprintf(buf,"%-15.4lf\t\t%-15.4lf\t\t%-15.4lf\n",
    rmsSamplesTotal.Rms(),rmsLinesTotal.Rms(),rmsTotals.Rms());
    fpOut << buf;

    return true;
  }

@@ -1127,9 +1184,8 @@ namespace Isis {
        sprintf(buf,",");
        fpOut << buf;


        QString observationString =
            observation->formatBundleOutputString(errorProp,true);
            observation->bundleOutputCSV(errorProp);

        //Removes trailing commas
        if (observationString.right(1)==",") {
@@ -1137,6 +1193,7 @@ namespace Isis {
        }

        fpOut << (const char*) observationString.toLatin1().data();

        sprintf(buf,"\n");
        fpOut << buf;
        imgIndex++;
@@ -1149,7 +1206,6 @@ namespace Isis {
  }



  /**
   * Outputs a text file with the results of the BundleAdjust.
   *
@@ -1167,7 +1223,7 @@ namespace Isis {

    m_txtBundleOutputFilename = ofname;

    char buf[1056];
    char buf[4096];
    BundleObservationQsp observation;

    int nObservations = m_statisticsResults->observations().size();
@@ -1220,16 +1276,19 @@ namespace Isis {
        sprintf(buf, "\nImage Serial Number: %s\n", image->serialNumber().toLatin1().data());
        fpOut << buf;

        sprintf(buf, "\n    Image         Initial              Total               "
                     "Final             Initial           Final\n"
                     "Parameter         Value              Correction            "
                     "Value             Accuracy          Accuracy\n");
        sprintf(buf,"Image         Initial                     Total                  "
                    "Final                                      Accuracy\n");
        fpOut << buf;
        sprintf(buf,"Parameter         Value                       Correction"
                    "             Value                      Initial           "
                    "Final           Units\n");
        fpOut << buf;

        QString observationString =
            observation->formatBundleOutputString(berrorProp);
        fpOut << (const char*)observationString.toLatin1().data();
        sprintf(buf,"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
                    "***************************************\n");
        fpOut << buf;

        observation->bundleOutputString(fpOut,berrorProp);
        // Build list of images and parameters for correlation matrix.
        foreach ( QString image, observation->imageNames() ) {
          imagesAndParameters.insert( image, observation->parameterList() );
Loading