Unverified Commit e74144bb authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

added cnet fixture (#3680)

* added cnet fixture

* removed filelist

* update as per comments

* updated docs

* typo
parent 2874acf6
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ namespace Isis {
   *
   * @param fileName Name of the cube file to open. Environment
   *     variables in the filename will be automatically expanded.
   * @param label PVL label to use when initializing cube 
   * @param label PVL label object representing the new Cube label
   * @param access Defines how the cube will be opened. Either read-only
   *     "r" or read-write "rw".
   */
@@ -106,8 +106,8 @@ namespace Isis {
   *
   * @param fileName Name of the cube file to open. Environment
   *     variables in the filename will be automatically expanded.
   * @param label PVL label to use when initializing cube 
   * @param isd Ale compatible ISD to be used for initing spice data
   * @param label PVL label object representing the new Cube label  
   * @param isd JSON object containing Ale compatible ISD
   * @param access Defines how the cube will be opened. Either read-only
   *     "r" or read-write "rw".
   */
@@ -119,6 +119,29 @@ namespace Isis {
    open(fileName.toString(), access);
  }
  
  /**
   * Initialize Cube data from a PVL label and JSON ISD.
   *
   * @param fileName Name of the cube file to open. Environment
   *     variables in the filename will be automatically expanded.
   * @param labelFile Path to PVL label representing the new Cube label
   * @param isdPath Path to Ale compatible ISD
   * @param access Defines how the cube will be opened. Either read-only
   *     "r" or read-write "rw".
   */
  void Cube::fromIsd(const FileName &fileName, FileName &labelFile, FileName &isdFile, QString access) {
    std::ifstream isdStream(isdFile.expanded().toStdString());
    std::ifstream labelStream(labelFile.expanded().toStdString());
    
    Pvl label;
    nlohmann::json isd;
    
    isdStream >> isd;
    labelStream >> label;
    
    fromIsd(fileName, label, isd, access);
    reopen("rw");  
  }

  //! Destroys the Cube object.
  Cube::~Cube() {
+2 −0
Original line number Diff line number Diff line
@@ -238,6 +238,8 @@ namespace Isis {
      };

      void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access);
      void fromIsd(const FileName &fileName, FileName &labelFile, FileName &isdFile, QString access);

      void fromLabel(const FileName &fileName, Pvl &label, QString access);

      bool isOpen() const;
+0 −2
Original line number Diff line number Diff line
@@ -63,10 +63,8 @@ QString buildRow(SerialNumberList &serials, QString sn, set<QString> &cps);
QString buildRow(SerialNumberList &serials, QString sn, double value);
void outputRow(ofstream &outStream, QString rowText);


QString g_delimiter;


// Main program
void IsisMain() {
  Progress progress;
+52 −190
Original line number Diff line number Diff line
@@ -2,203 +2,65 @@

namespace Isis {

  void TestCube::SetUp() {
    std::istringstream labelStrm(R"(
        Object = IsisCube
          Object = Core
            StartByte   = 65537
            Format      = Tile
            TileSamples = 128
            TileLines   = 128
            Group = Dimensions
              Samples = 1204
              Lines   = 1056
              Bands   = 1
            End_Group
            Group = Pixels
              Type       = UnsignedByte
              ByteOrder  = Lsb
              Base       = 0.0
              Multiplier = 1.0
            End_Group
          End_Object
          Group = Instrument
            SpacecraftName       = VIKING_ORBITER_1
            InstrumentId         = VISUAL_IMAGING_SUBSYSTEM_CAMERA_B
            TargetName           = MARS
            StartTime            = 1977-07-09T20:05:51
            ExposureDuration     = 0.008480 <seconds>
            SpacecraftClockCount = 33322515
            FloodModeId          = ON
            GainModeId           = HIGH
            OffsetModeId         = ON
          End_Group
          Group = Archive
            DataSetId       = VO1/VO2-M-VIS-2-EDR-V2.0
            ProductId       = 387A06
            MissonPhaseName = EXTENDED_MISSION
            ImageNumber     = 33322515
            OrbitNumber     = 387
          End_Group
          Group = BandBin
            FilterName = CLEAR
            FilterId   = 4
          End_Group
          Group = Kernels
            NaifFrameCode             = -27002
            LeapSecond                = $base/kernels/lsk/naif0012.tls
            TargetAttitudeShape       = $base/kernels/pck/pck00009.tpc
            TargetPosition            = (Table, $base/kernels/spk/de430.bsp,
                                         $base/kernels/spk/mar097.bsp)
            InstrumentPointing        = (Table, $viking1/kernels/ck/vo1_sedr_ck2.bc,
                                         $viking1/kernels/fk/vo1_v10.tf)
            Instrument                = Null
            SpacecraftClock           = ($viking1/kernels/sclk/vo1_fict.tsc,
                                         $viking1/kernels/sclk/vo1_fsc.tsc)
            InstrumentPosition        = (Table, $viking1/kernels/spk/viking1a.bsp)
            InstrumentAddendum        = $viking1/kernels/iak/vikingAddendum003.ti
            ShapeModel                = $base/dems/molaMarsPlanetaryRadius0005.cub
            InstrumentPositionQuality = Reconstructed
            InstrumentPointingQuality = Reconstructed
            CameraVersion             = 1
          End_Group
          Group = Reseaus
            Line     = (5, 6, 8, 9, 10, 11, 12, 13, 14, 14, 15, 133, 134, 135, 137,
                        138, 139, 140, 141, 141, 142, 143, 144, 263, 264, 266, 267,
                        268, 269, 269, 270, 271, 272, 273, 393, 393, 395, 396, 397,
                        398, 399, 399, 400, 401, 402, 403, 523, 524, 525, 526, 527,
                        527, 528, 529, 530, 530, 532, 652, 652, 654, 655, 656, 657,
                        657, 658, 659, 660, 661, 662, 781, 783, 784, 785, 786, 787,
                        788, 788, 789, 790, 791, 911, 912, 913, 914, 915, 916, 917,
                        918, 918, 919, 920, 921, 1040, 1041, 1043, 1044, 1045, 1045,
                        1046, 1047, 1047, 1048, 1050)
            Sample   = (24, 142, 259, 375, 491, 607, 723, 839, 954, 1070, 1185, 24,
                        84, 201, 317, 433, 549, 665, 780, 896, 1011, 1127, 1183, 25,
                        142, 259, 375, 492, 607, 722, 838, 953, 1068, 1183, 25, 84,
                        201, 317, 433, 549, 665, 779, 895, 1010, 1125, 1182, 25, 143,
                        259, 375, 491, 607, 722, 837, 952, 1067, 1182, 25, 84, 201,
                        317, 433, 548, 664, 779, 894, 1009, 1124, 1181, 25, 142, 258,
                        374, 490, 605, 720, 835, 951, 1066, 1180, 24, 83, 200, 316,
                        431, 547, 662, 776, 892, 1007, 1122, 1179, 23, 140, 257, 373,
                        488, 603, 718, 833, 948, 1063, 1179)
            Type     = (1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
                        5, 6, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 5, 5, 5,
                        5, 5, 5, 6, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 5,
                        5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5,
                        5, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6)
            Valid    = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
            Template = $viking1/reseaus/vo1.visb.template.cub
            Status   = Nominal
          End_Group
        End_Object
      End
      )");

    labelStrm >> label;

    testIsd = json::parse(R"(
      {"CameraVersion": 2,
         "NaifKeywords": {
              "BODY_CODE" : 499,
              "BODY499_RADII" : [3396.19, 3396.19, 3376.2],
              "BODY_FRAME_CODE" : 10014,
              "CLOCK_ET_-27999_33322515_COMPUTED" : "d5b9203a4d24c5c1",
              "INS-27002_TRANSX" : [0.0, 0.011764705882353, 0.0],
              "INS-27002_TRANSY" : [0.0, 0.0, 0.01176470588235],
              "INS-27002_ITRANSS" : [0.0, 85.0, 0.0],
              "INS-27002_ITRANSL" : [0.0, 0.0, 85.0]
        },
      "InstrumentPointing": {
        "TimeDependentFrames": [-85600, -85000, 1],
        "CkTableStartTime": 100,
        "CkTableEndTime": 100.1,
        "CkTableOriginalSize": 2,
        "EphemerisTimes": [
          100,
          100.1
        ],
        "Quaternions": [
          [0.0, -0.660435174378928, 0, 0.750883067090392],
          [0.0, -0.660435174378928, 0, 0.750883067090392]
        ],
        "AngularVelocity": [
          [0, 0, 0],
          [0, 0, 0]
        ],
        "ConstantFrames": [-85600],
        "ConstantRotation": [1, 0, 0, 0, 1, 0, 0, 0, 1]
      },
      "BodyRotation": {
        "TimeDependentFrames": [31006, 1],
        "CkTableStartTime": 100,
        "CkTableEndTime": 100.1,
        "CkTableOriginalSize": 2,
        "EphemerisTimes": [
          100,
          100.1
        ],
        "Quaternions": [
          [ 0, 0.8509035, 0, 0.525322 ],
          [ 0, 0.8509035, 0, 0.525322 ]
        ],
        "AngularVelocity": [
          [0, 0, 0],
          [0, 0, 0]
        ],
        "ConstantFrames": [31001, 31007, 31006],
        "ConstantRotation": [-0.4480736,  0,  0.8939967, 0,  1,  0, -0.8939967,  0, -0.4480736]
      },
      "InstrumentPosition": {
        "SpkTableStartTime": 100,
        "SpkTableEndTime": 100.1,
        "SpkTableOriginalSize": 2,
        "EphemerisTimes": [
          100,
          100.1
        ],
        "Positions": [
          [1000, 0, 0],
          [1000, 0, 0]
        ],
        "Velocities": [
          [0, 0, 0],
          [0, 0, 0]
        ]
      },
      "SunPosition": {
        "SpkTableStartTime": 100,
        "SpkTableEndTime": 100.1,
        "SpkTableOriginalSize": 2,
        "EphemerisTimes": [
          100,
          100.1
        ],
        "Positions": [
          [0, 20, 0]
        ],
        "Velocities": [
          [10,10,10]
        ]
      }
    })");

    // call constructor
    Cube testCube;
  void DefaultCube::SetUp() {
    std::ifstream isdFile("data/defaultImage/defaultCube.isd");
    std::ifstream cubeLabel("data/defaultImage/defaultCube.pvl");
    
    testCube.fromIsd(tempFile.fileName() + ".cub", label, testIsd, "rw");
    isdFile >> isd;
    cubeLabel >> label;

    // reopen to write out new data 
    testCube.reopen("rw");
    testCube->fromIsd(tempFile.fileName() + ".cub", label, isd, "rw");
  }

  void TestCube::TearDown() {

  void DefaultCube::TearDown() {
    if (testCube->isOpen()) {
      testCube->close();
    }
  }


  void ThreeImageNetwork::SetUp() {
    FileName labelPath1("data/threeImageNetwork/cube1.pvl");
    FileName labelPath2("data/threeImageNetwork/cube2.pvl");
    FileName labelPath3("data/threeImageNetwork/cube3.pvl");

    FileName isdPath1("data/threeImageNetwork/cube1.isd");
    FileName isdPath2("data/threeImageNetwork/cube2.isd");
    FileName isdPath3("data/threeImageNetwork/cube3.isd");
    
    cube1 = new Cube();
    cubeTempPath1.open();
    cube1->fromIsd(cubeTempPath1.fileName() + ".cub", labelPath1, isdPath1, "rw");

    cube2 = new Cube();
    cubeTempPath2.open();
    cube2->fromIsd(cubeTempPath2.fileName() + ".cub", labelPath2, isdPath2, "rw");

    cube3 = new Cube();
    cubeTempPath3.open();
    cube3->fromIsd(cubeTempPath3.fileName() + ".cub", labelPath3, isdPath3, "rw");

    cubeList = new FileList();
    cubeList->append(cube1->fileName());
    cubeList->append(cube2->fileName());
    cubeList->append(cube3->fileName());

    cubeListTempPath.open();
    cubeList->write(cubeListTempPath.fileName());
    
    network = new ControlNet();
    network->ReadControl("data/threeImageNetwork/controlnetwork.net");
  }
  

  void ThreeImageNetwork::TearDown() {
    delete cube1;
    delete cube2;
    delete cube3;

    delete cubeList;
    delete network;

  }
}
+25 −2
Original line number Diff line number Diff line
@@ -16,22 +16,45 @@
#include "Cube.h"
#include "Pvl.h"
#include "PvlObject.h"
#include "ControlNet.h"
#include "FileList.h"

using json = nlohmann::json;

namespace Isis {

   class TestCube : public ::testing::Test {
   class DefaultCube : public ::testing::Test {
      protected:
        Cube *testCube;
        QTemporaryFile tempFile;

        Pvl label;
        json testIsd;
        json isd;

        void SetUp() override;
        void TearDown() override;
   };


   class ThreeImageNetwork : public ::testing::Test {
      protected:
        
        ControlNet *network; 

        Cube *cube1;
        Cube *cube2;
        Cube *cube3;
        
        FileList *cubeList; 

        QTemporaryFile cubeTempPath1;
        QTemporaryFile cubeTempPath2;
        QTemporaryFile cubeTempPath3;
        QTemporaryFile cubeListTempPath; 

        void SetUp() override;
        void TearDown() override;
   };
}

#endif
Loading