diff --git a/isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl b/isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl index dd05ce68a7846f23144517c02bc6b8de9c6fcc17..102a7faca99a4d264d1f81ce75d3522c2b8c0cdd 100644 --- a/isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl +++ b/isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl @@ -1,5 +1,5 @@ {% set file_name = Product_Observational.File_Area_Observational.File.file_name %} -{% set sensor = FindCH2Sensor(file_name) %} +{% set sensor = CharAt(file_name, 10) %} {% set ImageArray = Product_Observational.File_Area_Observational.Array_2D_Image %} @@ -67,7 +67,7 @@ Object = IsisCube End_Object Group = Instrument - SpacecraftName = {{ Product_Observational.Observation_Area.Investigation_Area.name }} + SpacecraftName = {{ capitalize(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 @@ -75,7 +75,36 @@ Object = IsisCube 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) }} + {% if exists("Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_line_exposure_duration") %} + LineExposureDuration = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_line_exposure_duration._text }} + {% else %} + LineExposureDuration = 3.236 + {% endif %} + End_Group + + {% if exists("Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters") %} + Group = Archive + JobId = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_job_id }} + OrbitNumber = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_imaging_orbit_number }} + GainType = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_gain }} + ExposureType = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_exposure }} + DetectorPixelWidth = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_detector_pixel_width._text }} + FocalLength = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_focal_length._text }} + ReferenceData = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_reference_data_used }} + OrbitLimbDirection = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_orbit_limb_direction }} + SpacecraftYawDirection = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_spacecraft_yaw_direction }} + SpacecraftAltitude = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_spacecraft_altitude._text }} + PixelResolution = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_pixel_resolution._text }} + Roll = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_roll._text }} + Pitch = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_pitch._text }} + Yaw = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_yaw._text }} + SunAzimuth = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_sun_azimuth._text }} + SunElevation = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_sun_elevation._text }} + SolarIncidence = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_solar_incidence._text }} + Projection = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_projection }} + Area = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_area }} End_Group + {% endif %} Group = BandBin Center = 675 diff --git a/isis/appdata/import/fileTemplate.tpl b/isis/appdata/import/fileTemplate.tpl index 61db724210f8dad4477301a99ad9455fa008e7e1..6137b41300524e7a6c3a66cc10728cf12414922e 100644 --- a/isis/appdata/import/fileTemplate.tpl +++ b/isis/appdata/import/fileTemplate.tpl @@ -93,7 +93,7 @@ {%- if InstrumentId == "OSINAC" or InstrumentId == "OSIWAC"-%} {%- set InstrumentId="Osiris" -%} {%- endif -%} -{%- else if SpacecraftName == "Chandrayaan-2"-%} +{%- else if SpacecraftName == "Chandrayaan-2" or SpacecraftName == "chandrayaan-2"-%} {%- set SpacecraftId="Chandrayaan2" -%} {%- if InstrumentId == "terrain mapping camera"-%} {%- set InstrumentId="TMC2" -%} diff --git a/isis/src/base/apps/isisimport/isisimport.cpp b/isis/src/base/apps/isisimport/isisimport.cpp index 71f20d1b0571b6b0542525c05ffe658af4628172..2c6f2bfb6006a976a308c9ef6f8cb7c5e72e081e 100644 --- a/isis/src/base/apps/isisimport/isisimport.cpp +++ b/isis/src/base/apps/isisimport/isisimport.cpp @@ -341,18 +341,6 @@ 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(); - - char sensor = fileName[10]; - - return std::string(1, sensor); - }); // end of inja callbacks diff --git a/isis/src/base/objs/XmlToJson/XmlToJson.cpp b/isis/src/base/objs/XmlToJson/XmlToJson.cpp index 88471305be18c9215e89fd878a04fa1ca524917f..f41bc9afc186c8620d23c01c12f886a51ab4e480 100644 --- a/isis/src/base/objs/XmlToJson/XmlToJson.cpp +++ b/isis/src/base/objs/XmlToJson/XmlToJson.cpp @@ -207,5 +207,4 @@ namespace Isis { } return output; } -} - +} \ No newline at end of file diff --git a/isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp b/isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp index b95d506d43fbe165d96061586fdbf96c923bffb2..26f6cb34e5bdd136a894a01a3f32a4608550d353 100644 --- a/isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp +++ b/isis/tests/FunctionalTestsIsisImportChandrayaan2.cpp @@ -28,7 +28,7 @@ using json = nlohmann::json; static QString APP_XML = FileName("$ISISROOT/bin/xml/isisimport.xml").expanded(); -TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2){ +TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2MinimalLabel){ std::istringstream PvlInput(R"( Object = IsisCube Object = Core @@ -57,6 +57,7 @@ TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2){ TargetName = Moon StartTime = 2019-11-28T00:35:38.9755 StopTime = 2019-11-28T00:45:17.9161 + LineExposureDuration = 3.236 End_Group Group = BandBin @@ -172,4 +173,171 @@ TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2){ outGroup = outLabel->findGroup("Kernels", Pvl::Traverse); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); +} + +TEST_F(TempTestingFiles, FunctionalTestIsisImportChandrayaan2FullLabel){ + std::istringstream PvlInput(R"( + Object = IsisCube + Object = Core + StartByte = 65537 + Format = Tile + TileSamples = 519 + TileLines = 1000 + + Group = Dimensions + Samples = 180093 + Lines = 4000 + Bands = 1 + End_Group + + Group = Pixels + Type = UnsignedWord + ByteOrder = Lsb + Base = 0.0 + Multiplier = 1.0 + End_Group + End_Object + + Group = Instrument + SpacecraftName = Chandrayaan-2 + InstrumentId = TMC-2 + TargetName = Moon + StartTime = 2024-08-08T05:32:59.6974 + StopTime = 2024-08-08T05:42:42.4783 + LineExposureDuration = 3.236 + End_Group + + Group = Archive + JobId = TMCXXD18CHO2210300NNNN24221055326097_V2_1 + OrbitNumber = 22103 + GainType = g1 + ExposureType = e1 + DetectorPixelWidth = 7 + FocalLength = 140 + ReferenceData = SELENE + OrbitLimbDirection = Descending + SpacecraftYawDirection = False + SpacecraftAltitude = 89.53 + PixelResolution = 4.48 + Roll = 0.009365 + Pitch = 0.066417 + Yaw = -0.017284 + SunAzimuth = 116.737463 + SunElevation = 39.932493 + SolarIncidence = 50.067507 + Projection = Selenographic + Area = Equatorial + End_Group + + Group = BandBin + Center = 675 + Width = 175 + End_Group + + Group = Kernels + NaifFrameCode = -152210 + End_Group + End_Object + + Object = Label + Bytes = 65536 + End_Object + + Object = OriginalXmlLabel + Name = IsisCube + StartByte = 1440809537 + Bytes = 7625 + ByteOrder = Lsb + End_Object + End + )"); + QString dataFilePath= "data/isisimport/chan2/ch2_tmc_ncn_20240808T0532596974_d_img_d18.xml"; + QString dataFileName = "ch2_tmc_ncn_20240808T0532596974_d_img_d18.xml"; + QString imageFileName = "ch2_tmc_ncn_20240808T0532596974_d_img_d18.img"; + QString cubeFileName = tempDir.path() + "/output.cub"; + + int samples = 4000; + int lines = 180093; + 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 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); + + truthGroup = truthLabel.findGroup("Archive", Pvl::Traverse); + outGroup = outLabel->findGroup("Archive", Pvl::Traverse); + EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, outGroup, truthGroup); + } \ No newline at end of file diff --git a/isis/tests/XmlToJsonTests.cpp b/isis/tests/XmlToJsonTests.cpp index b20f60ffa10ec468c1f4ac4a814c54b001748c24..7db3e03eeb5977ae38d1f46d87d773e63be57071 100644 --- a/isis/tests/XmlToJsonTests.cpp +++ b/isis/tests/XmlToJsonTests.cpp @@ -293,3 +293,4 @@ TEST(XmlToJson, TestXMLWithNamespace) { } + diff --git a/isis/tests/data/isisimport/chan2/ch2_tmc_ncn_20240808T0532596974_d_img_d18.xml b/isis/tests/data/isisimport/chan2/ch2_tmc_ncn_20240808T0532596974_d_img_d18.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a6aa1c85ece9a235456366d7d4376858e1320c6 --- /dev/null +++ b/isis/tests/data/isisimport/chan2/ch2_tmc_ncn_20240808T0532596974_d_img_d18.xml @@ -0,0 +1,141 @@ + + + + urn:isro:isda:ch2_cho.tmc:data_calibrated:ch2_tmc_ncn_20240808t0532596974_d_img_d18 + 1.0 + Chandrayaan-2 Orbiter TMC2 Experiment + 1.11.0.0 + Product_Observational + + + 2019-05-07 + 1.0 + PDS4 product label created by SAC Optical DP Team + + + + + + 2024-08-08T05:32:59.6974Z + 2024-08-08T05:42:42.4783Z + + + Science + Calibrated + Calibrated Processing Level describes the radiometric correction (look up table) applied to the raw data + + + chandrayaan-2 + Mission + + urn:isro:isda:context:investigation:mission.chandrayaan2::1.0 + data_to_investigation + + + + + Chandrayaan 2 Orbiter + Spacecraft + + Chandrayaan-2 Orbiter is an Orbiter craft under the Chandrayaan-2 Spacecraft + consists of various scientific instruments. + + + + terrain mapping camera + Instrument + + TMC-2 (Terrain Mapping Camera) is one of the scientific instrument hosted + on the Chandrayaan-2 Orbiter. The instrument is passive electro-optical + imaging camera operating in visible-panchromatic band (500-800nm), + comprising three optical sensors Fore, Nadir and Aft placed with angles + of +25 deg, 0 deg and -25 deg to have three stereo views of the same target + as spacecraft moves along the track. + + + + + Moon + Satellite + Moon is a natural satellite of Earth + + + + TMCXXD18CHO2210300NNNN24221055326097_V2_1 + TMCXXD18CHO2210300NNNN24221055326097_V2_1 + 22103 + 22103 + 3.236 + g1 + e1 + 7 + 140 + SELENE + Descending + False + 89.53 + 4.48 + 0.009365 + 0.066417 + -0.017284 + 116.737463 + 39.932493 + 50.067507 + Selenographic + Equatorial + + + + 45.054183 + 95.360662 + 45.050300 + 96.171919 + 15.105121 + 95.128359 + 15.102485 + 95.740193 + + + 45.158521 + 95.350390 + 45.155106 + 96.174856 + 15.209056 + 95.155738 + 15.206454 + 95.776465 + + + + + + + ch2_tmc_ncn_20240808T0532596974_d_img_d18.img + 2024-08-25T12:10:25 + 1440744000 + bccc88b8394260ae5791ddecd2ebca90 + + This File contains the count calibrated image. + md5_checksum is provided for ensuring data integrity when users are downloading the data. + + + + 0 + 2 + Last Index Fastest + + UnsignedLSB2 + + + Line + 180093 + 1 + + + Sample + 4000 + 2 + + + + \ No newline at end of file