Commit d865dcab authored by Kaitlyn Lee's avatar Kaitlyn Lee Committed by Summer Stapleton
Browse files

History entry added to cube after running sumspice. Fixes #4972. (#658)

* Added WriteHistory() method to SumFinder.

* Renamed method.

* Refactored writeHistory to be up to isis standards.

* Added history entries and updated code to be up to isis standards.

* Updated history entry.
parent e6fb02c5
Loading
Loading
Loading
Loading
+119 −98
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@
#include "Kernels.h"
#include "NaifStatus.h"
#include "Progress.h"
#include "History.h"
#include "Application.h"


using namespace std;
@@ -355,7 +357,7 @@ namespace Isis {
    PvlGroup &instGrp = cubeLabels->findGroup("Instrument", Pvl::Traverse);
    PvlKeyword exptime = instGrp["ExposureDuration"];
    QString units = exptime.unit(0).toLower();
    double etime(toDouble(exptime[0]));
    double etime = toDouble(exptime[0]);

    // Convert to seconds if indicated
    if ( "milliseconds" == units) etime /= 1000.0;
@@ -380,7 +382,7 @@ namespace Isis {
  bool SumFinder::update(const unsigned int options)  {
    confirmValidity(m_cube,"Valid Cube (and SUMFILE) required for updates!");

    bool good(true);
    bool good = true;

    // Reset timing to original times just needs a cube file.
    if ( options & Reset) {
@@ -409,7 +411,6 @@ namespace Isis {
      }
    }


    return (good);
  }

@@ -470,7 +471,7 @@ namespace Isis {
    PvlGroup &instGrp = cubeLabel->findGroup("Instrument", Pvl::Traverse);
    PvlGroup sumtime("SumTimeHistory");
    PvlGroup *sumtPtr = &sumtime;
    bool addSumGroup(true);  // Assume the object doesn't exist!
    bool addSumGroup = true;  // Assume the object doesn't exist!

    // Some monkey business for Sumtime history object (see below)
    PvlObject &isiscube = cubeLabel->findObject("IsisCube");
@@ -674,7 +675,7 @@ namespace Isis {
  }

  int SumFinder::disableSpice(Pvl &label) const {
    int ndeleted(0);
    int ndeleted = 0;

    if ( label.hasObject("IsisCube") ) {
      PvlObject &iCube = label.findObject("IsisCube");
@@ -703,7 +704,27 @@ namespace Isis {
    return (ndeleted);
  }

  /**
   * Writes out the History blob to m_cube
   */
  void SumFinder::writeHistory() {
    bool addedHist = false;
    Isis::Pvl &inlab = *m_cube->label();
    for (int i = 0; i < inlab.objects(); i++) {
      if ( inlab.object(i).isNamed("History") && Isis::iApp != NULL ) {
        Isis::History h( (QString) inlab.object(i)["Name"] );
        m_cube->read(h);
        h.AddEntry();
        m_cube->write(h);
        addedHist = true;
      }
    }
// namespace Isis


    if (!addedHist && Isis::iApp != NULL) {
      Isis::History h("IsisCube");
      h.AddEntry();
      m_cube->write(h);
    }
  }
}
// namespace Isis
+30 −24
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ namespace Isis {
   *   @history 2016-09-14 Kris Becker - Original Version
   *   @history 2017-02-09 Jesse Mapel - Updated to ignore invalid
   *                            SpacecraftClockStopCount values.
   *   @history 2018-04-12 Kaitlyn Lee - Added method writeHistory()
   *                           to add a sumspice entry to
   *                           m_cube's History blob. Fixes #4972.
   *
   */
  class SumFinder {
    public:
@@ -97,6 +101,8 @@ namespace Isis {

      bool update(const unsigned int options);

      void writeHistory();

   protected:
      virtual bool calculateTimes(Cube &cube,
                                  iTime &startTime,
+24 −22
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ void IsisMain() {

  // Determine the update mode
  QString update = ui.GetString("UPDATE").toLower();
  unsigned int options(0);  // == SumFinder::None
  unsigned int options = 0;  // == SumFinder::None
  if ( "times"    == update ) options |= (unsigned int) SumFinder::Times;
  if ( "spice"    == update ) options |= (unsigned int) SumFinder::Spice;
  // These are unnecessary if UPDATE=SPICE!
@@ -170,7 +170,9 @@ void IsisMain() {
      }
    }

    // This will close the cube but retain all the pertinent info
    // This will update the history blob and close the cube,
    // but retain all the pertinent info
    cubesum->writeHistory();
    cubesum->setCube();
    resultSet.append(cubesum);
    progress.CheckStatus();
+4 −0
Original line number Diff line number Diff line
@@ -318,6 +318,10 @@ sumspice from=st_2395699394_v.lev0.cub sumfile=N2395699394.SUM update=spice sum
      Updated the pvl.DIFF's of the input for the dawn test to ignore the 
      InstrumentPointing keyword. Fixes #5379.
    </change>
    <change name="Kaitlyn Lee" date="2018-04-12">
      Added a call to writeHistory() of the SumFinder class that will add a sumspice
      entry to each input cube's History blob after a successful run. Fixes #4972.
    </change>
  </history>

  <category>