Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ release. - Added TOVECT output parameter which generate a geospatial CSV file with a VRT metadata sidecar file [#5571](https://github.com/DOI-USGS/ISIS3/issues/5571) - Added Vectorize to ProcessGroundPolygon library - Added gtest files for the app and unit test - Added Chandrayaan2 template for isisimport ### Changed - Refactored the pixel2map app Loading isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl 0 → 100644 +96 −0 Original line number Diff line number Diff line {% set file_name = Product_Observational.File_Area_Observational.File.file_name %} {% set sensor = FindCH2Sensor(file_name) %} {% set ImageArray = Product_Observational.File_Area_Observational.Array_2D_Image %} Object = IsisCube Object = Core Group = Dimensions Samples = {{ ImageArray.Axis_Array.0.elements }} Lines = {{ ImageArray.Axis_Array.1.elements }} Bands = 1 End_Group Group = Pixels {% set pixelType = ImageArray.Element_Array.data_type %} {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.data_type") %} Type = {% if pixelType == "IEEE754LSBDouble" %} Double {% else if pixelType == "IEEE754LSBSingle" %} Real {% else if pixelType == "IEEE754MSBDouble" %} Double {% else if pixelType == "IEEE754MSBSingle" %} Real {% else if pixelType == "SignedByte" %} SignedByte {% else if pixelType == "SignedLSB2" %} SignedWord {% else if pixelType == "SignedLSB4" %} SignedInteger {% else if pixelType == "SignedMSB2" %} SignedWord {% else if pixelType == "SignedMSB4" %} SignedInteger {% else if pixelType == "UnsignedByte" %} UnsignedByte {% else if pixelType == "UnsignedLSB2" %} UnsignedWord {% else if pixelType == "UnsignedLSB4" %} UnsignedInteger {% else if pixelType == "UnsignedMSB2" %} UnsignedWord {% else if pixelType == "UnsignedMSB4" %} UnsignedInteger {% else %} Real {% endif %} ByteOrder = {% if pixelType == "IEEE754LSBDouble" %} LSB {% else if pixelType == "IEEE754LSBSingle" %} LSB {% else if pixelType == "IEEE754MSBDouble" %} MSB {% else if pixelType == "IEEE754MSBSingle" %} MSB {% else if pixelType == "SignedByte" %} LSB {% else if pixelType == "SignedLSB2" %} LSB {% else if pixelType == "SignedLSB4" %} LSB {% else if pixelType == "SignedMSB2" %} MSB {% else if pixelType == "SignedMSB4" %} MSB {% else if pixelType == "UnsignedByte" %} LSB {% else if pixelType == "UnsignedLSB2" %} LSB {% else if pixelType == "UnsignedLSB4" %} LSB {% else if pixelType == "UnsignedMSB2" %} MSB {% else if pixelType == "UnsignedMSB4" %} MSB {% else %} Lsb {% endif %} {% else %} Type = Real ByteOrder = Lsb {% endif %} Base = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.value_offset") %} {{ ImageArray.Element_Array.value_offset }} {% else if exists("Product_Observational.File_Area_Observational.Array_2D_Image.offset._text") %} {{ ImageArray.offset._text }} {% else %} 0 {% endif %} Multiplier = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor") %} {{ ImageArray.Element_Array.scaling_factor._text }} {% else %} 1 {% endif %} End_Group End_Object Group = Instrument SpacecraftName = {{ Product_Observational.Observation_Area.Investigation_Area.name }} {% set inst_name = Product_Observational.Observation_Area.Observing_System.Observing_System_Component.1.name %} {% if inst_name == "terrain mapping camera" %} InstrumentId = TMC-2 {% endif %} TargetName = {{ Product_Observational.Observation_Area.Target_Identification.name }} StartTime = {{ RemoveStartTimeZ(Product_Observational.Observation_Area.Time_Coordinates.start_date_time) }} StopTime = {{ RemoveStartTimeZ(Product_Observational.Observation_Area.Time_Coordinates.stop_date_time) }} End_Group Group = BandBin Center = 675 Width = 175 End_Group Group = Kernels NaifFrameCode = {% if sensor == "a" %}-152212 {% else if sensor == "f" %}-152211 {% else if sensor == "n" %}-152210 {% endif %} End_Group End_Object Object = Translation End_Object End isis/appdata/import/fileTemplate.tpl +5 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,11 @@ {%- if InstrumentId == "OSINAC" or InstrumentId == "OSIWAC"-%} {%- set InstrumentId="Osiris" -%} {%- endif -%} {%- else if SpacecraftName == "Chandrayaan-2"-%} {%- set SpacecraftId="Chandrayaan2" -%} {%- if InstrumentId == "terrain mapping camera"-%} {%- set InstrumentId="TMC2" -%} {%- endif -%} {%- endif -%} {#- Combine the pieces to output the file name to be used to import an image into a cube -#} Loading isis/src/base/apps/isisimport/isisimport.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,18 @@ namespace Isis { return inputString.substr(index, 1); }); /** * Find sensor type from Chandrayaan2 label's file_name */ env.add_callback("FindCH2Sensor", 1, [](Arguments& args) { std::string fileName = args.at(0)->get<string>(); char sensor = fileName[10]; return std::string(1, sensor); }); // end of inja callbacks Loading isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp 0 → 100644 +175 −0 Original line number Diff line number Diff line #include <iostream> #include <time.h> #include <QRegExp> #include <QString> #include <QTemporaryDir> #include <QTemporaryFile> #include <QFileInfo> #include <QDataStream> #include <QTextStream> #include <QByteArray> #include <QDataStream> #include <nlohmann/json.hpp> #include "TempFixtures.h" #include "Histogram.h" #include "md5wrapper.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" #include "TestUtilities.h" #include "isisimport.h" #include "gmock/gmock.h" using namespace Isis; using namespace testing; using json = nlohmann::json; static QString APP_XML = FileName("$ISISROOT/bin/xml/isisimport.xml").expanded(); TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2){ std::istringstream PvlInput(R"( Object = IsisCube Object = Core StartByte = 65537 Format = Tile TileSamples = 128 TileLines = 400 Group = Dimensions Samples = 17891 Lines = 400 Bands = 1 End_Group Group = Pixels Type = UnsignedByte ByteOrder = Lsb Base = 0.0 Multiplier = 1.0 End_Group End_Object Group = Instrument SpacecraftName = Chandrayaan-2 InstrumentId = TMC-2 TargetName = Moon StartTime = 2019-11-28T00:35:38.9755 StopTime = 2019-11-28T00:45:17.9161 End_Group Group = BandBin Center = 675 Width = 175 End_Group Group = Kernels NaifFrameCode = -152212 End_Group End_Object Object = Label Bytes = 65536 End_Object Object = History Name = IsisCube StartByte = 7233537 Bytes = 703 End_Object Object = OriginalXmlLabel Name = IsisCube StartByte = 7234240 Bytes = 4223 ByteOrder = Lsb End_Object End )"); QString dataFilePath= "data/isisimport/chan2/ch2_tmc_nca_20191128T0035389755_b_brw_d18.xml"; QString dataFileName = "ch2_tmc_nca_20191128T0035389755_b_brw_d18.xml"; QString imageFileName = "ch2_tmc_nca_20191128T0035389755_b_brw_d18.img"; QString cubeFileName = tempDir.path() + "/output.cub"; int samples = 400; int lines = 17891; int bytes = 2; // create a temp img file and write data to it QFile tempImgFile(tempDir.path() + "/" + imageFileName); if(!tempImgFile.open(QFile::WriteOnly | QFile::Text)){ FAIL() << " Could not open file for writing"; } QDataStream out(&tempImgFile); // generate lines QByteArray writeToFile = QByteArray(); short int fill = 0; for(int i=-1; i<(samples * bytes); i++){ writeToFile.append(fill); } // write the lines to the temp file for(int i=0; i<lines; i++){ QDataStream out(&tempImgFile); out << writeToFile; } tempImgFile.flush(); tempImgFile.close(); // create a temp data file and copy the contents of the xml in to it QFile tempDataFile(tempDir.path() + "/" + dataFileName); if(!tempDataFile.open(QFile::ReadWrite | QFile::Text)){ FAIL() << " Could not open file for writing"; } // open xml to get data QFile realXmlFile(dataFilePath); if (!realXmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) { FAIL() << "Failed to open file"; } QTextStream xmlData(&tempDataFile); xmlData << realXmlFile.readAll(); tempDataFile.close(); realXmlFile.close(); QFileInfo fileInfo(tempDataFile); // testing with template QVector<QString> args = {"from=" + fileInfo.absoluteFilePath(), "to=" + cubeFileName}; UserInterface options(APP_XML, args); isisimport(options); Pvl truthLabel; PvlInput >> truthLabel; Cube outCube(cubeFileName); Pvl *outLabel = outCube.label(); PvlGroup truthGroup = truthLabel.findGroup("Dimensions", Pvl::Traverse); PvlGroup &outGroup = outLabel->findGroup("Dimensions", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Pixels", Pvl::Traverse); outGroup = outLabel->findGroup("Pixels", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Instrument", Pvl::Traverse); outGroup = outLabel->findGroup("Instrument", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("BandBin", Pvl::Traverse); outGroup = outLabel->findGroup("BandBin", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Kernels", Pvl::Traverse); outGroup = outLabel->findGroup("Kernels", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); } No newline at end of file Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ release. - Added TOVECT output parameter which generate a geospatial CSV file with a VRT metadata sidecar file [#5571](https://github.com/DOI-USGS/ISIS3/issues/5571) - Added Vectorize to ProcessGroundPolygon library - Added gtest files for the app and unit test - Added Chandrayaan2 template for isisimport ### Changed - Refactored the pixel2map app Loading
isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl 0 → 100644 +96 −0 Original line number Diff line number Diff line {% set file_name = Product_Observational.File_Area_Observational.File.file_name %} {% set sensor = FindCH2Sensor(file_name) %} {% set ImageArray = Product_Observational.File_Area_Observational.Array_2D_Image %} Object = IsisCube Object = Core Group = Dimensions Samples = {{ ImageArray.Axis_Array.0.elements }} Lines = {{ ImageArray.Axis_Array.1.elements }} Bands = 1 End_Group Group = Pixels {% set pixelType = ImageArray.Element_Array.data_type %} {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.data_type") %} Type = {% if pixelType == "IEEE754LSBDouble" %} Double {% else if pixelType == "IEEE754LSBSingle" %} Real {% else if pixelType == "IEEE754MSBDouble" %} Double {% else if pixelType == "IEEE754MSBSingle" %} Real {% else if pixelType == "SignedByte" %} SignedByte {% else if pixelType == "SignedLSB2" %} SignedWord {% else if pixelType == "SignedLSB4" %} SignedInteger {% else if pixelType == "SignedMSB2" %} SignedWord {% else if pixelType == "SignedMSB4" %} SignedInteger {% else if pixelType == "UnsignedByte" %} UnsignedByte {% else if pixelType == "UnsignedLSB2" %} UnsignedWord {% else if pixelType == "UnsignedLSB4" %} UnsignedInteger {% else if pixelType == "UnsignedMSB2" %} UnsignedWord {% else if pixelType == "UnsignedMSB4" %} UnsignedInteger {% else %} Real {% endif %} ByteOrder = {% if pixelType == "IEEE754LSBDouble" %} LSB {% else if pixelType == "IEEE754LSBSingle" %} LSB {% else if pixelType == "IEEE754MSBDouble" %} MSB {% else if pixelType == "IEEE754MSBSingle" %} MSB {% else if pixelType == "SignedByte" %} LSB {% else if pixelType == "SignedLSB2" %} LSB {% else if pixelType == "SignedLSB4" %} LSB {% else if pixelType == "SignedMSB2" %} MSB {% else if pixelType == "SignedMSB4" %} MSB {% else if pixelType == "UnsignedByte" %} LSB {% else if pixelType == "UnsignedLSB2" %} LSB {% else if pixelType == "UnsignedLSB4" %} LSB {% else if pixelType == "UnsignedMSB2" %} MSB {% else if pixelType == "UnsignedMSB4" %} MSB {% else %} Lsb {% endif %} {% else %} Type = Real ByteOrder = Lsb {% endif %} Base = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.value_offset") %} {{ ImageArray.Element_Array.value_offset }} {% else if exists("Product_Observational.File_Area_Observational.Array_2D_Image.offset._text") %} {{ ImageArray.offset._text }} {% else %} 0 {% endif %} Multiplier = {% if exists("Product_Observational.File_Area_Observational.Array_2D_Image.Element_Array.scaling_factor") %} {{ ImageArray.Element_Array.scaling_factor._text }} {% else %} 1 {% endif %} End_Group End_Object Group = Instrument SpacecraftName = {{ Product_Observational.Observation_Area.Investigation_Area.name }} {% set inst_name = Product_Observational.Observation_Area.Observing_System.Observing_System_Component.1.name %} {% if inst_name == "terrain mapping camera" %} InstrumentId = TMC-2 {% endif %} TargetName = {{ Product_Observational.Observation_Area.Target_Identification.name }} StartTime = {{ RemoveStartTimeZ(Product_Observational.Observation_Area.Time_Coordinates.start_date_time) }} StopTime = {{ RemoveStartTimeZ(Product_Observational.Observation_Area.Time_Coordinates.stop_date_time) }} End_Group Group = BandBin Center = 675 Width = 175 End_Group Group = Kernels NaifFrameCode = {% if sensor == "a" %}-152212 {% else if sensor == "f" %}-152211 {% else if sensor == "n" %}-152210 {% endif %} End_Group End_Object Object = Translation End_Object End
isis/appdata/import/fileTemplate.tpl +5 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,11 @@ {%- if InstrumentId == "OSINAC" or InstrumentId == "OSIWAC"-%} {%- set InstrumentId="Osiris" -%} {%- endif -%} {%- else if SpacecraftName == "Chandrayaan-2"-%} {%- set SpacecraftId="Chandrayaan2" -%} {%- if InstrumentId == "terrain mapping camera"-%} {%- set InstrumentId="TMC2" -%} {%- endif -%} {%- endif -%} {#- Combine the pieces to output the file name to be used to import an image into a cube -#} Loading
isis/src/base/apps/isisimport/isisimport.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,18 @@ namespace Isis { return inputString.substr(index, 1); }); /** * Find sensor type from Chandrayaan2 label's file_name */ env.add_callback("FindCH2Sensor", 1, [](Arguments& args) { std::string fileName = args.at(0)->get<string>(); char sensor = fileName[10]; return std::string(1, sensor); }); // end of inja callbacks Loading
isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp 0 → 100644 +175 −0 Original line number Diff line number Diff line #include <iostream> #include <time.h> #include <QRegExp> #include <QString> #include <QTemporaryDir> #include <QTemporaryFile> #include <QFileInfo> #include <QDataStream> #include <QTextStream> #include <QByteArray> #include <QDataStream> #include <nlohmann/json.hpp> #include "TempFixtures.h" #include "Histogram.h" #include "md5wrapper.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" #include "TestUtilities.h" #include "isisimport.h" #include "gmock/gmock.h" using namespace Isis; using namespace testing; using json = nlohmann::json; static QString APP_XML = FileName("$ISISROOT/bin/xml/isisimport.xml").expanded(); TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2){ std::istringstream PvlInput(R"( Object = IsisCube Object = Core StartByte = 65537 Format = Tile TileSamples = 128 TileLines = 400 Group = Dimensions Samples = 17891 Lines = 400 Bands = 1 End_Group Group = Pixels Type = UnsignedByte ByteOrder = Lsb Base = 0.0 Multiplier = 1.0 End_Group End_Object Group = Instrument SpacecraftName = Chandrayaan-2 InstrumentId = TMC-2 TargetName = Moon StartTime = 2019-11-28T00:35:38.9755 StopTime = 2019-11-28T00:45:17.9161 End_Group Group = BandBin Center = 675 Width = 175 End_Group Group = Kernels NaifFrameCode = -152212 End_Group End_Object Object = Label Bytes = 65536 End_Object Object = History Name = IsisCube StartByte = 7233537 Bytes = 703 End_Object Object = OriginalXmlLabel Name = IsisCube StartByte = 7234240 Bytes = 4223 ByteOrder = Lsb End_Object End )"); QString dataFilePath= "data/isisimport/chan2/ch2_tmc_nca_20191128T0035389755_b_brw_d18.xml"; QString dataFileName = "ch2_tmc_nca_20191128T0035389755_b_brw_d18.xml"; QString imageFileName = "ch2_tmc_nca_20191128T0035389755_b_brw_d18.img"; QString cubeFileName = tempDir.path() + "/output.cub"; int samples = 400; int lines = 17891; int bytes = 2; // create a temp img file and write data to it QFile tempImgFile(tempDir.path() + "/" + imageFileName); if(!tempImgFile.open(QFile::WriteOnly | QFile::Text)){ FAIL() << " Could not open file for writing"; } QDataStream out(&tempImgFile); // generate lines QByteArray writeToFile = QByteArray(); short int fill = 0; for(int i=-1; i<(samples * bytes); i++){ writeToFile.append(fill); } // write the lines to the temp file for(int i=0; i<lines; i++){ QDataStream out(&tempImgFile); out << writeToFile; } tempImgFile.flush(); tempImgFile.close(); // create a temp data file and copy the contents of the xml in to it QFile tempDataFile(tempDir.path() + "/" + dataFileName); if(!tempDataFile.open(QFile::ReadWrite | QFile::Text)){ FAIL() << " Could not open file for writing"; } // open xml to get data QFile realXmlFile(dataFilePath); if (!realXmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) { FAIL() << "Failed to open file"; } QTextStream xmlData(&tempDataFile); xmlData << realXmlFile.readAll(); tempDataFile.close(); realXmlFile.close(); QFileInfo fileInfo(tempDataFile); // testing with template QVector<QString> args = {"from=" + fileInfo.absoluteFilePath(), "to=" + cubeFileName}; UserInterface options(APP_XML, args); isisimport(options); Pvl truthLabel; PvlInput >> truthLabel; Cube outCube(cubeFileName); Pvl *outLabel = outCube.label(); PvlGroup truthGroup = truthLabel.findGroup("Dimensions", Pvl::Traverse); PvlGroup &outGroup = outLabel->findGroup("Dimensions", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Pixels", Pvl::Traverse); outGroup = outLabel->findGroup("Pixels", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Instrument", Pvl::Traverse); outGroup = outLabel->findGroup("Instrument", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("BandBin", Pvl::Traverse); outGroup = outLabel->findGroup("BandBin", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); truthGroup = truthLabel.findGroup("Kernels", Pvl::Traverse); outGroup = outLabel->findGroup("Kernels", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); } No newline at end of file