Commit e9e3a035 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Added spacecraft and instrument name methods to camera models. Fixes #2335.


git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6340 41f8697f-d340-4b68-9986-7bafba869bb8
parent 047a4d87
Loading
Loading
Loading
Loading
+84 −27
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

#include "ApolloMetricDistortionMap.h"

#include <QString>

#include "CameraDetectorMap.h"
#include "CameraFocalPlaneMap.h"
#include "CameraGroundMap.h"
@@ -48,29 +50,8 @@ namespace Isis {
  ApolloMetricCamera::ApolloMetricCamera(Cube &cube) : FramingCamera(cube) {
    NaifStatus::CheckErrors();
    
    // Get the camera characteristics
    SetFocalLength();
    SetPixelPitch();

    // Setup detector map
    new CameraDetectorMap(this);

    // Setup focal plane map
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
    focalMap->SetDetectorOrigin(ParentSamples() / 2.0, ParentLines() / 2.0);

    QString ppKey("INS" + toString(naifIkCode()) + "_PP");
    QString odkKey("INS" + toString(naifIkCode()) + "_OD_K");
    QString decenterKey("INS" + toString(naifIkCode()) + "_DECENTER");

    new ApolloMetricDistortionMap(this, getDouble(ppKey, 0),
                                  getDouble(ppKey, 1), getDouble(odkKey, 0), getDouble(odkKey, 1),
                                  getDouble(odkKey, 2), getDouble(decenterKey, 0),
                                  getDouble(decenterKey, 1), getDouble(decenterKey, 2));

    // Setup the ground and sky map
    new CameraGroundMap(this);
    new CameraSkyMap(this);
    m_instrumentNameLong = "Metric Camera";
    m_instrumentNameShort = "Metric";

    Pvl &lab = *cube.label();
    const PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
@@ -78,27 +59,61 @@ namespace Isis {
    // The Spacecraft Name should be either Apollo 15, 16, or 17.  The name
    // itself could be formatted any number of ways, but the number contained
    // in the name should be unique between the missions
    QString spacecraft = inst.findKeyword("SpacecraftName")[0];
    if (spacecraft.contains("15")) {
    // We use the naifIkCode instead now
    //QString spacecraft = inst.findKeyword("SpacecraftName")[0];
    // Apollo 15 Pan naif code = -917240
    if (naifIkCode() == -915240) {
      p_ckFrameId = -915240;
      p_ckReferenceId = 1;
      p_spkTargetId = -915;
      m_spacecraftNameLong = "Apollo 15";
      m_spacecraftNameShort = "Apollo15";
    }
    else if (spacecraft.contains("16")) {
    // Apollo 16 Pan naif code = -917240
    else if (naifIkCode() == -916240) {
      p_ckFrameId = -916240;
      p_ckReferenceId = 1;
      p_spkTargetId = -916;
      m_spacecraftNameLong = "Apollo 16";
      m_spacecraftNameShort = "Apollo16";
    }
    else if (spacecraft.contains("17")) {
    // Apollo 17 Pan naif code = -917240
    else if (naifIkCode() == -917240) {
      p_ckFrameId = -917240;
      p_ckReferenceId = 1;
      p_spkTargetId = -917;
      m_spacecraftNameLong = "Apollo 17";
      m_spacecraftNameShort = "Apollo17";
    }
    else {
      QString msg = "File does not appear to be an Apollo image";
      throw IException(IException::User, msg, _FILEINFO_);
    }
    
    // Get the camera characteristics
    SetFocalLength();
    SetPixelPitch();

    // Setup detector map
    new CameraDetectorMap(this);

    // Setup focal plane map
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
    focalMap->SetDetectorOrigin(ParentSamples() / 2.0, ParentLines() / 2.0);

    QString ppKey("INS" + toString(naifIkCode()) + "_PP");
    QString odkKey("INS" + toString(naifIkCode()) + "_OD_K");
    QString decenterKey("INS" + toString(naifIkCode()) + "_DECENTER");

    new ApolloMetricDistortionMap(this, getDouble(ppKey, 0),
                                  getDouble(ppKey, 1), getDouble(odkKey, 0), getDouble(odkKey, 1),
                                  getDouble(odkKey, 2), getDouble(decenterKey, 0),
                                  getDouble(decenterKey, 1), getDouble(decenterKey, 2));

    // Setup the ground and sky map
    new CameraGroundMap(this);
    new CameraSkyMap(this);

    // Create a cache and grab spice info since it does not change for
    // a framing camera (fixed spacecraft position and pointing)
    // Convert the start time to et
@@ -107,6 +122,7 @@ namespace Isis {
    NaifStatus::CheckErrors();
  }

  
  /**
   * Returns the shutter open and close times. The user should pass in the
   * exposure duration in seconds and the StartTime keyword value, converted to
@@ -137,8 +153,49 @@ namespace Isis {
    shuttertimes.second = time + (exposureDuration / 2.0);
    return shuttertimes;
  }
  
  
  /**
   * This method returns the full instrument name.
   *
   * @return QString
   */
  QString ApolloMetricCamera::instrumentNameLong() const {
    return m_instrumentNameLong;
  }
  
  
  /**
   * This method returns the shortened instrument name.
   *
   * @return QString
   */
  QString ApolloMetricCamera::instrumentNameShort() const {
    return m_instrumentNameShort;
  }
  
  
  /**
   * This method returns the full spacecraft name.
   * 
   * @return QString
   */
  QString ApolloMetricCamera::spacecraftNameLong() const {
    return m_spacecraftNameLong;
  }
  
  
  /**
   * This method returns the shortened spacecraft name.
   *
   * @return QString
   */
  QString ApolloMetricCamera::spacecraftNameShort() const {
    return m_spacecraftNameShort;
  }
} // End Apollo namespace


/**
 * This is the function that is called in order to instantiate an
 * ApolloMetricCamera object.
+15 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

#include "FramingCamera.h"

#include <QString>

namespace Isis {
  /**
   * @brief Apollo Metric Camera Model
@@ -52,6 +54,9 @@ namespace Isis {
   *   @history 2014-01-17 Kris Becker - Set CkReferenceID to J2000 to resolve
   *                           problem with ckwriter. Also, set the SpkReferenceId
   *                           to J2000. References #1737 and #1739.
   *   @history 2015-08-24 Ian Humphrey and Makayla Shepherd - Added new data members and methods
   *                           to get spacecraft and instrument names. Extended unit test to test
   *                           these methods and added test data for Apollo 16 and 17.
   */
  class ApolloMetricCamera : public FramingCamera {
    public:
@@ -106,10 +111,20 @@ namespace Isis {
       */
      virtual int SpkReferenceId() const { return (1); }
      
      virtual QString instrumentNameLong() const;
      virtual QString instrumentNameShort() const;
      virtual QString spacecraftNameLong() const;
      virtual QString spacecraftNameShort() const;

    private:
      int p_ckFrameId;       //!< "Camera-matrix" Kernel Frame ID
      int p_ckReferenceId;   //!< "Camera-matrix" Kernel Reference ID
      int p_spkTargetId;     //!< Spacecraft Kernel Target ID
      
      QString m_instrumentNameLong; //!< Full instrument name
      QString m_instrumentNameShort; //!< Shortened instrument name
      QString m_spacecraftNameLong; //!< Full spacecraft name
      QString m_spacecraftNameShort; //!< Shortened spacecraft name
  };
};
#endif
+22 −0
Original line number Diff line number Diff line
@@ -30,3 +30,25 @@ DeltaLine = 0.000000000
For center pixel position ...
Latitude OK
Longitude OK


Testing name methods ...
Spacecraft Name Long: Apollo 15
Spacecraft Name Short: Apollo15
Instrument Name Long: Metric Camera
Instrument Name Short: Metric

Spacecraft Name Long: Apollo 16
Spacecraft Name Short: Apollo16
Instrument Name Long: Metric Camera
Instrument Name Short: Metric

Spacecraft Name Long: Apollo 17
Spacecraft Name Short: Apollo17
Instrument Name Long: Metric Camera
Instrument Name Short: Metric


Testing exceptions:

**USER ERROR** File does not appear to be an Apollo image.
+24 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
#include <iomanip>
#include <iostream>

#include <QList>
#include <QString>

#include "ApolloMetricCamera.h"
#include "Camera.h"
#include "CameraFactory.h"
@@ -106,6 +109,27 @@ int main(void) {
    else {
      cout << setprecision(16) << "Longitude off by: " << cam->UniversalLongitude() - knownLon << endl;
    }
    
    // Test name methods
    QList<QString> files;
    files.append("$apollo15/testData/AS15-M-0533.cropped.cub");
    files.append("$apollo16/testData/AS16-M-0533.reduced.cub");
    files.append("$apollo17/testData/AS17-M-0543.reduced.cub");
    
    cout << endl << endl << "Testing name methods ..." << endl;
    for (int i = 0; i < files.size(); i++) {
      Cube n(files[i], "r");
      ApolloMetricCamera *nCam = (ApolloMetricCamera *) CameraFactory::Create(n);
      cout << "Spacecraft Name Long: " << nCam->spacecraftNameLong() << endl;
      cout << "Spacecraft Name Short: " << nCam->spacecraftNameShort() << endl;
      cout << "Instrument Name Long: " << nCam->instrumentNameLong() << endl;
      cout << "Instrument Name Short: " << nCam->instrumentNameShort() << endl << endl;
    }
    
    // Test exception
    cout << endl << "Testing exceptions:" << endl << endl;
    Cube test("$hayabusa/testData/st_2530292409_v.cub", "r");
    ApolloMetricCamera mCam(test);
  }
  catch(IException &e) {
    e.print();
+66 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
#include "ApolloPanIO.h"
#include "ApolloPanoramicDetectorMap.h"

#include <QString>

#include "CameraDistortionMap.h"
#include "CameraFocalPlaneMap.h"
#include "IException.h"
@@ -33,6 +35,29 @@ namespace Isis {
              additiveLineTimeError = 0.0,
              multiplicativeLineTimeError = 0.0;
              
      // Set up naming info
      m_instrumentNameLong = "Panoramic Camera";
      m_instrumentNameShort = "Pan";
      
      // Apollo15 Pan naif code = -915230
      if (naifIkCode() == -915230) {
        m_spacecraftNameLong = "Apollo 15";
        m_spacecraftNameShort = "Apollo15";
      }
      // Apollo16 Pan naif code = -916230
      else if (naifIkCode() == -916230) {
        m_spacecraftNameLong = "Apollo 16";
        m_spacecraftNameShort = "Apollo16";
      }
      // Apollo17 Pan naif code = -917230
      else if (naifIkCode() == -917230) {
        m_spacecraftNameLong = "Apollo 17";
        m_spacecraftNameShort = "Apollo17";
      }
      else {
        QString msg = "File does not appear to be an Apollo image";
        throw IException(IException::User, msg, _FILEINFO_);
      }

      //following keywords in InstrumentAddendum file
      QString ikernKey = "INS" + toString((int)naifIkCode()) + "_CONSTANT_TIME_OFFSET";
@@ -107,8 +132,49 @@ namespace Isis {

      LoadCache();
    }
    
    
  /**
   * This method returns the full instrument name.
   *
   * @return QString
   */
  QString ApolloPanoramicCamera::instrumentNameLong() const {
    return m_instrumentNameLong;
  }
  
  
  /**
   * This method returns the shortened instrument name.
   *
   * @return QString
   */
  QString ApolloPanoramicCamera::instrumentNameShort() const {
    return m_instrumentNameShort;
  }
  
  
  /**
   * This method returns the full spacecraft name.
   * 
   * @return QString
   */
  QString ApolloPanoramicCamera::spacecraftNameLong() const {
    return m_spacecraftNameLong;
  }
  
  
  /**
   * This method returns the shortened spacecraft name.
   *
   * @return QString
   */
  QString ApolloPanoramicCamera::spacecraftNameShort() const {
    return m_spacecraftNameShort;
  }
}// end Isis namespace


/**
 * This is the function that is called in order to instantiate an
 * ApolloPanoramicCamera object.
Loading