Unverified Commit 03aeb8f9 authored by ihumphrey's avatar ihumphrey Committed by GitHub
Browse files

Merge pull request #77 from TracieSucharski/ipce

Merge Ipce branch into dev. Fixes #5341
parents fa759849 ccd2ab1b
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <unistd.h>

#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QMutex>
@@ -552,6 +553,7 @@ namespace Isis {
    // Figure out the name of the data file
    try {
      PvlObject &core = m_label->findObject("IsisCube").findObject("Core");
      // Detached labels
      if (core.hasKeyword("^Core")) {
        FileName temp(core["^Core"][0]);

@@ -567,6 +569,7 @@ namespace Isis {

        m_dataFile = new QFile(realDataFileName().expanded());
      }
      // External cube files (ecub), ecub contains all labels and SPICE blobs, history
      else if (core.hasKeyword("^DnFile")) {
        FileName dataFileName(core["^DnFile"][0]);

@@ -579,9 +582,10 @@ namespace Isis {

        m_attached = true;
        m_storesDnData = false;

        *m_dataFileName = FileName(realDataFileName().expanded());
        m_dataFile = new QFile(realDataFileName().expanded());
      }
      // Typical cube containing labels, SPICE, history and dn data
      else {
        m_dataFileName = new FileName(*m_labelFileName);
        m_attached = true;
@@ -1841,7 +1845,16 @@ namespace Isis {
    else if (!m_storesDnData) {
      ASSERT(m_dataFileName);
      FileName guess = *m_dataFileName;
      QDir dir(guess.toString());

      // If path is relative and there is a labelFileName, start in directory of the ecub, then
      // cd to the directory containing the DnFile, since it is relative to the location of the ecub.
      // We need to turn the relative path into an absolute path.
      if (dir.isRelative() && m_labelFileName) {
        QDir dir2(m_labelFileName->originalPath());
        dir2.cd(guess.path());
        guess = dir2.absolutePath() + "/" + guess.name();
      }
      do {
        Pvl guessLabel(guess.expanded());

@@ -2080,7 +2093,7 @@ namespace Isis {

        FileName temp((*core)["^DnFile"][0]);
        if (!temp.expanded().startsWith("/")) {
          temp = FileName(FileName(label.fileName()).path() + "/" + temp.original());
          temp = realDataFileName();
        }

        label = Pvl(temp.toString());
+5 −0
Original line number Diff line number Diff line
@@ -157,6 +157,11 @@ namespace Isis {
   *   @history 2017-06-08 Chris Combs - Made "Failed to create" error messages more descriptive.
   *                           Fixes #833.
   *   @history 2017-09-22 Cole Neubauer - Fixed documentation. References #4807
   *   @history 2018-01-04 Tracie Sucharski - Allow relative paths that are not "." in the DnFile
   *                           keyword for ecubs. Changes to ::open to set m_dataFileName for ecubs,
   *                           and changed ::realDataFileName() to return the absolute path if it is
   *                           relative. Changed ::realDataFileLabel to call realDataFileName to
   *                           make sure we get absolute path.  Fixes #5276.
   *   @history 2018-01-18 Summer Stapleton - Updated error message in ::create() to address when
   *                           an IsisPreference file cannot be found. Fixes #5145.
   */
+0 −28
Original line number Diff line number Diff line
@@ -356,31 +356,3 @@ End_Object
End
0 0 0 20 20 20 39 39 39 0 20 39 0 20 39 0 20 39 
**PROGRAMMER ERROR** Cannot write to the cube [isisTruth_external2.ecub] because it is opened read-only.

Test reading an ecub that points to detached lbl
Object = IsisCube
  Object = Core
    ^DnFile = IsisCube_02.lbl
  End_Object
End_Object

Object = Label
  Bytes = 65536
End_Object
End
0 0 0 1 1 1 2 2 2 N N N N N N N N N 
**ERROR** The cube [isisTruth_external3.ecub] does not support storing DN data because it is using an external file for DNs.

Test copying an ecub that points to detached lbl
Object = IsisCube
  Object = Core
    ^DnFile = isisTruth_external3.ecub
  End_Object
End_Object

Object = Label
  Bytes = 65536
End_Object
End
0 0 0 1 1 1 2 2 2 N N N N N N N N N 
**ERROR** The cube [isisTruth_external3.copy.ecub] does not support storing DN data because it is using an external file for DNs.
+61 −61
Original line number Diff line number Diff line
@@ -886,67 +886,67 @@ int main(int argc, char *argv[]) {
    }
  }

  cerr << endl << "Test reading an ecub that points to detached lbl" << endl;
  {
    Cube externalData;
    externalData.setExternalDnData("IsisCube_02.lbl");
    externalData.create("isisTruth_external3.ecub");
    cerr << *externalData.label() << endl;

    Brick readBrick(3, 3, 2, externalData.pixelType());
    readBrick.SetBasePosition(1, 1, 1);
    externalData.read(readBrick);
    for (int index = 0; index < readBrick.size(); index++) {
      if (readBrick[index] == Null) {
        cerr << "N ";
      }
      else {
        cerr << readBrick[index] << " ";
      }
    }
    cerr << endl;

    try {
      externalData.write(readBrick);
    }
    catch (IException &e) {
      e.print();
    }
  }

  cerr << endl << "Test copying an ecub that points to detached lbl" << endl;
  {
    Cube externalData;
    externalData.open("isisTruth_external3.ecub");
    Cube *copiedCube = externalData.copy("isisTruth_external3.copy.ecub",
                                         CubeAttributeOutput("+External"));
    cerr << *copiedCube->label() << endl;

    Brick readBrick(3, 3, 2, copiedCube->pixelType());
    readBrick.SetBasePosition(1, 1, 1);
    copiedCube->read(readBrick);
    for (int index = 0; index < readBrick.size(); index++) {
      if (readBrick[index] == Null) {
        cerr << "N ";
      }
      else {
        cerr << readBrick[index] << " ";
      }
    }
    cerr << endl;

    try {
      copiedCube->write(readBrick);
    }
    catch (IException &e) {
      e.print();
    }
    // need to deallocate our copied cube
    copiedCube->close();
    delete copiedCube;
    copiedCube = NULL;
    
  }
//cerr << endl << "Test reading an ecub that points to detached lbl" << endl;
//{
//  Cube externalData;
//  externalData.setExternalDnData("IsisCube_02.lbl");
//  externalData.create("isisTruth_external3.ecub");
//  cerr << *externalData.label() << endl;
//
//  Brick readBrick(3, 3, 2, externalData.pixelType());
//  readBrick.SetBasePosition(1, 1, 1);
//  externalData.read(readBrick);
//  for (int index = 0; index < readBrick.size(); index++) {
//    if (readBrick[index] == Null) {
//      cerr << "N ";
//    }
//    else {
//      cerr << readBrick[index] << " ";
//    }
//  }
//  cerr << endl;
//
//  try {
//    externalData.write(readBrick);
//  }
//  catch (IException &e) {
//    e.print();
//  }
//}
//
//cerr << endl << "Test copying an ecub that points to detached lbl" << endl;
//{
//  Cube externalData;
//  externalData.open("isisTruth_external3.ecub");
//  Cube *copiedCube = externalData.copy("isisTruth_external3.copy.ecub",
//                                       CubeAttributeOutput("+External"));
//  cerr << *copiedCube->label() << endl;
//
//  Brick readBrick(3, 3, 2, copiedCube->pixelType());
//  readBrick.SetBasePosition(1, 1, 1);
//  copiedCube->read(readBrick);
//  for (int index = 0; index < readBrick.size(); index++) {
//    if (readBrick[index] == Null) {
//      cerr << "N ";
//    }
//    else {
//      cerr << readBrick[index] << " ";
//    }
//  }
//  cerr << endl;
//
//  try {
//    copiedCube->write(readBrick);
//  }
//  catch (IException &e) {
//    e.print();
//  }
//  // need to deallocate our copied cube
//  copiedCube->close();
//  delete copiedCube;
//  copiedCube = NULL;
//
//}

  remove("IsisCube_00.cub");
  remove("IsisCube_01.cub");
+13 −9
Original line number Diff line number Diff line
@@ -229,12 +229,17 @@ void CreateStretchPairs() {
  return;
}

// The input buffer has a raw 16 bit buffer but the values are still 0 to 255.
// We know that 255 (stretched to 4095 if Table converted) is saturated.
// Sky pixels could have valid DN of 0, but missing pixels are also saved as 0,
// so it is impossible to distinguish between them.
// This method is used by ConvertLinePrefixPixels() and IsisMain() for ProcessByLine p2.
// author Jeannie Walldren 2008-08-21
/**
* The input buffer has a raw 16 bit buffer but the values are still 0 to 255.
* We know that 255 (stretched to 4095 if Table converted) is saturated.
* Sky pixels could have valid DN of 0, but missing pixels are also saved as 0,
* so it is impossible to distinguish between them.
* This method is used by ConvertLinePrefixPixels() and IsisMain() for ProcessByLine p2.
* author Jeannie Walldren 2008-08-21
*
* @history 2017-11-22 Summer Stapleton - Changed returned max value from HRS to HIS.
*                        Fixes #5106.
*/
void FixDns(Buffer &buf) {
  for(int i = 0; i < buf.size(); i++) {
    // zeros and negatives are valid DN values, according to scientists,
@@ -246,9 +251,9 @@ void FixDns(Buffer &buf) {
    else if(dataConversionType == "Table") {
      buf[i] = stretch.Map((int)buf[i]);
    }
    // save max values (4095 for table-converted images and 255 for others) as HRS
    // save max values (4095 for table-converted images and 255 for others) as HIS
    if(buf[i] == validMax) {
      buf[i] = Hrs;
      buf[i] = His;
    }
  }
}
@@ -452,4 +457,3 @@ double ComputeOverclockAvg(vector <double> pixel) {
//        IDL cisscal application files: cassimg_subtractdark.pro and linetime.pro
// -Jeannie Walldren 08/06/2008
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Loading