diff --git a/isis/src/base/objs/IrregularBodyCameraGroundMap/IrregularBodyCameraGroundMap.h b/isis/src/base/objs/IrregularBodyCameraGroundMap/IrregularBodyCameraGroundMap.h index 8771a43c6a..a2c4c57274 100644 --- a/isis/src/base/objs/IrregularBodyCameraGroundMap/IrregularBodyCameraGroundMap.h +++ b/isis/src/base/objs/IrregularBodyCameraGroundMap/IrregularBodyCameraGroundMap.h @@ -19,7 +19,7 @@ namespace Isis { * This class is derived from CameraGroundMap to support the special case of * irregular bodies. Particularly, only the GetXY() method is reimplemented * here to never perform the "emission angle" (in places called "back-of-the- - * planet") test. This is because the test uses the ellipsoidd to validate + * planet") test. This is because the test uses the ellipsoid to validate * ground point visibility along the look vector to the surface. This is not * adequate for most irregular bodies. * diff --git a/isis/src/base/objs/IrregularBodyCameraGroundMap/unitTest.cpp b/isis/src/base/objs/IrregularBodyCameraGroundMap/unitTest.cpp deleted file mode 100644 index d29f6a0a31..0000000000 --- a/isis/src/base/objs/IrregularBodyCameraGroundMap/unitTest.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "Preference.h" - -using namespace std; -int main() { - Isis::Preference::Preferences(true); - cout << "This class will be tested by the applications and the individual Camera models." << endl; -} diff --git a/isis/src/osirisrex/objs/OsirisRexTagcamsCamera/unitTest.cpp b/isis/src/osirisrex/objs/OsirisRexTagcamsCamera/unitTest.cpp deleted file mode 100644 index 3476893cab..0000000000 --- a/isis/src/osirisrex/objs/OsirisRexTagcamsCamera/unitTest.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/** This is free and unencumbered software released into the public domain. - -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -#include -#include - -#include "Camera.h" -#include "CameraFactory.h" -#include "IException.h" -#include "iTime.h" -#include "OsirisRexTagcamsCamera.h" -#include "Preference.h" -#include "Pvl.h" -#include "PvlGroup.h" - -using namespace std; -using namespace Isis; - -void testCamera(Cube &c, double sample, double line, double knownLat, double knownLon); -void testLineSamp(Camera *cam, double sample, double line); - -/** - * OSIRIS-REx Tagcams Camera model unit test for instruments NAVCam, NFTCam - * (and perhaps someday, StowCam). - * - * @author 2024-03-01 Ken Edmundson - * @internal - * @history 2024-03-01 Ken Edmundson - Initial version. - * - */ - -int main(void) { - Preference::Preferences(true); - - cout << "Unit Test for OsirisRexTagcamsCamera..." << endl; - try { - cout << "\nTesting NAVCam (backwards compatibility)..." << endl; - Cube navCube(FileName("$ISISROOT/../isis/tests/data/osirisRexImages/20200303T213031S138_ncm_L0-reduced.cub").expanded(), "r"); - - // checking at center of format of NavCam - double knownLat = 49.7487786981275; - double knownLon = 43.7549667753273; - double sample = 129.5; - double line = 97.0; - - testCamera(navCube, sample, line, knownLat, knownLon); - cout << "============================================================================" << endl; - - cout << "\nTesting NFTCam (backwards compatibility)..." << endl; - Cube nftCube(FileName("$ISISROOT/../isis/tests/data/osirisRexImages/20201020T214241S004_nft_L0-reduced.cub").expanded(), "r"); - - // checking at center of format of NftCam - knownLat = 53.7314045659365; - knownLon = 45.4736806050086; - sample = 129.5; - line = 97.0; - - testCamera(nftCube, sample, line, knownLat, knownLon); - cout << "============================================================================" << endl; - - // TODO: COMPLETE IF/WHEN NAIF HAS PROVIDED KERNELS FOR STOWCAM. CURRENT IK IS LABELED AS - // PLACEHOLDER ONLY. - - cout << "\nTesting StowCam (backwards compatibility)..." << endl; - cout << "\nTODO: COMPLETE IF/WHEN NAIF KERNELS AVAILABLE; CURRENT IK IS PLACEHOLDER." << endl; -/* - Cube stowCube(placeholder, "r"); - knownLat = 0.0; - knownLon = 0.0; - sample = 1296.0; - line = 972.0; - testCamera(stowCube, sample, line, knownLat, knownLon); -*/ - cout << "============================================================================" << endl; - } - catch (IException &e) { - cout << "Failed unitTest." << endl; - e.print(); - } -} - -void testCamera(Cube &cube, - double sample, double line, - double knownLat, double knownLon) { - - OsirisRexTagcamsCamera *cam = (OsirisRexTagcamsCamera *) CameraFactory::Create(cube); - cout << "FileName: " << FileName(cube.fileName()).name() << endl; - cout << "NAIF Frame ID: " << cam->instrumentRotation()->Frame() << endl << endl; - cout.setf(std::ios::fixed); - cout << setprecision(9); - - // Test kernel IDs - cout << "Kernel IDs: " << endl; - cout << "CK Frame ID = " << cam->CkFrameId() << endl; - cout << "CK Reference ID = " << cam->CkReferenceId() << endl; - cout << "SPK Target ID = " << cam->SpkTargetId() << endl; - cout << "SPK Reference ID = " << cam->SpkReferenceId() << endl << endl; - - // Test name methods - cout << "Spacecraft Name Long: " << cam->spacecraftNameLong() << endl; - cout << "Spacecraft Name Short: " << cam->spacecraftNameShort() << endl; - cout << "Instrument Name Long: " << cam->instrumentNameLong() << endl; - cout << "Instrument Name Short: " << cam->instrumentNameShort() << endl << endl; - - // Test Shutter Open/Close - const PvlGroup &inst = cube.label()->findGroup("Instrument", Pvl::Traverse); - double exposureDuration = ((double) inst["ExposureDuration"])/1000; - QString stime = inst["StartTime"]; - double et; // StartTime keyword is the center exposure time - str2et_c(stime.toLatin1().data(), &et); - pair shuttertimes = cam->ShutterOpenCloseTimes(et, exposureDuration); - cout << "Shutter open = " << shuttertimes.first.Et() << endl; - cout << "Shutter close = " << shuttertimes.second.Et() << endl << endl; - - // Test all four corners to make sure the conversions are right - cout << "For upper left corner ..." << endl; - testLineSamp(cam, 1.0, 1.0); - - cout << "For upper right corner ..." << endl; -// testLineSamp(cam, 2596.0, 1.0); - testLineSamp(cam, 259.0, 1.0); - - cout << "For lower left corner ..." << endl; -// testLineSamp(cam, 1.0, 1944.0); - testLineSamp(cam, 1.0, 194.0); - - cout << "For lower right corner ..." << endl; -// testLineSamp(cam, 2596.0, 1944.0); - testLineSamp(cam, 259.0, 194.0); - - cout << "For known pixel position (" << sample << ", " << line << "..." << endl; - if (!cam->SetImage(sample, line)) { - throw IException(IException::Unknown, "ERROR setting image to known position.", _FILEINFO_); - } - if (abs(cam->UniversalLatitude() - knownLat) < 6E-14) { - cout << "Latitude OK" << endl; - } - else { - cout << setprecision(16) << "Latitude off by: " << cam->UniversalLatitude() - knownLat << endl; - } - if (abs(cam->UniversalLongitude() - knownLon) < 6E-14) { - cout << "Longitude OK" << endl; - } - else { - cout << setprecision(16) << "Longitude off by: " << cam->UniversalLongitude() - knownLon << endl; - } -} - - -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) < 0.001) deltaSamp = 0.0; - if (fabs(deltaLine) < 0.001) deltaLine = 0.0; - cout << "DeltaSample = " << deltaSamp << endl; - cout << "DeltaLine = " << deltaLine << endl << endl; - } - else { - cout << "DeltaSample = NO INTERSECTION" << endl; - cout << "DeltaLine = NO INTERSECTION" << endl << endl; - } -} - diff --git a/isis/tests/UnitTestOsirisRexTagCams.cpp b/isis/tests/UnitTestOsirisRexTagCams.cpp new file mode 100644 index 0000000000..0ab3f9d31f --- /dev/null +++ b/isis/tests/UnitTestOsirisRexTagCams.cpp @@ -0,0 +1,179 @@ +#include "OsirisRexTagcamsCamera.h" + +#include "iTime.h" +#include "TempFixtures.h" +#include "TestUtilities.h" + +#include + +using namespace Isis; +using namespace std; + +/** + * Osiris-REx TagCams NAVCam unit test. + * + * Tests ... + * - back and forth between sample/line and Universal Lat/Lon + * + */ +TEST_F(TempTestingFiles, UnitTestOsirisRexTagCamsNAVCam) { + + QString cubeFileName = "data/osirisRexImages/20200303T213031S138_ncm_L0-reduced.cub"; + Cube navCube(cubeFileName); + + OsirisRexTagcamsCamera *cam = (OsirisRexTagcamsCamera *)navCube.camera(); + + // Test kernel IDs + EXPECT_EQ(cam->CkFrameId(), -64000); + EXPECT_EQ(cam->CkReferenceId(), 1); + EXPECT_EQ(cam->SpkTargetId(), -64); + EXPECT_EQ(cam->SpkReferenceId(), 1); + + // Test names and instrument id + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameLong(), "OSIRIS-REx"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameShort(), "OSIRIS-REx"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameLong(), "Primary Optical Navigation (NCM) Camera"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameShort(), "NAVCam"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentId(), "NAVCam"); + + // Test Shutter Open/Close + const PvlGroup &inst = navCube.label()->findGroup("Instrument", Pvl::Traverse); + double exposureDuration = ((double) inst["ExposureDuration"])/1000; + QString stime = inst["StartTime"]; + double et; // StartTime keyword is the center exposure time + str2et_c(stime.toLatin1().data(), &et); + pair shuttertimes = cam->ShutterOpenCloseTimes(et, exposureDuration); + EXPECT_NEAR(shuttertimes.first.Et(), 636543100.32342994, 6E-14); + EXPECT_NEAR(shuttertimes.second.Et(), 636543100.32343423, 6E-14); + + // test at center of format + EXPECT_TRUE(cam->SetImage(129.5, 97.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 49.7487786981275, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 43.7549667753273, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 129.5, 0.01); + EXPECT_NEAR(cam->Line(), 97.0, 0.01); + + // test at upper left corner + EXPECT_TRUE(cam->SetImage(1.0, 1.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 18.614472228664749, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 30.4388285538537, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 1.0, 0.01); + EXPECT_NEAR(cam->Line(), 1.0, 0.01); + + // test at upper right corner + EXPECT_TRUE(cam->SetImage(259.0, 1.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 36.692323846663946, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 81.774178147101267, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 259.0, 0.01); + EXPECT_NEAR(cam->Line(), 1.0, 0.01); + + // test at lower left corner + EXPECT_TRUE(cam->SetImage(1.0, 194.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 44.70914449416866, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 1.6058653718226457, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 1.0, 0.01); + EXPECT_NEAR(cam->Line(), 194.0, 0.01); + + // test at lower right corner + EXPECT_TRUE(cam->SetImage(259.0, 194.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 71.210706457717208, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 82.189907756214126, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 259.0, 0.01); + EXPECT_NEAR(cam->Line(), 194.0, 0.01); +} + + +/** + * Osiris-REx TagCams NAVCam unit test. + * + * Tests ... + * - back and forth between sample/line and Universal Lat/Lon + * + */ +TEST_F(TempTestingFiles, UnitTestOsirisRexTagCamsNFTCam) { + + QString cubeFileName = "data/osirisRexImages/20201020T214241S004_nft_L0-reduced.cub"; + Cube cube(cubeFileName); + + OsirisRexTagcamsCamera *cam = (OsirisRexTagcamsCamera *)cube.camera(); + + // Test kernel IDs + EXPECT_EQ(cam->CkFrameId(), -64000); + EXPECT_EQ(cam->CkReferenceId(), 1); + EXPECT_EQ(cam->SpkTargetId(), -64); + EXPECT_EQ(cam->SpkReferenceId(), 1); + + // Test names and instrument id + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameLong(), "OSIRIS-REx"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameShort(), "OSIRIS-REx"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameLong(), "Natural Feature Tracking (NFT) Camera"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameShort(), "NFTCam"); + EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentId(), "NFTCam"); + + // checking at center of format of NftCam + EXPECT_TRUE(cam->SetImage(129.5, 97.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 53.7314045659365, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 45.4736806050086, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 129.5, 0.01); + EXPECT_NEAR(cam->Line(), 97.0, 0.01); + + // test at upper left corner + EXPECT_TRUE(cam->SetImage(1.0, 1.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 53.74996008837919, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 44.87991851142592, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 1.0, 0.01); + EXPECT_NEAR(cam->Line(), 1.0, 0.01); + + // test at upper right corner + EXPECT_TRUE(cam->SetImage(259.0, 1.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 53.45070519515528, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 45.595734037697831, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 259.0, 0.01); + EXPECT_NEAR(cam->Line(), 1.0, 0.01); + + // test at lower left corner + EXPECT_TRUE(cam->SetImage(1.0, 194.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 54.251546951663194, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 45.249110941406045, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 1.0, 0.01); + EXPECT_NEAR(cam->Line(), 194.0, 0.01); + + // test at lower right corner + EXPECT_TRUE(cam->SetImage(259.0, 194.0)); + EXPECT_NEAR(cam->UniversalLatitude(), 53.714109526681277, 0.0001); + EXPECT_NEAR(cam->UniversalLongitude(), 46.006871961761462, 0.0001); + + EXPECT_TRUE(cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude())); + EXPECT_NEAR(cam->Sample(), 259.0, 0.01); + EXPECT_NEAR(cam->Line(), 194.0, 0.01); +} + + +/** + * Osiris-REx TagCams StowCam unit test. + * + * TODO: COMPLETE IF/WHEN NAIF HAS PROVIDED KERNELS FOR STOWCAM. + * CURRENT IK IS LABELED AS PLACEHOLDER ONLY. + * + * Tests ... + * - back and forth between sample/line and Universal Lat/Lon + * + */ \ No newline at end of file