Commit 9cbc7ac2 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Reworded history entry and added testing to make sure data is read in correctly.

parent 48f06c04
Loading
Loading
Loading
Loading
+45 −37
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ void IsisMain() {
  readBytes.readLong = 0;
  fin.seekg(0);
  fin.read(readBytes.readChars, 4);
  if( fin.fail() || fin.eof() ) {
    string msg = "An error ocurred when reading the input file [" + from + "]";
    throw IException(IException::Io, msg, _FILEINFO_);
  }
  readBytes.readFloat = swp.Float(readBytes.readChars);

  if(readBytes.readLong != 1659) {
@@ -58,25 +62,33 @@ void IsisMain() {

  // Read bytes 4-7 to get number of lines
  fin.read(readBytes.readChars, 4);
  if( fin.fail() || fin.eof() ) {
    string msg = "An error ocurred when reading the input file [" + from + "]";
    throw IException(IException::Io, msg, _FILEINFO_);
  }
  readBytes.readFloat = swp.Float(readBytes.readChars);
  int nLines = (int) readBytes.readLong;

  // Read bytes 8-11 to get number of bytes
  fin.read(readBytes.readChars, 4);
  if( fin.fail() || fin.eof() ) {
    string msg = "An error ocurred when reading the input file [" + from + "]";
    throw IException(IException::Io, msg, _FILEINFO_);
  }
  readBytes.readFloat = swp.Float(readBytes.readChars);
  int nBytes = (int) readBytes.readLong;

  // Read bytes 12-15 to get the total number of bits out of all the bands
  fin.read(readBytes.readChars, 4);
  readBytes.readFloat = swp.Float(readBytes.readChars);

  if( fin.fail() || fin.eof() ) {
    string msg = "An error ocurred when reading the input file [" + from + "]";
    throw IException(IException::Io, msg, _FILEINFO_);
  }
  readBytes.readFloat = swp.Float(readBytes.readChars);
  int totalBandBits = readBytes.readLong;

  // Maps the bit type of the file to the number of bytes of that type
  // Taken directly from a given python program that reads in ddd data
  map<int, int> dataTypes = {
    {1450901768, 1},
    {1450902032, 2},
@@ -113,7 +125,8 @@ void IsisMain() {
    nOffset = 1024;
  }

  //TO DO: Reword
  fin.close();

  PvlGroup results("FileInfo");
  results += PvlKeyword( "NumberOfLines", toString(nLines) );
  results += PvlKeyword( "NumberOfBytesPerLine", toString(nBytes) );
@@ -125,12 +138,9 @@ void IsisMain() {
  results += PvlKeyword( "LabelBytes", toString(nOffset) );
  Application::Log(results);

  fin.close();

  ProcessImport p;

  int bitsPerBand = totalBandBits / nBands;
  if ( ui.WasEntered("TO") ) {
  switch(bitsPerBand) {
    case 8:
      p.SetPixelType(Isis::UnsignedByte);
@@ -142,9 +152,8 @@ void IsisMain() {
      p.SetPixelType(Isis::Real);
      break;
    default:
        IString msg = "Unsupported bit per pixel count [" + IString(bitsPerBand) + "]. "; //Reword?
        msg += "(Use the raw2isis and crop programs to import the file in case it is ";
        msg += "line or sample interleaved.)";
      IString msg = "Unsupported bit per pixel count [" + IString(bitsPerBand) + "] ";
      msg += "from [" + from + "]";
      throw IException(IException::Io, msg, _FILEINFO_);
  }

@@ -163,4 +172,3 @@ void IsisMain() {
  p.StartProcess();
  p.EndProcess();
}
}
+9 −8
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
  </brief>

  <description>
    This program will import a ddd image into an Isis cube. The ddd format files are created by Malin Space Science Systems.
    This program will import a ddd image into an Isis cube. The ddd format files
    are created by Malin Space Science Systems.
  </description>

  <history>
@@ -32,12 +33,13 @@
    </change>
    <change name="Kaitlyn Lee" date="2018-03-01">
      We were given a python program that reads in data from a ddd file
      to use as an example. In the python program, the way they calculate the
      number of bands is different from the one we previously used. The old
      formula did the number of total band bits / 8; the formula is now
      the (number of total band bits / 8) / the number of bytes of the data type
      of the file's bit type. ddd files are also pixel interleaved, so the program
      can now process files with multiple bands. Fixes #703.
      to use as an example. In the python program, the formula they used to
      calculate the number of bands is different from the one we previously used.
      The old formula did the number of total band bits / 8; the formula is now
      (the number of total band bits / 8) / the number of bytes of the data type
      of the file's bit type. Added the ability to process files with multiple
      bands. Removed the internal default of the output parameter set to None so
      that an output file is now requried. Fixes #703.
    </change>
  </history>

@@ -64,7 +66,6 @@
      <parameter name="TO">
         <type>cube</type>
         <fileMode>output</fileMode>
         <internalDefault>None</internalDefault>
         <brief>
           Output Isis cube
         </brief>