Commit 922fa8b8 authored by Kristin's avatar Kristin Committed by Jesse Mapel
Browse files

Fixes failing Rosetta VIRTIS Camera Model test (#3355) (#3372)

* Update date and other metadata

* ckwriter_test_fix

* Fix unintentional cmakelists change

* Update Rosetta VIRTIS test to test the calibrated (level 3) data supported by the camera model and test both VIS and IR
parent 63a9f0dd
Loading
Loading
Loading
Loading
+47 −8
Original line number Diff line number Diff line
Unit Test for RosettaVirtisCamera...
FileName: I1_00237395857.cub

Teting Level 3 (Calibrated) VIRTIS-M-VIS Cube ...
FileName: V1_00388238556.cub
CK Frame: -226211

Kernel IDs: 
CK Frame ID = -226000
CK Reference ID = 1
SPK Target ID = -226
SPK Reference ID = 1

Spacecraft Name Long: Rosetta
Spacecraft Name Short: Rosetta
Instrument Name Long: Visual and Infrared Thermal Imaging Spectrometer
Instrument Name Short: VIRTIS

Start Time: 482889934.995558500
End Time:   482891995.079238355
For upper left corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For upper right corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For lower left corner ...
DeltaSample = 0.000000000
DeltaLine = -0.010806839

For lower right corner ...
DeltaSample = 0.000000000
DeltaLine = -0.011730711

For center pixel position ...
Latitude OK
Longitude OK

Teting Level 3 (Calibrated) VIRTIS-M-IR Cube ...
FileName: I1_00382172310.cub
CK Frame: -226213

Kernel IDs: 
@@ -13,23 +52,23 @@ Spacecraft Name Short: Rosetta
Instrument Name Long: Visual and Infrared Thermal Imaging Spectrometer
Instrument Name Short: VIRTIS

Start Time: 332047165.140102983
End Time:   332047289.497766495
Start Time: 476823679.937990844
End Time:   476825050.406471491
For upper left corner ...
DeltaSample = 0.000000000
DeltaLine = -0.262132577
DeltaLine = -0.038726648

For upper right corner ...
DeltaSample = 0.000000000
DeltaLine = -0.428036996
DeltaLine = -0.057422638

For lower left corner ...
DeltaSample = -0.030325205
DeltaLine = 1.142735209
DeltaSample = 0.000000000
DeltaLine = 1.101867835

For lower right corner ...
DeltaSample = 0.000000000
DeltaLine = 1.162544983
DeltaLine = 1.209474087

For center pixel position ...
Latitude OK
+87 −68
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ using namespace std;
using namespace Isis;

void TestLineSamp(Camera *cam, double samp, double line);
int TestCamera(Camera *cam, Cube c, double lines, double knownLat, double knownLon); 

/**
 *
@@ -44,6 +45,8 @@ void TestLineSamp(Camera *cam, double samp, double line);
 * @internal
 *   @history 2018-08-28 Kris Becker - Initial unit test for Rosetta VIRTIS
 *            instrument
 *   @history 2019-07-02 Krisitn Berry - Update to test only level 3 (calibrated) images, as only
 *            calibrated images are currently supported by the camera model. 
 */  
int main(void) {
  Preference::Preferences(true);
@@ -53,12 +56,29 @@ int main(void) {
    // 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 = -13.317366927129520;
    double knownLon = 125.530724158825336;
    double knownLat = 55.0877030799486249;
    double knownLon = 9.3721561274843133;

    cout << endl << "Teting Level 3 (Calibrated) VIRTIS-M-VIS Cube ..." << endl;
    Cube visCube("$ISIS3DATA/rosetta/testData/V1_00388238556.cub", "r");
    double lines = 100.0;
    RosettaVirtisCamera *cam = (RosettaVirtisCamera *) CameraFactory::Create(visCube);
    TestCamera(cam, visCube, lines, knownLat, knownLon);

    cout << endl << "Teting Level 3 (Calibrated) VIRTIS-M-IR Cube ..." << endl;
    knownLat = 29.1974649731145028;
    knownLon = 346.8749209987247468;
    lines = 67; 
    Cube irCube("$ISIS3DATA/rosetta/testData/I1_00382172310.cub", "r");
    RosettaVirtisCamera *cam2 = (RosettaVirtisCamera *) CameraFactory::Create(irCube);
    TestCamera(cam2, irCube, lines, knownLat, knownLon);
  }
  catch(IException &e) {
    e.print();
  }
}

    Cube c("$ISIS3DATA/rosetta/testData/I1_00237395857.cub", "r");
//    Cube c("./I1_00237395857.cub", "r");
    RosettaVirtisCamera *cam = (RosettaVirtisCamera *) CameraFactory::Create(c);
int TestCamera(Camera *cam, Cube c, double lines, double knownLat, double knownLon) {
  cout << "FileName: " << FileName(c.fileName()).name() << endl;
  cout << "CK Frame: " << cam->instrumentRotation()->Frame() << endl << endl;
  cout.setf(std::ios::fixed);
@@ -78,29 +98,31 @@ int main(void) {
  cout << "Instrument Name Short: " << cam->instrumentNameShort() << endl << endl;
  
  // Test Shutter Open/Close 
    //const PvlGroup &inst = p.findGroup("Instrument", Pvl::Traverse);
  std::pair< double, double > imgTimes = cam->StartEndEphemerisTimes();
  cout << "Start Time: " << imgTimes.first << "\n";
  cout << "End Time:   " << imgTimes.second << "\n";
  
  // Test all four corners to make sure the conversions are right
#if 1
    // Note - The limited data available at the time/scope this camera model
    // was developed (2017-08-28) does not fully support this test!!
  // For Rosetta, could not find images with the comet at all 4 corners, so these are 
  // actually corners of the comet, not the image. Values were chosen to approximate
  // the corners on two different images (VIS and IR). 
  
  // good.
  cout << "For upper left corner ..." << endl;
    TestLineSamp(cam, 119.0, 4.0);
  TestLineSamp(cam, 138.0, 10.0);
  
  cout << "For upper right corner ..." << endl;
    TestLineSamp(cam, 135.0, 4.0);
  TestLineSamp(cam, 165.0, 19.0);
  
  // fixme? 
  cout << "For lower left corner ..." << endl;
    TestLineSamp(cam, 122.0, 9.0);
  TestLineSamp(cam, 138.0, 55.0);
  
  cout << "For lower right corner ..." << endl;
    TestLineSamp(cam, 130.0, 9.0);
#endif
  TestLineSamp(cam, 130.0, 55.0);

  double samp = 128.0;
    double line = 8.0;
  double line = lines/2.0;
  cout << "For center pixel position ..." << endl;
  
  if(!cam->SetImage(samp, line)) {
@@ -121,10 +143,7 @@ int main(void) {
  else {
    cout << setprecision(16) << "Longitude off by: " << cam->UniversalLongitude() - knownLon << endl;
  }
  }
  catch(IException &e) {
    e.print();
  }
  return 0;
}

void TestLineSamp(Camera *cam, double samp, double line) {