Unverified Commit b03abdb6 authored by Tim Giroux's avatar Tim Giroux Committed by GitHub
Browse files

EIS wac camera model gtest (#4554)

* eis wac camera model gtest

* remove old test
parent 38755662
Loading
Loading
Loading
Loading
+1 −1
Changes for isis/src/clipper/objs/ClipperWacFcCamera/ClipperWacFcCamera.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ namespace Isis {
       * @return @b int The appropriate instrument code for the "Camera-matrix"
       *         Kernel Frame ID
       */
      virtual int CkFrameId() const { return (-159011); }
      virtual int CkFrameId() const { return (-159104); }


      /**
−31

File deleted.

−136

File deleted.

+69
Changes for isis/tests/ClipperWacFcCameraTests.cpp: 69 added lines, 0 removed lines.
Original line number Diff line number Diff line
#include <gtest/gtest.h>
#include "Fixtures.h"
#include "Camera.h"
#include "CameraFactory.h"
#include "Cube.h"
#include "ClipperWacFcCamera.h"
#include "IException.h"
#include "iTime.h"
#include "TestUtilities.h"

using namespace Isis;

void TestLineSamp(Camera *cam, double samp, double line) {
  bool success = cam->SetImage(samp, line);
  EXPECT_TRUE(success);

  if(success) {
    success = cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude());
  }
  EXPECT_TRUE(success);

  if(success) {
    EXPECT_NEAR(samp, cam->Sample(), 1.1e-2);
    EXPECT_NEAR(line, cam->Line(), 1.0e-2);
  }
}


TEST_F(ClipperWacFcCube, ClipperWacFcCameraUnitTest) {
  ClipperWacFcCamera *cam;
  try {
    cam = (ClipperWacFcCamera *) CameraFactory::Create(*wacFcCube);
  } catch(IException &e) {
    FAIL() << "Unable to create ClipperWacFcCamera" << std::endl;
  }

  // Camera info
  //EXPECT_EQ(cam->instrumentRotation()->Frame(), -27002);    // from the defaultcube isd
  EXPECT_EQ(cam->CkFrameId(), -159104);
  EXPECT_EQ(cam->CkReferenceId(), 1);
  EXPECT_EQ(cam->SpkTargetId(), -159);
  EXPECT_EQ(cam->SpkReferenceId(), 1);
  EXPECT_NEAR(cam->FocalLength(), 150.402, 1e-4);

  EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameLong(), "Europa Clipper");
  EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->spacecraftNameShort(), "Clipper");
  EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameLong(), "Europa Imaging System Framing Wide Angle Camera");
  EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameShort(), "EIS-FWAC");

  
  // Check SetImage on corners
  int line, samp, nline, nsamp;
  line = 1.0;     samp = 1.0;
  nline = 1203.0; nsamp = 1055.0;
  TestLineSamp(cam, line, samp);
  TestLineSamp(cam, line, nsamp);
  TestLineSamp(cam, nline, nsamp);
  TestLineSamp(cam, nline, samp);


  // Simple test for ClipperWacFcCamera::ShutterOpenCloseTimes
  PvlGroup &inst = label.findGroup("Instrument", Pvl::Traverse);
  QString startTime = inst["StartTime"];
  iTime etStart(startTime);

  std::pair<iTime, iTime> startStop;
  startStop = cam->ShutterOpenCloseTimes(etStart.Et(), 0.00005);  // dummy value for exposure duration
  EXPECT_TRUE(startStop.first.Et() < startStop.second.Et());
}
+53 −1
Changes for isis/tests/Fixtures.cpp: 53 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1551,6 +1551,59 @@ namespace Isis {
    }
  }

  void ClipperWacFcCube::SetUp() {
    TempTestingFiles::SetUp();

    // Use defaultCube label and isd for now
    std::ifstream isdFile("data/defaultImage/defaultCube.isd");
    std::ifstream cubeLabel("data/defaultImage/defaultCube.pvl");
    isdFile >> isd;
    cubeLabel >> label;
    
    // Define WAC cube
    wacFcCube = new Cube();
    FileName wacFn(tempDir.path() + "/ClipperWAC.cub");
    wacFcCube->fromIsd(wacFn, label, isd, "rw");

    PvlGroup &wacKernels = wacFcCube->label()->findObject("IsisCube").findGroup("Kernels");
    wacKernels.findKeyword("NaifFrameCode").setValue("-159104");

      // Instruments Group
    PvlGroup &realWacInst = wacFcCube->label()->findObject("IsisCube").findGroup("Instrument");
    std::istringstream newWacInst(R"(
      Group = Instrument
        SpacecraftName            = Clipper
        InstrumentId              = EIS-WAC-FC
        TargetName                = Europa
        StartTime                 = 2025-01-01T00:00:00.000
      End_Group
    )");
    PvlGroup newWacInstPvl; newWacInst >> newWacInstPvl;
    realWacInst = newWacInstPvl;

      // NaifKeywords Group
    PvlObject &realWacNk = wacFcCube->label()->findObject("NaifKeywords");
    std::istringstream newWacNk(R"(
        INS-159104_FOCAL_LENGTH = 150.40199
        INS-159104_PIXEL_PITCH  = 0.014
        INS-159104_TRANSX       = (0.0, 0.014004651, 0.0)
        INS-159104_TRANSY       = (0.0, 0.0, 0.01399535)
        INS-159104_ITRANSS      = (0.0, 71.404849, 0.0)
        INS-159104_ITRANSL      = (0.0, 0.0, 71.4523)
      End_Object
    )");
    PvlObject newWacNkPvl; newWacNk >> newWacNkPvl;
    realWacNk = newWacNkPvl;

    wacFcCube->reopen("rw");
  }

  void ClipperWacFcCube::TearDown() {
    if (wacFcCube) {
      delete wacFcCube;
    }
  }

  void ClipperNacRsCube::SetUp() {
    DefaultCube::SetUp();

@@ -1610,5 +1663,4 @@ namespace Isis {
      delete testCube;
    }
  }

}
Loading