Commit 9c3c9ea5 authored by Tyler Wilson's avatar Tyler Wilson
Browse files

Ingestion program for Galileo NIMS cubes. Fixes #2407.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6617 41f8697f-d340-4b68-9986-7bafba869bb8
parent 65d4cb69
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -482,9 +482,12 @@ namespace Isis {

  void ProcessImport::SetSuffixOffset(int samples,int lines, int coreBands,int itemBytes){


        p_suffixData = samples*lines*coreBands*itemBytes;




  };


@@ -1429,6 +1432,8 @@ namespace Isis {
    // Handle the file header
    streampos pos = fin.tellg();
    //tjw


    if (p_saveFileHeader) {
      p_fileHeader = new char[p_fileHeaderBytes];
      fin.read(p_fileHeader, p_fileHeaderBytes);
@@ -1436,7 +1441,7 @@ namespace Isis {
    }
    else {
        fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
        fin.seekg(p_fileHeaderBytes, ios_base::beg);

    }

    // Check the last io
@@ -1714,7 +1719,7 @@ namespace Isis {
    }
    else {
        fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
        fin.seekg(p_fileHeaderBytes, ios_base::beg);
        //fin.seekg(p_fileHeaderBytes, ios_base::beg);
    }


@@ -1970,7 +1975,7 @@ namespace Isis {
    }
    else {
        fin.seekg(p_fileHeaderBytes+p_suffixData, ios_base::beg);
        fin.seekg(p_fileHeaderBytes, ios_base::beg);
        //fin.seekg(p_fileHeaderBytes, ios_base::beg);
    }


+25 −32
Original line number Diff line number Diff line
@@ -192,6 +192,28 @@ namespace Isis {
    trnsStrm << "END";


    //tjw
    //Determine if we are processing a QUBE whose
    //core data type is VAX_REAL

    try{

    PvlObject obj = p_pdsLabel.findObject("QUBE");
    PvlKeyword coreKey = obj.findKeyword("CORE_ITEM_TYPE");
    PvlKeyword suffixKey = obj.findKeyword("BAND_SUFFIX_ITEM_TYPE");
      //if ( (coreKey[0] == "VAX_REAL") && (suffixKey[0] =="VAX_REAL") )

      if (coreKey[0] == "VAX_REAL") {

            ProcessImport::SetVAXConvert(true);
        }

    }
    catch(IException &e){


    }



    Isis::PvlTranslationManager pdsXlater(p_pdsLabel, trnsStrm);
@@ -275,6 +297,8 @@ namespace Isis {
    IdentifySource(p_pdsLabel);




    return;
  }

@@ -433,8 +457,7 @@ namespace Isis {
  /**
   * Handles all special pixel setting, ultimately, calls SetSpecialValues.
   */
  void ProcessImportPds::ProcessSpecialPixels(Isis::PvlTranslationManager & pdsXlater,
                                              const bool & isQube) {
  void ProcessImportPds::ProcessSpecialPixels(Isis::PvlTranslationManager & pdsXlater, const bool & isQube) {
    QString str;
    // Set any special pixel values
    double pdsNull = Isis::NULL8;
@@ -631,36 +654,6 @@ namespace Isis {
    QString str;


    //tjw
    //Determine if we are processing a QUBE whose
    //core data type is VAX_REAL

    try{


        PvlObject obj = p_pdsLabel.findObject("QUBE");
        PvlKeyword coreKey = obj.findKeyword("CORE_ITEM_TYPE");



        if (coreKey[0] == "VAX_REAL") {

            ProcessImport::SetVAXConvert(true);
        }

    }
    catch(IException &e){


        //If we're not dealing with a Galileo NIMS cube, then
        //catch the exception and move on

    }





    // Find the organization of the image data
    // Save off which axis the samples, lines and bands are on
    int linePos = 0;
+2 −6
Original line number Diff line number Diff line
@@ -204,16 +204,12 @@ namespace Isis {
   *                          ProcessImportPds objects. Marked
   *                          EndProcess as deprecated.
   *  @history 2015-01-19 Sasha Brownsberger - Made destructor virtual. References #2215.
   *
   *  @history 2016-02-25 Tyler Wilson - Added a check in ProcessPdsQubeLabel to determine
   *                          if a Galileo NIMS qub is being process.   If it is, then
   *                          SetVAXConvert(true) is called which turns on a VAX conversion
   *                          routine in ProcessImport.  If it is not, then nothing happens.
   *  @history 2015-03-10 Tyler Wilson Added to unit test to test opening Galileo NIMS cube files. 
   *                          References #2368.
   *
   *  @todo 2005-02-09 Finish documentation-lots of holes with variable
   *                   definitions in .h file and .cpp methods, and  insert
   *                   implementation example
   *
  
   */
  class ProcessImportPds : public ProcessImport {
+0 −4
Original line number Diff line number Diff line
@@ -956,10 +956,6 @@ isisimportpds: Gathering statistics
**I/O ERROR** Unable to read OriginalLabel [].
**PROGRAMMER ERROR** Unable to find OriginalLabel [].

Testing a Galileo NIMS qub file
isisimportpds: Importing
0% Processed10% Processed20% Processed30% Processed40% Processed50% Processed60% Processed70% Processed80% Processed90% Processed100% Processed

Testing Isis2 file
isisimportpds: Importing
0% Processed10% Processed20% Processed30% Processed40% Processed50% Processed60% Processed70% Processed80% Processed90% Processed100% Processed
+2 −142
Original line number Diff line number Diff line
#include "Isis.h"

#include <QFile>

#include "ProcessImportPds.h"
#include "Application.h"
#include "IString.h"
#include "OriginalLabel.h"
#include "Statistics.h"
#include <QByteArray>
#include <QFile>

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <istream>



using namespace std;
using namespace Isis;
@@ -23,19 +14,13 @@ using namespace Isis;
 * @internal
 *   @history 2012-05-08 Tracie Sucharski - Moved test data to /usgs/cpks/mer/testData and
 *                         /usgs/cpkgs/clementine1/testData.  Added test for invalid label.
 *   @history 2016-02-25 Tyler Wilson - Moved new test data to /usgs/cpks/base/testData and
 *                         Added a check in ProcessPdsQubeLabel for determing if we are
 *                         processing a Galileo NIMS qub saved in VAX format.
 *
 *
 */
void IsisMain() {

  Isis::Preference::Preferences(true);
  void ReportError(QString err);
  QByteArray grabPvl(QString fileName);
  // Test an IMAGE file

  // Test an IMAGE file
  try {
    cout << "Testing PDS file containing an ^IMAGE pointer" << endl;
    Isis::ProcessImportPds p;
@@ -98,79 +83,6 @@ void IsisMain() {
    e.print();
  }

  //Test a Galileo NIMS file

  try{
 
        cout << endl;
        cout << "Testing a Galileo NIMS qub file"  << endl;
        Isis::ProcessImportPds pnims;
        Pvl *nimslab = new Pvl();

        FileName inFile("$base/testData/30i001ci.qub");

        //Open a stream to the PVL file and load it into memory

        QByteArray pvlData= grabPvl(inFile.expanded());
        QTextStream pvlTextStream(&pvlData);
        istringstream pvlStream(pvlTextStream.readAll().toStdString());


        try{
            pvlStream >> *nimslab;
        }
        catch(IException &e) {
            ReportError(e.toString());
        }




        // Convert the pds file to a cube
        try {

        pnims.SetPdsFile(*nimslab,inFile.expanded(),ProcessImportPds::Qube);

        }
        catch(IException &e) {
            ReportError(e.toString());
        }


        Isis::CubeAttributeOutput coreatt = CubeAttributeOutput("+REAL");


        QString nimsfile = Isis::Application::GetUserInterface().GetFileName("TO1");

        try {

        pnims.SetOutputCube(nimsfile,coreatt);

        }
        catch (IException &e) {

            ReportError(e.toString());

        }


        pnims.StartProcess();
        pnims.EndProcess();

        QFile::remove(nimsfile);

    }//end outer try

    catch(Isis::IException &e) {

        ReportError(e.toString());


    }




  // Test an Isis2 file
  try {
    cout << endl;
@@ -242,8 +154,6 @@ void IsisMain() {
  catch (Isis::IException &e) {
    e.print();
  }


}

/**
@@ -257,53 +167,3 @@ void ReportError(QString err) {
  cout << err.replace(QRegExp("\\[[^\\]]*\\]"), "[]") << endl;
}



/**
 * Grabs the Pvl file from the input file and returns it as
 * a byte array which can be easily searched.
 * @param fileName
 * @author Tyler Wilson
 */



QByteArray grabPvl(QString fileName){


    QByteArray null;
    QFile pvlFile;

    pvlFile.setFileName(fileName);

     if ( !pvlFile.open(QFile::ReadOnly|QIODevice::Text))
         return null;


     //Read the Pvl file into a byte array
     QByteArray fileData = pvlFile.readAll();
     QByteArray pvlData;

     QString pvlEnd("QUBE\nEND");
     int ix = fileData.lastIndexOf(pvlEnd);

     pvlData = fileData.left(ix+pvlEnd.size());



    return pvlData;


}










Loading