Unverified Commit f6501877 authored by Kristin's avatar Kristin Committed by GitHub
Browse files

Merge pull request #149 from jessemapel/rosetta

Added support for binary CK based body reference frames. Fixes #5408
parents ce3fb977 b9eb204c
Loading
Loading
Loading
Loading
+42 −60
Original line number Diff line number Diff line
@@ -1847,11 +1847,6 @@ namespace Isis {
   */
  void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) {

    // Figure out the number of bytes to read for a single line
    int readBytes = Isis::SizeOf(p_pixelType);
    readBytes = readBytes * p_ns * p_nb;
    char *in = new char [readBytes];

    // Set up an Isis::EndianSwapper object
    QString tok(Isis::ByteOrderName(p_byteOrder));
    tok = tok.toUpper();
@@ -1902,6 +1897,11 @@ namespace Isis {
    p_progress->SetMaximumSteps(p_nl);
    p_progress->CheckStatus();

    // Figure out the number of bytes to read for a single line
    int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes;
    int readBytes = p_ns * sampleBytes;
    char *in = new char [readBytes];

    // Loop for each line
    for(int line = 0; line < p_nl; line++) {
      // Check the last io
@@ -1915,16 +1915,6 @@ namespace Isis {
      // Space for storing prefix and suffix data pointers
      vector<char *> tempPre, tempPost;

      // Handle any line prefix bytes
      pos = fin.tellg();
      if (p_saveDataPre) {
        tempPre.push_back(new char[p_dataPreBytes]);
        fin.read(tempPre.back(), p_dataPreBytes);
      }
      else {
        fin.seekg(p_dataPreBytes, ios_base::cur);
      }

      // Check the last io
      if (!fin.good()) {
        QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
@@ -1960,31 +1950,32 @@ namespace Isis {
        // to special pixels
        int osamp = 0;

        for(int samp = band; samp < p_ns * p_nb; samp += p_nb) {
        for(int samp = 0; samp < p_ns; samp++) {
          int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes;
          switch(p_pixelType) {
            case Isis::UnsignedByte:
              (*out)[osamp] = (double)((unsigned char *)in)[samp];
              (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex];
              break;
            case Isis::UnsignedWord:
              (*out)[osamp] =
                (double)swapper.UnsignedShortInt((unsigned short int *)in+samp);
                (double)swapper.UnsignedShortInt(&in[bufferIndex]);
              break;
            case Isis::SignedWord:
              (*out)[osamp] = (double)swapper.ShortInt((short int *)in+samp);
              (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]);
              break;
            case Isis::SignedInteger:
              (*out)[samp] = (double)swapper.Int((int *)in+samp);
              (*out)[samp] = (double)swapper.Int(&in[bufferIndex]);
              break;
            case Isis::Real:
              if(p_vax_convert) {
                (*out)[osamp]= VAXConversion( (float *)in+samp );
                (*out)[osamp]= VAXConversion(&in[bufferIndex]);
              }
              else {
                (*out)[osamp] = (double)swapper.Float((float *)in+samp);
                (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]);
              }
              break;
            case Isis::Double:
              (*out)[osamp] = (double)swapper.Double((double *)in+samp);
              (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]);
              break;
            default:
              break;
@@ -2008,33 +1999,25 @@ namespace Isis {
          funct(*out);
        }

        // Handle any line suffix bytes
        pos = fin.tellg();
        if (p_saveDataPost) {
          tempPost.push_back(new char[p_dataPostBytes]);
          fin.read(tempPost.back(), p_dataPostBytes);
        }
        else {
          fin.seekg(p_dataPostBytes, ios_base::cur);
        }

        // Check the last io
        if (!fin.good()) {
          QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
                       toString((int)pos) + "]. Byte count [" +
                       toString(p_dataPreBytes) + "]" ;
          throw IException(IException::Io, msg, _FILEINFO_);
        }

      } // End band loop

        // Save off the prefix bytes vector
      // Handle record prefix and suffix
      if (p_saveDataPre) {
        for(int samp = 0; samp < p_ns; samp++) {
          char *samplePrefix = new char[p_dataPreBytes];
          memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes);
          tempPre.push_back(samplePrefix);
        }
        p_dataPre.push_back(tempPre);
        tempPre.clear();
      }

        // Save off the suffix bytes vector
      if (p_saveDataPost) {
        for(int samp = 0; samp < p_ns; samp++) {
          char *sampleSuffix = new char[p_dataPostBytes];
          int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes;
          memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes);
          tempPost.push_back(sampleSuffix);
        }
        p_dataPost.push_back(tempPost);
        tempPost.clear();
      }
@@ -2043,12 +2026,11 @@ namespace Isis {
      if (!fin.good()) {
        QString msg = "Cannot read file [" + p_inFile + "]. Position [" +
                     toString((int)pos) + "]. Byte count [" +
                       toString(p_fileHeaderBytes) + "]" ;
                     toString(p_dataPreBytes) + "]" ;
        throw IException(IException::Io, msg, _FILEINFO_);
      }

      } // End band loop

      // Handle the data trailer
      pos = fin.tellg();
      if (p_saveDataTrailer) {
        p_dataTrailer.push_back(new char[p_dataTrailerBytes]);
+13 −2
Original line number Diff line number Diff line
@@ -152,6 +152,17 @@ namespace Isis {
   *   @history 2017-05-29 Kristin Berry - Added support for data trailers in BIP files and fixed
   *                           a typo so that DataTrailerBytes() will return the correct value.
   *                           References #3888.
   *   @history 2018-05-01 Jesse Mapel - Changed data suffix and prefix in BIP files. Previously,
   *                           data suffixes and prefixes were for each band before/after each line.
   *                           Now, data suffixes and prefixes are before/after each sample. For a
   *                           RGB, 3-band image with n samples a line of data was previously
   *                           | Header | R prefix | G prefix | B prefix | R 1 | G 1 | B 1| ...
   *                           | R n | G n | B n| R suffix | G suffix | B suffix | Trailer |. Now
   *                           it is | Header | Prefix 1 | R 1 | G 1 | B 1 | Suffix 1 | ...
   *                           | Prefix n | R n | G n | B n | Suffix n | Trailer |. This change
   *                           was made to accomodate Rosetta VIRTIS-m calibrated data files and
   *                           has no impact on other supported BIP files.
   *                           Fixes #5398.
   *
   */
  class ProcessImport : public Isis::Process {
+182 −182
Original line number Diff line number Diff line
@@ -3012,7 +3012,7 @@ namespace Isis {
    frinfo_c(frameCode, &centerBodyCode, &frameClass, &classId, &found);

    if (found) {
      if (frameClass == 2  ||  centerBodyCode > 0) {
      if (frameClass == 2  ||  (centerBodyCode > 0 && frameClass != 3)) {
        m_frameType = PCK;
        // Load the PC information while it is available and set member values
        loadPCFromSpice(centerBodyCode);
+82 −77
Original line number Diff line number Diff line
@@ -209,6 +209,12 @@ namespace Isis {
   *   @history 2017-12-13 Ken Edmundson - Added "case DYN:" to methods ToReferencePartial and toJ2000Partial. Fixes #5251.
   *                           This problem was found when trying to bundle M3 images that had been spiceinited with nadir
   *                           pointing. The nadir frame is defined as a Dynamic Frame by Naif.
   *   @history 2018-04-21 Jesse Mapel - Modified frametype resolution to check if a body centered
   *                           frame uses a CK or PCK definition. This only occurs for bodies
   *                           where a pck cannot accurately define for the duration of a mission.
   *                           The current example is the comet 67P/CHURYUMOV-GERASIMENKO
   *                           imaged by Rosetta. Some future comet/astroid missions are expected
   *                           to use a CK defined body fixed reference frame. Fixes #5408.
   *
   *  @todo Downsize using Hermite cubic spline and allow Nadir tables to be downsized again.
   *  @todo Consider making this a base class with child classes based on frame type or
@@ -591,4 +597,3 @@ namespace Isis {
};

#endif
+7 −0
Original line number Diff line number Diff line
@@ -624,6 +624,13 @@ Frame type is binary PCK and cannot be updated
End of PCK testing


Testing CK based body rotation with 67P/Churyumov–Gerasimenko data ...
Time = 4.6285471e+08
CJ = 0.93816333 -0.34618155 -0.002810256
     0.30996014 0.84356223 -0.43855157
     0.15418909 0.41056193 0.89870163


Testing exceptions...

**I/O ERROR** Cannot find [INS-99999_TRANSX] in text kernels.
Loading