Commit a52f7c4d authored by Kristin Berry's avatar Kristin Berry
Browse files

Changes to the RosettaVirtisCamera and SpiceRotation to allow spiceinit with mirror kernels

parent 7c813885
Loading
Loading
Loading
Loading
+30 −11
Original line number Diff line number Diff line
@@ -607,7 +607,9 @@ namespace Isis {
      if (p_degree > 0 && p_cacheAv.size() > 1)  p_cacheAv.clear();

      // Load the time cache first
      if (p_minimizeCache != Fixed) {
        p_minimizeCache = No; 
      }
      LoadTimeCache();

      if (p_fullCacheSize > 1) {
@@ -635,7 +637,9 @@ namespace Isis {
      p_cacheAv.clear();

      // Reload the time cache first
      if (p_minimizeCache != Fixed) {
        p_minimizeCache = No; 
      }
      LoadTimeCache();

      for (std::vector<double>::size_type pos = 0; pos < maxSize; pos++) {
@@ -715,7 +719,9 @@ namespace Isis {

      //std::cout << "Full cache size is " << p_cache.size() << endl;
      
      if (p_minimizeCache != Fixed) {
        p_minimizeCache = Yes; 
      }
      LoadTimeCache();

      //std::cout << "Minimized cache size is " << p_cache.size() << endl;
@@ -1931,6 +1937,11 @@ namespace Isis {
    return;
 }

  // NEW: sets the cache time
  void SpiceRotation::SetCacheTime(std::vector<double> cacheTime) {
    MinimizeCache(DownsizeStatus::Fixed); // look at this later. Needed for VIRTIS-M 
    p_cacheTime = cacheTime; 
  }

  /**
   * Evaluate the derivative of the fit polynomial defined by the
@@ -2296,11 +2307,13 @@ namespace Isis {
    ktotal_c("ck", (SpiceInt *) &count);

    // Downsize the loaded cache
    if ((p_source == Memcache) && p_minimizeCache == Yes) {
    if ((p_source == Memcache) && p_minimizeCache == Yes) { // FIXME me (skip this if: minimizeCache == no)
      // Multiple ck case, type 5 ck case, or PolyFunctionOverSpice
      //  final step -- downsize loaded cache and reload

      if (p_fullCacheSize != (int) p_cache.size()) {
        std::cout << "fullcachesize: " << p_fullCacheSize << std::endl; 
        std::cout << "p_cache.size(): " << p_cache.size() << std::endl; 

        QString msg =
          "Full cache size does NOT match cache size in LoadTimeCache -- should never happen";
@@ -2397,7 +2410,7 @@ namespace Isis {
        dafus_c(sum, (SpiceInt) 2, (SpiceInt) 6, dc, ic);

        // Don't read type 5 ck here
        if (ic[2] == 5) break;
        if (ic[2] == 5) break; // FIXME: ic[2] is the ck type
//
        // Check times for type 3 ck segment if spacecraft matches
        if (ic[0] == spCode && ic[2] == 3) {
@@ -2476,15 +2489,21 @@ namespace Isis {
      throw IException(IException::User, msg, _FILEINFO_);
    }

    // FIXME: this is the only place we can go with p_minimizeCache = No 
    // Load times according to cache size (body rotations) -- handle first round of type 5 ck case
    //   and multiple ck case --Load a time for every line scan line and downsize later
    if (!timeLoaded) {
    if (! (timeLoaded || (p_cacheTime.size() > 1))) {
      double cacheSlope = 0.0; 
      if (p_fullCacheSize > 1)
        cacheSlope = (p_fullCacheEndTime - p_fullCacheStartTime) / (double)(p_fullCacheSize - 1);
      for (int i = 0; i < p_fullCacheSize; i++)
        p_cacheTime.push_back(p_fullCacheStartTime + (double) i * cacheSlope); 
      if (p_source == Nadir) p_minimizeCache = No;
      // could try to change the kernels: type, resample, something else? check on type 2 or 3, concerned about interpolation
      // it's already type 2 or 3... 
      // FIXME
      if (p_source == Nadir && (p_minimizeCache != Fixed)) {
        p_minimizeCache = No;
      }
    }
    NaifStatus::CheckErrors();
  }
+3 −1
Original line number Diff line number Diff line
@@ -280,7 +280,8 @@ namespace Isis {
      enum DownsizeStatus {
        Yes,  //!< Downsize the cache
        Done, //!< Cache is downsized
        No    //!< Do not downsize the cache
        No,   //!< Do not downsize the cache
        Fixed //!< Never downsize the cache
      };

      /**
@@ -392,6 +393,7 @@ namespace Isis {
      double GetTimeScale();

      void SetOverrideBaseTime(double baseTime, double timeScale);
      void SetCacheTime(std::vector<double> cacheTime); 

      // Derivative methods
      double DPolynomial(const int coeffIndex);
+12 −5
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include <istream>
#include <sstream>
#include <cmath>
#include <iomanip>

#include <QString>
#include <QFileInfo>
@@ -406,16 +407,21 @@ void IsisMain ()
    SpiceDouble etStart;
    SpiceDouble etEnd;
    std::cout << "startScet: " << startScet << std::endl; 
    std::cout << "startScet: " << stopScet << std::endl; 
    std::cout << "stopScet: " << stopScet << std::endl; 
    scs2e_c( (SpiceInt) -226, startScet.toLatin1().data(), &etStart);
    scs2e_c( (SpiceInt) -226, stopScet.toLatin1().data(), &etEnd);
    QString startTime = iTime(etStart).UTC(); 
    QString stopTime = iTime(etEnd).UTC(); 
    QString startTime = iTime(etStart-16.0).UTC(); 
    QString stopTime = iTime(etEnd-16.0).UTC(); 
    std::cout << "starTime: " << startTime  << std::endl; 
    std::cout << "stopTime: " << stopTime  << std::endl; 
    std::cout << std::setprecision(15) << "start et: " << etStart << std::endl; 
    std::cout << std::setprecision(15) << "stop et: " << etEnd << std::endl; 
    std::cout << std::setprecision(15) << "difference: " << etEnd - etStart << std::endl; 

    SpiceChar startSclkString[50]; 
    SpiceChar endSclkString[50]; 
    sce2s_c( (SpiceInt) -226, etStart, (SpiceInt) 50, startSclkString);
    sce2s_c( (SpiceInt) -226, etEnd, (SpiceInt) 50, endSclkString);
    sce2s_c( (SpiceInt) -226, etStart-16.0, (SpiceInt) 50, startSclkString);
    sce2s_c( (SpiceInt) -226, etEnd-16.0, (SpiceInt) 50, endSclkString);
    
    inst.findKeyword("StartTime").setValue(startTime);
    inst.findKeyword("StopTime").setValue(stopTime); 
@@ -485,6 +491,7 @@ QString convertSCET(int word1, int word2, int word3)
  double fractionalSeconds = (double) word3; 
  QString scetString = QString::number(seconds, 'f');
  QStringList scetStringList = scetString.split(".");
  // The integer portion
  scetString = scetStringList[0];
  scetString.append(":");
  scetString.append(QString::number(fractionalSeconds));
+27 −2
Original line number Diff line number Diff line
@@ -292,18 +292,41 @@ namespace Isis {
   */
  void RosettaVirtisCamera::readSCET(const QString &filename) {
   //  Open the ISIS table object
   std::vector<double> cacheTime; 
   Table hktable("VIRTISHouseKeeping", filename);
   m_lineRates.clear();
   int lineno(1);
   double lineEndTime = 0;
   for (int i = 0; i < hktable.Records(); i++) {
     TableRecord &trec = hktable[i];
     QString scetString = trec["dataSCET"];
     double lineMidTime = getClockTime(scetString, naifSpkCode()).Et();
//     double lineMidTime = getClockTime(scetString, naifSpkCode()).Et();
     double exposureDuration = exposureTime(); //16.0; // 16.099999999999998
     lineEndTime = getClockTime(scetString, naifSpkCode()).Et();
//     std::cout << lineno << ", " << iTime(lineEndTime-exposureDuration).UTC()  << ", " << 
//         iTime(lineEndTime).UTC() << std::endl; 
//      std::cout << "UTC: " << getClockTime(scetString, naifSpkCode()).UTC() << std::endl;

     m_lineRates.push_back(LineRateChange(lineno,
                                          lineStartTime(lineMidTime),
                                          lineEndTime-exposureDuration,
                                          //lineStartTime(lineMidTime),
                                          exposureTime()));
     cacheTime.push_back(lineEndTime-exposureTime());
     lineno++;
   }
   cacheTime.push_back(lineEndTime);

//   std::cout << "failing #: " << iTime(528395445.01256).UTC() << std::endl; 
//  2016-SEP-29 04:29:20.638 2016-SEP-29 04:29:36.738 Y
/// 2016-09-29T0 4:29:20.580302, 2016-09-29T04:29:36.580302

//2016-09-29T04:21:20.5558536, 2016-09-29T04:21:36.5558536
//  2016-SEP-29 04:21:20.614 2016-SEP-29 04:21:36.714 Y


//  2016-SEP-29 04:29:40.623 2016-SEP-29 04:29:56.723 Y
//failing #: 2016-09-29T04:29:36.9302085

    // Adjust the last time
    LineRateChange lastR = m_lineRates.back();

@@ -321,6 +344,8 @@ namespace Isis {
    m_lineRates.back() = LineRateChange(lastR.GetStartLine(),
                                        lastR.GetStartEt(),
                                        exposureTime());

    instrumentRotation()->SetCacheTime(cacheTime);
  }