Commit bf66c729 authored by Ken Edmundson's avatar Ken Edmundson Committed by Makayla Shepherd
Browse files

Commit in preparation for git-svn remigration

parent db5f60ca
Loading
Loading
Loading
Loading
+117 −90
Original line number Diff line number Diff line
/**
 * @file
 * $Revision: 1.7 $
 * $Date: 2010/06/17 18:59:11 $
 *
 *   Unless noted otherwise, the portions of Isis written by the USGS are
 *   public domain. See individual third-party library and package descriptions
 *   for intellectual property information, user agreements, and related
 *   information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or
 *   implied, is made by the USGS as to the accuracy and functioning of such
 *   software and related material nor shall the fact of distribution
 *   constitute any such warranty, and no responsibility is assumed by the
 *   USGS in connection therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
 *   in a browser or see the Privacy & Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include "ApolloPanoramicCamera.h"

#include "ApolloPanIO.h"
//#include "ApolloPanIO.h"
#include "ApolloPanoramicCameraFiducialMap.h"
#include "ApolloPanoramicDetectorMap.h"

#include <QString>

#include "Affine.h"

#include "CameraDistortionMap.h"
#include "CameraFocalPlaneMap.h"
#include "IException.h"
#include "IString.h"
#include "iTime.h"
#include "LineScanCameraDetectorMap.h"
#include "LineScanCameraGroundMap.h"
#include "LineScanCameraSkyMap.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
//#include "SampleScanCameraDetectorMap.h"
#include "SampleScanCameraGroundMap.h"
#include "SampleScanCameraSkyMap.h"
#include "NaifStatus.h"
//#include "VariableSampleScanCameraDetectorMap.h"
//#include "PvlGroup.h"
//#include "PvlKeyword.h"

using namespace std;
namespace Isis {
  /**
   * Constructs an Apollo Panoramic Camera object using the image labels.
   * Constructs the Apollo Panoramic Camera model object from the labels.
   *
   * @param lab Pvl label from an Apollo Panoramic image.
   * This constructor uses the Pvl labels for Apollo Panoramic Camera Images.
   *
   * @param lab Pvl label from an Apollo Panoramic Camera image.
   * @internal
   *   @history 2016-09-12 Ken Edmundson - Original version, sort of. Orrin Thomas did the original
   *                       original. The camera model has changed significantly since.
   *
   */
  ApolloPanoramicCamera::ApolloPanoramicCamera(Isis::Cube &cube) : Isis::LineScanCamera(cube) {
    // Set up the camera info from ik/iak kernels
    SetFocalLength(610.0);  //nominal (uncalibrated) focal length in mm from "Apollo 15 SIM Bay
    // Photographic Equipment and Mission Summary" August, 1971
    SetPixelPitch(0.005);   //internally all images are modeled as if they have 5 micron pixels
    
    double  constantTimeOffset = 0.0,
    additionalPreroll = 0.0,
    additiveLineTimeError = 0.0,
    multiplicativeLineTimeError = 0.0;
    
    // Set up naming info
  ApolloPanoramicCamera::ApolloPanoramicCamera(Isis::Cube &cube) : Isis::SampleScanCamera(cube) {
    NaifStatus::CheckErrors();

    m_instrumentNameLong = "Panoramic Camera";
    m_instrumentNameShort = "Pan";

@@ -43,95 +65,100 @@ namespace Isis {
    if (naifIkCode() == -915230) {
      m_spacecraftNameLong = "Apollo 15";
      m_spacecraftNameShort = "Apollo15";
      m_ckFrameId = -915230;
    }
    // Apollo16 Pan naif code = -916230
    else if (naifIkCode() == -916230) {
      m_spacecraftNameLong = "Apollo 16";
      m_spacecraftNameShort = "Apollo16";
      m_ckFrameId = -916230;
    }
    // Apollo17 Pan naif code = -917230
    else if (naifIkCode() == -917230) {
      m_spacecraftNameLong = "Apollo 17";
      m_spacecraftNameShort = "Apollo17";
      m_ckFrameId = -917230;
    }
    else {
      QString msg = "File does not appear to be an Apollo image";
      throw IException(IException::User, msg, _FILEINFO_);
      QString msg = "File does not appear to be an Apollo Panoramic image";
      msg += QString::number(naifIkCode());
      msg += " is not a supported instrument kernel code for Apollo.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    //following keywords in InstrumentAddendum file
    QString ikernKey = "INS" + toString((int)naifIkCode()) + "_CONSTANT_TIME_OFFSET";
    constantTimeOffset = getDouble(ikernKey);
    // Get the Instrument label information needed to define the camera for this frame
    Pvl &lab = *cube.label();
    PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
    QString spacecraft = (QString)inst["SpacecraftName"];
    QString instId = (QString)inst["InstrumentId"];

    ikernKey = "INS" + toString((int)naifIkCode()) + "_ADDITIONAL_PREROLL";
    additionalPreroll = getDouble(ikernKey);
    // read focal length and pixel pitch from the instrument kernel
    SetFocalLength();
    SetPixelPitch();

    ikernKey = "INS" + toString((int)naifIkCode()) + "_ADDITIVE_LINE_ERROR";
    additiveLineTimeError = getDouble(ikernKey);
    ReadSampleRates(lab.fileName());

    ikernKey = "INS" + toString((int)naifIkCode()) + "_MULTIPLI_LINE_ERROR";
    multiplicativeLineTimeError = getDouble(ikernKey);
    SpiceDouble etStart = iTime((QString)inst["StartTime"]).Et();
    setTime(etStart);

    Pvl &lab = *cube.label(); 
    PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
    QString stime = (QString)inst["StartTime"];  
    SpiceDouble etStart;
    str2et_c(stime.toLatin1().data(), &etStart);
    stime = (QString) inst["StopTime"];
    SpiceDouble etStop;
    str2et_c(stime.toLatin1().data(), &etStop);
    iTime isisTime( (QString) inst["StartTime"]);
    
    // Get other info from labels
    // line exposure duration, sec/mm
    double lineRate = ( (double) inst["LineExposureDuration"] )*0.005;    
    
    lineRate *= 1.0 + multiplicativeLineTimeError;
    lineRate += additiveLineTimeError;
    etStart += additionalPreroll * lineRate;
    etStart += constantTimeOffset;
    
    setTime(isisTime);
    
    // Setup detector map
    //note (etStart+etStop)/2.0 is the time in the middle of image 
    //  (line = 0 after interior orientation)
    ApolloPanoramicDetectorMap *detectorMap = 
    new ApolloPanoramicDetectorMap((Camera *)this, 
                                   (etStart+etStop)/2.0, 
                                   (double)lineRate, &lab);
    //interior orientation residual stats
    m_residualMean = detectorMap->meanResidual();
    m_residualMax = detectorMap->maxResidual();
    m_residualStdev = detectorMap->stdevResidual();
    
    detectorMap->SetDetectorSampleSumming(1.0);
    detectorMap->SetStartingDetectorSample(0.0);
    // Setup focal plane map
    PvlGroup &kernel = lab.findGroup("Kernels", Pvl::Traverse);
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, (int) kernel["NaifFrameCode"]);
    // Setup fiducial mark affine transformation (in pixels)
    PvlGroup &fiducials = lab.findGroup("Fiducials", Pvl::Traverse);
    ApolloPanoramicCameraFiducialMap fid(fiducials, naifIkCode());

    //  Retrieve boresight location from instrument kernel (IK) (addendum?)
    double sampleBoreSight = 0.0;  //Presently no NAIF keywords for this sensor
    double lineBoreSight = 0.0;  //Presently no NAIF keywords for this sensor
    Affine* fiducialMap = fid.CreateTrans();

    focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight);
    // Setup detector map for transform of parent image pixels to "detector" pixels
    new VariableSampleScanCameraDetectorMap(this, p_sampleRates, fiducialMap);

    // Setup focal plane map
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());

//    focalMap->SetDetectorOrigin(114374.916541692, 11490.0);
    focalMap->SetDetectorOrigin(0.0, 11490.0);
    focalMap->SetDetectorOffset(0.0, 0.0);

    //  Retrieve boresight location from instrument kernel (IK) (addendum?)
//    double sampleBoreSight = 0.0;  //Presently no NAIF keywords for this sensor
//    double lineBoreSight = 0.0;  //Presently no NAIF keywords for this sensor

    // Setup distortion map
    new CameraDistortionMap(this, -1.0);
    //distMap->SetDistortion(naifIkCode());    Presently no NAIF keywords for this sensor

    //Setup the ground and sky map
    new LineScanCameraGroundMap(this);
    new LineScanCameraSkyMap(this);
    
    PvlGroup &instP = lab.findGroup("Kernels", Pvl::Traverse);
    m_CkFrameId = toInt(instP["NaifFrameCode"][0]);
    m_CkFrameId = -int(-m_CkFrameId/1000)*1000;
    new SampleScanCameraGroundMap(this);
    new SampleScanCameraSkyMap(this);

    LoadCache();
    NaifStatus::CheckErrors();

    delete fiducialMap;
  }

  /**
   * @param filename
   */
  void ApolloPanoramicCamera::ReadSampleRates(QString filename) {
    Table timesTable("SampleScanTimes", filename);

    if(timesTable.Records() <= 0) {
      QString msg = "Table [SampleScanTimes] in [";
      msg += filename + "] must not be empty";
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }

    for(int i = 0; i < timesTable.Records(); i++) {
      p_sampleRates.push_back(SampleRateChange((int)timesTable[i][2],
                                           (double)timesTable[i][0],
                                           timesTable[i][1]));
    }

    if(p_sampleRates.size() <= 0) {
      QString msg = "There is a problem with the data within the Table ";
      msg += "[SampleScanTimes] in [" + filename + "]";
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }
  }

}// end Isis namespace


+9 −41
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@
 *   http://www.usgs.gov/privacy.html.                                    
 */                                                                       

#include "LineScanCamera.h"
#include "SampleScanCamera.h"
#include "VariableSampleScanCameraDetectorMap.h"

namespace Isis {
  class PvlGroup;
@@ -48,9 +49,9 @@ namespace Isis {
     *                           members and methods and removed implementation of these methods
     *                           since Camera now handles this. References #2335. Fixed 
     *                           indentation.
     *   @history 2017-06-28 Makayla Shepherd - Updated documentation. References #4807.
     *   @history 2016-09-12 Ken Edmundson - Major changes, deriving now from SampleScanCamera.
     */
    class ApolloPanoramicCamera : public LineScanCamera {
    class ApolloPanoramicCamera : public SampleScanCamera {
    public:
      ApolloPanoramicCamera(Cube &lab);

@@ -64,7 +65,7 @@ namespace Isis {
      *         Kernel Frame ID
      */
      //this sensor was used on multiple missions so it is necessary to check which Apollo 
      virtual int CkFrameId() const {return m_CkFrameId; }  
      virtual int CkFrameId() const {return m_ckFrameId; }

      /** 
      * CK Reference ID - J2000
@@ -82,46 +83,13 @@ namespace Isis {
      */
      virtual int SpkReferenceId() const { return (1); }

      /** 
       * Returns residual summary statistics from interior orientation as a PvlGroup
       * 
       * @return PvlGroup Residuals report.
       */
      PvlGroup intOriResidualsReport();

      /**
       * Max interior orientation residual vector length, accesor
       * 
       * @return double Residual max
       */
      double intOriResidualMax()   const { return m_residualMax; }

      /**
       * Mean (average) of interior orientation residual vector length, accesor
       * 
       * @return double Residual mean
       */
      double intOriResidualMean()  const { return m_residualMean; }

      /**
       * Standard deviation of interior orientation residual vector length, accesor
       * 
       * @return double Residual standard deviation
       */
      double intOriResidualStdev() const { return m_residualStdev; }

    private:
      //! Max interior orientation residual vector length
      double m_residualMean;

      //! Mean (average) of interior orientation residual vector length
      double m_residualMax;
      void ReadSampleRates(QString filename);

      //! Standard deviation of interior orientation residual vector length
      double m_residualStdev;
      std::vector<SampleRateChange> p_sampleRates;

      //! CK "Camera Matrix" kernel frame ID
      int m_CkFrameId;
      int m_ckFrameId;
    };
};

+21 −17
Original line number Diff line number Diff line
@@ -14,9 +14,9 @@ namespace Isis {
   * This method sets cube sample line coordinates from given Dector coordinates
   *
   * @param sample dector sample coordinate
   *
   * @param line detector line coordinate
   *
   * @return bool Always returns true
   */
    bool ApolloPanoramicDetectorMap::SetDetector(const double sample, const double line) {
      //given a detector coordinate and a time (read from the 'parent' camera class) 
@@ -28,11 +28,11 @@ namespace Isis {
      p_detectorSample = -sample;

      //convert from detector to fiducial coordinants
      double fidL = (p_camera->time().Et() - m_etMiddle)/m_lineRate;
//      double fidL = (p_camera->time().Et() - m_etMiddle)/m_lineRate;
      //double fidS = sample;  //conversion is identity so it is skiped

      //convert from fiducial coordinates to parent image coordinates
      p_intOri.image2Machine(p_detectorSample, fidL, &p_parentSample, &p_parentLine);
//      p_intOri.image2Machine(p_detectorSample, fidL, &p_parentSample, &p_parentLine);

      //cout << "fiducial values sent to IO: " << p_detectorSample << " " << fidL << endl; //debug
      //cout << "cube coordinates returned from IO: " << p_parentSample << " " << p_parentLine << endl;
@@ -43,9 +43,9 @@ namespace Isis {
   * This method sets dector sample line coordinates from given cube coordinates
   *
   * @param sample cube sample coordinate
   *
   * @param line cube line coordinate
   *
   * @return bool Always returns true
   */
    bool ApolloPanoramicDetectorMap::SetParent(const double sample, const double line) {
      //Given an image (aka 'Parent', aka encoder, aka machine) coordinate set the detector 
@@ -56,7 +56,7 @@ namespace Isis {
      //convert from machine to fiducial coordinates
      //cout << "cube coordinates sent to IO: " << sample << " " << line << endl; //debug
    
      p_intOri.machine2Image(sample,line,&p_detectorSample, &p_detectorLine);
//      p_intOri.machine2Image(sample,line,&p_detectorSample, &p_detectorLine);

      //cout << "fiducial coordinate return from IO: " << p_detectorSample << " " << p_detectorLine << endl;
      //convert from fiducial coordinates to detector/time coordinates
@@ -77,13 +77,17 @@ namespace Isis {
     * This method uses the ApolloPanIO class to compute transforamtion from cube to image 
     * (aka fiducial cooraintes)
     *
     * @throws  IException::User "No FID_MEASURES table found in cube blobs."
     * @throws  IException::User "Less than four FID_MEASURES found in cube blobs."
     * @throws  IException::User "Insufficient Fiducial Observations for computation of the interior
     *                            orientation. At least one vertical pair must be measured, many 
     *                            more is recomented."
     * @return -1 failure
     *
     * @return  1 sucess
     * 
     * @returns int Returns 1 on success and -1 on failure.
     * @throws  No FID_MEASURES table found in cube blobs.
     *
     * @throws  Less than four FID_MEASURES found in cube blobs.
     *
     * @throws  Insufficient Fiducial Observations for computation of 
     *          the interior orientation.\nAt least one vertical pair 
     *          must be measured, many more is recomented.
     */
    int ApolloPanoramicDetectorMap::initializeInteriorOrientation() {
      int i,nrec;
@@ -104,13 +108,13 @@ namespace Isis {
                         _FILEINFO_);
        return -1;
      }
      p_intOri.initialize();

      for(i=0;i<nrec;i++)  //input all the observations to the the Interior Orientation Class
        p_intOri.fiducialObservation(tableFid[i][0], tableFid[i][1], tableFid[i][2]);
//      p_intOri.initialize();

      i = p_intOri.computeInteriorOrienation();
//      for(i=0;i<nrec;i++)  //input all the observations to the the Interior Orientation Class
//        p_intOri.fiducialObservation(tableFid[i][0], tableFid[i][1], tableFid[i][2]);

//      i = p_intOri.computeInteriorOrienation();
      i = 1;
      if( i != 1) { //unsuccessful computation of the interior orienation
        throw IException(IException::User,"Insufficient Fiducial Observations for computation of "
                                          "the interior orientation.\nAt least one vertical pair "
+20 −36
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
 */                                                                       


#include "ApolloPanIO.h"
//#include "ApolloPanIO.h"
#include "LineScanCameraDetectorMap.h"
#include "Pvl.h"
#include "PvlGroup.h"
@@ -43,7 +43,6 @@ namespace Isis {
     * @internal                                                              
     *   @history 2011-11-21 Orrin Thomas - Original version
     *   @history 2012-07-10 Orrin Thomas - Updated to current coding standards
     *   @history 2017-06-28 Makayla Shepherd - Updated documentation. References #4807.
     */        
    class ApolloPanoramicDetectorMap : public CameraDetectorMap {
    public:
@@ -66,7 +65,7 @@ namespace Isis {
      }

      //! Destroys ApolloPanoramicDetectorMap object
      virtual ~ApolloPanoramicDetectorMap() {};
//      virtual ~ApolloPanoramicDetectorMap() {};

      virtual bool SetParent(const double sample, const double line);

@@ -79,52 +78,37 @@ namespace Isis {
       *
       * @param lineRate the time in seconds between lines
       *
       * @return void
       */
      void SetLineRate(const double lineRate) {
        m_lineRate = lineRate;
      };

      /**
       * Return the time in seconds between scan lines
       * 
       * @return double Time in seconds between scan lines
       */
      //! Return the time in seconds between scan lines
      double LineRate() const {
        return m_lineRate;
      };

      /**
       * Mean (average) of interior orientation residual vector lengths, accesor
       * 
       * @return double Mean of interior orientation residual vector lengths
       */
      double  meanResidual() { return p_intOri.meanResiduals(); };
      //! Mean (average) of interior orientation residual vector lengths, accesor
//      double  meanResidual() { return p_intOri.meanResiduals(); };

      /**
       * Max interior orientation residual vector length, accesor
       * 
       * @return double Max interior orientation residual vector length
       */
      double   maxResidual() { return p_intOri.maxResiduals(); };
      //! Max interior orientation residual vector length, accesor
//      double   maxResidual() { return p_intOri.maxResiduals(); };

      /**
       * Standard deviation of interior orientation residual vector lengths, accesor
       * 
       * @return double Standard deviation of interior orientation residual vector lengths
       */
      double stdevResidual() { return p_intOri.stdevResiduals(); };
      //! Standard deviation of interior orientation residual vector lengths, accesor
//      double stdevResidual() { return p_intOri.stdevResiduals(); };

      private:
        //! Ephemeris time at the middle line
        double m_etMiddle;  

        double m_etMiddle; //!< Ephemeris time at the middle line 
        double m_lineRate; //!< line exposure duration
        Pvl *m_lab;        //!< Image label used to construct camera object
        //!line exposure duration
        double m_lineRate;

        /**
         * Class to preform transformations from cube coordiantes to image coordinates
         */
        ApolloPanIO p_intOri;
        //! Image label used to construct camera object    
        Pvl *m_lab;

        //! Class to preform transformations from cube coordiantes to image coordinates
//        ApolloPanIO p_intOri;

        int initializeInteriorOrientation();
    };
+5 −5
Original line number Diff line number Diff line
Group = Apollo15/Apollo_Pan
  Library = ApolloPanoramicCamera
Group = Apollo15/Pan
  Library = ./ApolloPanoramicCamera
  Routine = ApolloPanoramicCameraPlugin
  Version = 1
  Version = 2
EndGroup
Group = Apollo16/Apollo_Pan
Group = Apollo16/Pan
  Library = ApolloPanoramicCamera
  Routine = ApolloPanoramicCameraPlugin
  Version = 1
EndGroup
Group = Apollo17/Apollo_Pan
Group = Apollo17/Pan
  Library = ApolloPanoramicCamera
  Routine = ApolloPanoramicCameraPlugin
  Version = 1
Loading