diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c9320cdc5..9102c5d542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ release. - Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629) - Fixed SpiceClient to handle redirect requests. - Fixed jigsaw to default OUTADJUSTMENTH5 option to false and allow this feature to run on read-only images [#5700](https://github.com/DOI-USGS/ISIS3/issues/5700) - +- Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds [#5668](https://github.com/DOI-USGS/ISIS3/issues/5668) ## [9.0.0] - 09-25-2024 ### Added diff --git a/isis/src/base/objs/Cube/Cube.cpp b/isis/src/base/objs/Cube/Cube.cpp index c99fa50bef..6a3170da25 100644 --- a/isis/src/base/objs/Cube/Cube.cpp +++ b/isis/src/base/objs/Cube/Cube.cpp @@ -1510,6 +1510,26 @@ namespace Isis { this->write(sunTable); + if (isd.contains("line_scan_rate")) { + TableField ephTimeField("EphemerisTime", TableField::Double); + TableField expTimeField("ExposureTime", TableField::Double); + TableField lineStartField("LineStart", TableField::Integer); + + TableRecord timesRecord; + timesRecord += ephTimeField; + timesRecord += expTimeField; + timesRecord += lineStartField; + + Table timesTable("LineScanTimes", timesRecord); + for (size_t i = 0; i < isd["line_scan_rate"].size(); ++i) { + timesRecord[0] = isd["line_scan_rate"][i][1].get(); + timesRecord[1] = isd["line_scan_rate"][i][2].get(); + timesRecord[2] = isd["line_scan_rate"][i][0].get(); + timesTable += timesRecord; + } + this->write(timesTable); + } + PvlGroup currentKernels = this->group("Kernels"); Pvl *label = this->label(); @@ -1529,7 +1549,9 @@ namespace Isis { // Access the camera here while all of the kernels are still loaded. // This needs to be done for some cameras that need loaded spice data // to actually create the camera model. (KaguyaTC for example) + std::cout << "before_camera\n"; this->camera(); + std::cout << "after_camera\n"; } diff --git a/isis/src/mex/objs/HrscCamera/HrscCamera.cpp b/isis/src/mex/objs/HrscCamera/HrscCamera.cpp index 07c7140087..a46d6c15f5 100644 --- a/isis/src/mex/objs/HrscCamera/HrscCamera.cpp +++ b/isis/src/mex/objs/HrscCamera/HrscCamera.cpp @@ -42,12 +42,12 @@ namespace Isis { SetPixelPitch(0.007); instrumentRotation()->SetFrame(-41210); + ReadLineRates(cube); + // Get required keywords from instrument group Pvl &lab = *cube.label(); PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); - ReadLineRates(lab.fileName()); - // Setup detector map for transform of image pixels to detector position new VariableLineScanCameraDetectorMap(this, p_lineRates); DetectorMap()->SetDetectorSampleSumming(inst["Summing"]); @@ -119,14 +119,22 @@ namespace Isis { /** - * @param filename + * @param cube */ - void HrscCamera::ReadLineRates(QString filename) { - Table timesTable("LineScanTimes", filename); + void HrscCamera::ReadLineRates(Cube &cube) { + Table timesTable("LineScanTimes"); + + // check if LineScanTimes was added from isd + if (cube.hasTable("LineScanTimes")) { + timesTable = cube.readTable("LineScanTimes"); + } + else { + timesTable = Table("LineScanTimes", cube.fileName()); + } if(timesTable.Records() <= 0) { QString msg = "Table [LineScanTimes] in ["; - msg += filename + "] must not be empty"; + msg += cube.fileName() + "] must not be empty"; throw IException(IException::Unknown, msg, _FILEINFO_); } @@ -138,7 +146,7 @@ namespace Isis { if(p_lineRates.size() <= 0) { QString msg = "There is a problem with the data within the Table "; - msg += "[LineScanTimes] in [" + filename + "]"; + msg += "[LineScanTimes] in [" + cube.fileName() + "]"; throw IException(IException::Unknown, msg, _FILEINFO_); } } diff --git a/isis/src/mex/objs/HrscCamera/HrscCamera.h b/isis/src/mex/objs/HrscCamera/HrscCamera.h index 4ae8794b58..db264e47b9 100644 --- a/isis/src/mex/objs/HrscCamera/HrscCamera.h +++ b/isis/src/mex/objs/HrscCamera/HrscCamera.h @@ -68,7 +68,7 @@ namespace Isis { virtual int SpkReferenceId() const; private: - void ReadLineRates(QString filename); + void ReadLineRates(Cube &cube); std::vector p_lineRates; /**< Vector of the variable line rates for this camera model.*/ diff --git a/isis/tests/CubeTests.cpp b/isis/tests/CubeTests.cpp index 7f14bb1c92..c04eac3867 100644 --- a/isis/tests/CubeTests.cpp +++ b/isis/tests/CubeTests.cpp @@ -270,6 +270,546 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) { EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameLong(), "Visual Imaging Subsystem Camera B"); } +TEST(CubeTest, TestCubeAttachSpiceFromHrscIsd) { + std::istringstream labelStrm(R"( + Object = IsisCube + Object = Core + StartByte = 65537 + Format = Tile + TileSamples = 322 + TileLines = 368 + + Group = Dimensions + Samples = 1288 + Lines = 15088 + Bands = 1 + End_Group + + Group = Pixels + Type = Real + ByteOrder = Lsb + Base = 0.0 + Multiplier = 1.0 + End_Group + End_Object + + Group = Instrument + SpacecraftName = "MARS EXPRESS" + InstrumentId = HRSC + StartTime = 2008-02-08T12:08:53.843 + StopTime = 2008-02-08T12:12:10.561 + SpacecraftClockStartCount = 1/0150552525.07284 + SpacecraftClockStopCount = 1/0150552792.64947 + MissionPhaseName = ME_Phase_11 + TargetName = Mars + Summing = 4 + FocalPlaneTemperature = 7.9716 + LensTemperature = 8.1755 + InstrumentTemperature = 11.0301 + End_Group + + Group = Archive + DataSetId = MEX-M-HRSC-3-RDR-V2.0 + DetectorId = MEX_HRSC_IR + EventType = MARS-REGIONAL-MAPPING-Vo-Te-Im + OrbitNumber = 5270 + ProductId = H5270_0000_IR2.IMG + End_Group + + Group = BandBin + Width = 81.0 + Center = 955.5 + End_Group + + Group = Kernels + NaifIkCode = -41218 + 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, + $mex/kernels/ck/ATNM_MEASURED_080101_090101_V- + 03.BC, $mex/kernels/fk/MEX_V16.TF) + Instrument = $mex/kernels/ik/MEX_HRSC_V09.TI + SpacecraftClock = $mex/kernels/sclk/MEX_220705_STEP.TSC + InstrumentPosition = (Table, + $mex/kernels/spk/ORMM__080201000000_00474.BSP) + InstrumentAddendum = $mex/kernels/iak/hrscAddendum004.ti + ShapeModel = $base/dems/molaMarsPlanetaryRadius0005.cub + InstrumentPositionQuality = Reconstructed + InstrumentPointingQuality = Reconstructed + CameraVersion = 1 + Source = isis + End_Group + End_Object + + Object = Label + Bytes = 65536 + End_Object + + Object = Table + Name = LineScanTimes + StartByte = 77798913 + Bytes = 60 + Records = 3 + ByteOrder = Lsb + + Group = Field + Name = EphemerisTime + Type = Double + Size = 1 + End_Group + + Group = Field + Name = ExposureTime + Type = Double + Size = 1 + End_Group + + Group = Field + Name = LineStart + Type = Integer + Size = 1 + End_Group + End_Object + + Object = NaifKeywords + BODY_CODE = 499 + BODY499_RADII = (3396.19, 3396.19, 3376.2) + BODY_FRAME_CODE = 10014 + INS-41218_FOCAL_LENGTH = 174.82 + INS-41218_TRANSX = (0.016461898406507, -0.006999999322408, + 3.079982431615e-06) + INS-41218_TRANSY = (49.791792756805, 3.079982431615e-06, + 0.006999999322408) + INS-41218_ITRANSS = (-0.77805243343811, -142.85712902873, + 0.062856784318668) + INS-41218_ITRANSL = (-7113.1135971726, 0.062856784318668, + 142.85712902873) + INS-41218_BORESIGHT_SAMPLE = 2592.5 + INS-41218_BORESIGHT_LINE = 0.0 + End_Object + End + )"); + + json isd = json::parse(R"({ + "isis_camera_version": 1, + "image_lines": 15088, + "image_samples": 1288, + "name_platform": "MARS EXPRESS", + "name_sensor": "HIGH RESOLUTION STEREO CAMERA", + "reference_height": { + "maxheight": 1000, + "minheight": -1000, + "unit": "m" + }, + "name_model": "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL", + "interpolation_method": "lagrange", + "line_scan_rate": [ + [ + 0.5, + -98.35948351025581, + 0.012800790786743165 + ], + [ + 6665.5, + 98.34625607728958, + 0.013227428436279297 + ] + ], + "starting_ephemeris_time": 255744599.02748165, + "center_ephemeris_time": 255744697.38696516, + "radii": { + "semimajor": 3396.19, + "semiminor": 3376.2, + "unit": "km" + }, + "body_rotation": { + "time_dependent_frames": [ + 10014, + 1 + ], + "ck_table_start_time": 255744599.02748165, + "ck_table_end_time": 255744684.34504557, + "ck_table_original_size": 2, + "ephemeris_times": [ + 255744599.02748165, + 255744684.34504557 + ], + "quaternions": [ + [ + -0.6525755651775765, + -0.023151423894873242, + 0.3174415084303075, + -0.6876336466682659 + ], + [ + -0.654651809237426, + -0.02219145654977925, + 0.31751006120710407, + -0.6856572824309715 + ] + ], + "angular_velocities": [ + [ + 3.162398161513709e-05, + -2.8803031775991535e-05, + 5.6520727317788564e-05 + ], + [ + 3.162398161489585e-05, + -2.8803031778668454e-05, + 5.652072731655937e-05 + ] + ], + "reference_frame": 1 + }, + "instrument_pointing": { + "time_dependent_frames": [ + -41001, + 1 + ], + "ck_table_start_time": 255744599.02748165, + "ck_table_end_time": 255744684.34504557, + "ck_table_original_size": 3, + "ephemeris_times": [ + 255744599.02748165, + 255744684.33197814, + 255744684.34504557 + ], + "quaternions": [ + [ + -0.34147103254256284, + 0.4600620001156389, + -0.4826410643063962, + -0.662418367068051 + ], + [ + -0.3659838104244632, + 0.44394513387664625, + -0.4497912009709326, + -0.6831225689022163 + ], + [ + -0.3659874882249891, + 0.4439426152453299, + -0.4497860930062306, + -0.6831255985322837 + ] + ], + "angular_velocities": [ + [ + 0.0003517633111319437, + 0.001015465002260446, + 0.00038771759258420565 + ], + [ + 0.00035178320677913466, + 0.001008400741447663, + 0.0003885676589327302 + ], + [ + 0.0003517842276725049, + 0.0010084000654699077, + 0.00038856810918190424 + ] + ], + "reference_frame": 1, + "constant_frames": [ + -41210, + -41200, + -41000, + -41001 + ], + "constant_rotation": [ + -0.9999999844629888, + 1.027590578527487e-06, + 0.00017627525841189352, + 1.2246232944813223e-16, + -0.9999830090976747, + 0.00582936668603668, + 0.0001762782535384808, + 0.0058293665954657434, + 0.9999829935609271 + ] + }, + "naif_keywords": { + "BODY499_RADII": [ + 3396.19, + 3396.19, + 3376.2 + ], + "BODY_FRAME_CODE": 10014, + "BODY_CODE": 499, + "INS-41210_FOV_FRAME": "MEX_HRSC_HEAD", + "FRAME_-41210_NAME": "MEX_HRSC_HEAD", + "INS-41210_CK_TIME_TOLERANCE": 1.0, + "TKFRAME_-41210_AXES": [ + 1.0, + 2.0, + 3.0 + ], + "TKFRAME_-41210_SPEC": "ANGLES", + "FRAME_-41210_CLASS": 4.0, + "INS-41210_FOV_ANGULAR_SIZE": [ + 0.2, + 0.659734 + ], + "INS-41210_OD_K": [ + 0.0, + 0.0, + 0.0 + ], + "INS-41210_F/RATIO": 5.6, + "INS-41210_PLATFORM_ID": -41000.0, + "TKFRAME_-41210_ANGLES": [ + -0.334, + 0.0101, + 0.0 + ], + "INS-41210_SPK_TIME_BIAS": 0.0, + "FRAME_-41210_CENTER": -41.0, + "TKFRAME_-41210_UNITS": "DEGREES", + "INS-41210_BORESIGHT": [ + 0.0, + 0.0, + 175.0 + ], + "INS-41210_CK_TIME_BIAS": 0.0, + "FRAME_-41210_CLASS_ID": -41210.0, + "INS-41210_IFOV": 4e-05, + "INS-41210_FOV_BOUNDARY_CORNERS": [ + 18.187, + 60.0641, + 175.0, + 18.1281, + -60.0399, + 175.0, + -18.1862, + -60.0435, + 175.0, + -18.142 + ], + "INS-41210_FOV_SHAPE": "RECTANGLE", + "TKFRAME_-41210_RELATIVE": "MEX_HRSC_BASE", + "INS-41210_PIXEL_PITCH": 0.007, + "INS-41210_FOCAL_LENGTH": 175.0, + "BODY499_POLE_DEC": [ + 52.8865, + -0.0609, + 0.0 + ], + "BODY499_POLE_RA": [ + 317.68143, + -0.1061, + 0.0 + ], + "BODY499_PM": [ + 176.63, + 350.89198226, + 0.0 + ], + "INS-41218_ITRANSL": [ + -7113.11359717265, + 0.062856784318668, + 142.857129028729 + ], + "INS-41218_ITRANSS": [ + -0.778052433438109, + -142.857129028729, + 0.062856784318668 + ], + "INS-41218_FOV_SHAPE": "RECTANGLE", + "INS-41218_PIXEL_SIZE": [ + 7.0, + 7.0 + ], + "INS-41218_CK_REFERENCE_ID": 1.0, + "INS-41218_FOV_FRAME": "MEX_HRSC_HEAD", + "INS-41218_CCD_CENTER": [ + 2592.5, + 0.5 + ], + "INS-41218_CK_FRAME_ID": -41001.0, + "INS-41218_F/RATIO": 5.6, + "INS-41218_PIXEL_SAMPLES": 5184.0, + "INS-41218_BORESIGHT_SAMPLE": 2592.5, + "INS-41218_FILTER_BANDWIDTH": 90.0, + "INS-41218_BORESIGHT_LINE": 0.0, + "INS-41218_PIXEL_LINES": 1.0, + "INS-41218_FOCAL_LENGTH": 174.82, + "INS-41218_FOV_ANGULAR_SIZE": [ + 0.2, + 4e-05 + ], + "INS-41218_FILTER_BANDCENTER": 970.0, + "INS-41218_TRANSX": [ + 0.016461898406507, + -0.006999999322408, + 3.079982431615e-06 + ], + "INS-41218_TRANSY": [ + 49.7917927568053, + 3.079982431615e-06, + 0.006999999322408 + ], + "INS-41218_FOV_BOUNDARY_CORNERS": [ + 18.1982, + 49.9121, + 175.0, + 18.1982, + 49.9051, + 175.0, + -18.1693, + 49.8901, + 175.0, + -18.1693 + ], + "INS-41218_BORESIGHT": [ + 0.0151, + 49.9039, + 175.0 + ], + "INS-41218_IFOV": 4e-05 + }, + "detector_sample_summing": 4, + "detector_line_summing": 4, + "focal_length_model": { + "focal_length": 174.82 + }, + "detector_center": { + "line": 0.0, + "sample": 2592.0 + }, + "focal2pixel_lines": [ + -7113.11359717265, + 0.062856784318668, + 142.857129028729 + ], + "focal2pixel_samples": [ + -0.778052433438109, + -142.857129028729, + 0.062856784318668 + ], + "optical_distortion": { + "radial": { + "coefficients": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + "starting_detector_line": 0, + "starting_detector_sample": 0, + "instrument_position": { + "spk_table_start_time": 255744599.02748165, + "spk_table_end_time": 255744684.34504557, + "spk_table_original_size": 3, + "ephemeris_times": [ + 255744599.02748165, + 255744684.33197814, + 255744684.34504557 + ], + "positions": [ + [ + 3508.7678823246983, + -1180.0905763309427, + -404.65807247785085 + ], + [ + 3504.3243485204953, + -1050.5094345826292, + -743.2474663998983 + ], + [ + 3504.322049673533, + -1050.4890790873103, + -743.2990454930555 + ] + ], + "velocities": [ + [ + 0.07204007846693458, + 1.4787375689455564, + -3.9872650786018093 + ], + [ + -0.17588977444273826, + 1.5577275009096896, + -3.9471504887872113 + ], + [ + -0.17592754964964083, + 1.5577388421738825, + -3.947142539138405 + ] + ], + "reference_frame": 1 + }, + "sun_position": { + "spk_table_start_time": 255744599.02748165, + "spk_table_end_time": 255744684.34504557, + "spk_table_original_size": 2, + "ephemeris_times": [ + 255744599.02748165, + 255744684.34504557 + ], + "positions": [ + [ + 99136929.53828166, + -200428537.63629806, + -94608622.07352574 + ], + [ + 99138738.20092882, + -200427911.89904302, + -94608383.92687146 + ] + ], + "velocities": [ + [ + 21.199222172569485, + 7.334134527307004, + 2.791259509826079 + ], + [ + 21.199143743332474, + 7.334293076913804, + 2.791334350681398 + ] + ], + "reference_frame": 1 + } + })"); + + Pvl label; + labelStrm >> label; + + QTemporaryFile tempFile; + Cube testCube; + testCube.fromIsd(tempFile.fileName() + ".cub", label, isd, "rw"); + + PvlGroup kernels = testCube.group("Kernels"); + + EXPECT_TRUE(kernels.hasKeyword("InstrumentPointing")); + EXPECT_TRUE(kernels.hasKeyword("LeapSecond")); + EXPECT_TRUE(kernels.hasKeyword("TargetAttitudeShape")); + EXPECT_TRUE(kernels.hasKeyword("TargetPosition")); + EXPECT_TRUE(kernels.hasKeyword("InstrumentPointing")); + EXPECT_TRUE(kernels.hasKeyword("Instrument")); + EXPECT_TRUE(kernels.hasKeyword("SpacecraftClock")); + EXPECT_TRUE(kernels.hasKeyword("InstrumentPosition")); + EXPECT_TRUE(kernels.hasKeyword("InstrumentAddendum")); + EXPECT_TRUE(kernels.hasKeyword("ShapeModel")); + EXPECT_TRUE(kernels.hasKeyword("InstrumentPositionQuality")); + EXPECT_TRUE(kernels.hasKeyword("InstrumentPointingQuality")); + EXPECT_TRUE(kernels.hasKeyword("CameraVersion")); + + EXPECT_TRUE(testCube.hasTable("LineScanTimes")); + +} + TEST_F(SmallCube, TestCubeHasBlob) { Blob testBlob("TestBlob", "SomeBlob"); testCube->write(testBlob);