diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/Camera.plugin b/isis/src/kaguya/objs/KaguyaTcCamera/Camera.plugin new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.cpp b/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.cpp new file mode 100644 index 0000000000000000000000000000000000000000..810998bf1a2e3ef215f32062bd2bb786fefdcd35 --- /dev/null +++ b/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.cpp @@ -0,0 +1,155 @@ +/** + * @file + * + * 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 "KaguyaTcCamera.h" +#include "CameraDetectorMap.h" +#include "CameraDistortionMap.h" +#include "CameraFocalPlaneMap.h" +#include "CameraGroundMap.h" +#include "CameraSkyMap.h" + +#include <QString> +#include "IException.h" +#include "IString.h" +#include "iTime.h" +#include "NaifStatus.h" + +using namespace std; +namespace Isis { + /** + * Constructor for the Kaguya TC Camera Model + * + * @param lab Pvl Label to create the camera model from + * + * Data can be found in /work/projects/jaxa01 + * To unpack this data: + * 1. mv or cp filename.sl2 to filename.tar + * 2. tar xvf filename.tar + * 3. mv or cp filename.igz to filename.img.gz + * 4. gzip -d filename.img.gz + * 5. filename.img are the files to be imported using kaguyatc2isis + * + * @internal + * @history 2018-10-02 Adam Goins & Jeannie Backer - Original Version + */ + KaguyaTcCamera::KaguyaTcCamera(Cube &cube) : LineScanCamera(cube) { + m_instrumentNameLong = "Terrain Camera"; + m_instrumentNameShort = "TC"; + m_spacecraftNameLong = "Kaguya"; + m_spacecraftNameShort = "Kaguya"; + + QString msg = "Kaguya TC Camera is still under development."; + throw IException(IException::Programmer, msg, _FILEINFO_); + + NaifStatus::CheckErrors(); + // Get the camera characteristics + SetFocalLength(); + SetPixelPitch(); + + // Get the start time in et + Pvl &lab = *cube.label(); + PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse); + + // set variables startTime and exposureDuration + double time = iTime((QString)inst["StartTime"]).Et(); + + // divide exposure duration keyword value by 1000 to convert to seconds + double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0; + pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(time, exposureDuration); + // Add half exposure duration to get time at center of image + iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0; + + // Setup detector map + new CameraDetectorMap(this); + + // Setup focal plane map + CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); + + focalMap->SetDetectorOrigin( + Spice::getDouble("INS" + toString(naifIkCode()) + + "_BORESIGHT_SAMPLE"), + Spice::getDouble(0.5); + + // Setup distortion map + new CameraDistortionMap(this); + + // Setup the ground and sky map + new CameraGroundMap(this); + new CameraSkyMap(this); + + setTime(centerTime); + LoadCache(); + NaifStatus::CheckErrors(); + } + + /** + * @author 2018-10-02 Adam Goins & Jeannie Backer + * @internal + * @history 2018-10-02 Adam Goins & Jeannie Backer - Original version. + */ + pair<iTime, iTime> KaguyaTcCamera::ShutterOpenCloseTimes(double time, + double exposureDuration) { + return FramingCamera::ShutterOpenCloseTimes(time, exposureDuration); + } + + + /** + * CK frame ID - - Instrument Code from spacit run on CK + * + * @return @b int The appropriate instrument code for the "Camera-matrix" + * Kernel Frame ID + */ + int KaguyaTcCamera::CkFrameId() const { + return (-131000); + } + + /** + * CK Reference ID - J2000 + * + * @return @b int The appropriate instrument code for the "Camera-matrix" + * Kernel Reference ID + */ + int KaguyaTcCamera::CkReferenceId() const { + return (1); + } + + /** + * SPK Reference ID - J2000 + * + * @return @b int The appropriate instrument code for the Spacecraft + * Kernel Reference ID + */ + int KaguyaTcCamera::SpkReferenceId() const { + return (1); + } + +} + + +/** + * This is the function that is called in order to instantiate a KaguyaCamera + * object. + * + * @param lab Cube labels + * + * @return Isis::Camera* Kaguya + */ +extern "C" Isis::Camera *KaguyaTcCameraPlugin(Isis::Cube &cube) { + return new Isis::KaguyaTcCamera(cube); +} diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.h b/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.h new file mode 100644 index 0000000000000000000000000000000000000000..8caee2b5f292bff6b12f3a4d2baa39284c040dee --- /dev/null +++ b/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.h @@ -0,0 +1,42 @@ +#ifndef KaguyaTcCamera_h +#define KaguyaTcCamera_h +/** + * @file + * + * 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 "FramingCamera.h" + +namespace Isis { + + class KaguyaTcCamera : public LineScanCamera { + public: + KaguyaTcCamera(Cube &cube); + //! Destroys the KaguyaTcCamera object. + ~KaguyaTcCamera() {}; + virtual std::pair <iTime, iTime> ShutterOpenCloseTimes(double time, + double exposureDuration); + + virtual int CkFrameId() const; + virtual int CkReferenceId() const; + virtual int SpkReferenceId() const; + + + }; +}; +#endif diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.truth b/isis/src/kaguya/objs/KaguyaTcCamera/KaguyaTcCamera.truth new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/Makefile b/isis/src/kaguya/objs/KaguyaTcCamera/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f122bc88227c5c7ebd108dea5d339d1d2e074d82 --- /dev/null +++ b/isis/src/kaguya/objs/KaguyaTcCamera/Makefile @@ -0,0 +1,7 @@ +ifeq ($(ISISROOT), $(BLANK)) +.SILENT: +error: + echo "Please set ISISROOT"; +else + include $(ISISROOT)/make/isismake.objs +endif \ No newline at end of file diff --git a/isis/src/kaguya/objs/KaguyaTcCamera/unitTest.cpp b/isis/src/kaguya/objs/KaguyaTcCamera/unitTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..30e8b8628ac44ef147d481681f64a54184e70155 --- /dev/null +++ b/isis/src/kaguya/objs/KaguyaTcCamera/unitTest.cpp @@ -0,0 +1,148 @@ +/** + * @file + * + * 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 <QDebug> + +#include <iomanip> +#include <iostream> + +#include "Camera.h" +#include "CameraFactory.h" +#include "FileName.h" +#include "IException.h" +#include "iTime.h" +#include "Preference.h" +#include "Pvl.h" +#include "PvlGroup.h" +#include "KaguyaTcCamera.h" + +using namespace std; +using namespace Isis; + +void TestLineSamp(Camera *cam, double samp, double line); + +/** + * Unit test for Kaguya Tc Camera. + * + * @internal + * @history 2018-08-15 Jeannie Backer - Updated lat/lon changes due to + * changes in focal length. + */ +int main(void) { + Preference::Preferences(true); + + qDebug() << "Unit Test for KaguyaTcCamera..."; + try { + // These should be lat/lon at center of image. To obtain these numbers for a new cube/camera, + // set both the known lat and known lon to zero and copy the unit test output + // "Latitude off by: " and "Longitude off by: " values directly into these variables. + double knownLat = 0; // + double knownLon = 0; // + + Cube c("$tgo/testData/CAS-MCO-2016-11-22T16.38.39.354-NIR-02036-00.cub", "r"); + KaguyaTcCamera *cam = (KaguyaTcCamera *) CameraFactory::Create(c); + qDebug() << "FileName: " << FileName(c.fileName()).name(); + qDebug() << "CK Frame: " << cam->instrumentRotation()->Frame(); + qDebug() << ""; + + // Test kernel IDs + qDebug() << "Kernel IDs: "; + qDebug() << "CK Frame ID = " << cam->CkFrameId(); + qDebug() << "CK Reference ID = " << cam->CkReferenceId(); + qDebug() << "SPK Target ID = " << cam->SpkTargetId(); + qDebug() << "SPK Reference ID = " << cam->SpkReferenceId(); + qDebug() << ""; + + // Test Shutter Open/Close + const PvlGroup &inst = c.label()->findGroup("Instrument", Pvl::Traverse); + double exposureDuration = toDouble( inst["ExposureDuration"][0] ); + QString stime = inst["StartTime"]; + double et; + str2et_c(stime.toLatin1().data(), &et); + pair <iTime, iTime> shuttertimes = cam->ShutterOpenCloseTimes(et, exposureDuration); + qDebug() << qSetRealNumberPrecision(18) << "Shutter open = " << shuttertimes.first.Et(); + qDebug() << qSetRealNumberPrecision(18) << "Shutter close = " << shuttertimes.second.Et(); + qDebug() << qSetRealNumberPrecision(18) << "Focal Length = " << cam->FocalLength(); + qDebug() << ""; + + // Test all four corners to make sure the conversions are right + qDebug() << "For upper left corner ..."; + TestLineSamp(cam, 1.0, 1.0); + + qDebug() << "For upper right corner ..."; + TestLineSamp(cam, cam->Samples(), 1.0); + + qDebug() << "For lower left corner ..."; + TestLineSamp(cam, 1.0, cam->Lines()); + + qDebug() << "For lower right corner ..."; + TestLineSamp(cam, cam->Samples(), cam->Lines()); + + double samp = cam->Samples() / 2; + double line = cam->Lines() / 2; + qDebug() << "For center pixel position ..."; + + if(!cam->SetImage(samp, line)) { + qDebug() << "ERROR"; + return 0; + } + + if(abs(cam->UniversalLatitude() - knownLat) < 1E-13) { + qDebug() << "Latitude OK"; + } + else { + qDebug() << qSetRealNumberPrecision(18) + << "Latitude off by: " << cam->UniversalLatitude() - knownLat; + } + + if(abs(cam->UniversalLongitude() - knownLon) < 1E-11) { + qDebug() << "Longitude OK"; + } + else { + qDebug() << qSetRealNumberPrecision(18) + << "Longitude off by: " << cam->UniversalLongitude() - knownLon; + } + } + catch(IException &e) { + e.print(); + } +} + +void TestLineSamp(Camera *cam, double samp, double line) { + bool success = cam->SetImage(samp, line); + + if(success) { + success = cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude()); + } + + if(success) { + double deltaSamp = samp - cam->Sample(); + double deltaLine = line - cam->Line(); + if(fabs(deltaSamp) < 1.1e-2) deltaSamp = 0.0; + if(fabs(deltaLine) < 1.0e-2) deltaLine = 0.0; + qDebug() << "DeltaSample = " << deltaSamp; + qDebug() << "DeltaLine = " << deltaLine; + qDebug() << ""; + } + else { + qDebug() << "DeltaSample = ERROR"; + qDebug() << "DeltaLine = ERROR"; + qDebug() << ""; + } +}