Skip to content

Commit 992df27

Browse files
Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds (#5705)
* in-progress-work * convert table back to isis * fix changelog * Addressed PR feedback
1 parent 0676eb6 commit 992df27

File tree

6 files changed

+576
-8
lines changed

6 files changed

+576
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ release.
4444
- Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629)
4545
- Fixed SpiceClient to handle redirect requests.
4646
- 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)
47+
- Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds [#5668](https://github.com/DOI-USGS/ISIS3/issues/5668)
4748

4849
## [9.0.0] - 09-25-2024
4950

isis/src/base/objs/Cube/Cube.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ namespace Isis {
9898
*/
9999
void Cube::fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access) {
100100
fromLabel(fileName, label, access);
101+
102+
PvlGroup &instGrp = label.findGroup("Instrument", Pvl::Traverse);
103+
if (isd.contains("line_scan_rate") && (QString)instGrp["InstrumentId"] == "HRSC") {
104+
attachLineScanTableFromIsd(isd);
105+
}
106+
101107
attachSpiceFromIsd(isd);
102108

103109
close();
@@ -1532,6 +1538,26 @@ namespace Isis {
15321538
this->camera();
15331539
}
15341540

1541+
void Cube::attachLineScanTableFromIsd(nlohmann::json isd) {
1542+
TableField ephTimeField("EphemerisTime", TableField::Double);
1543+
TableField expTimeField("ExposureTime", TableField::Double);
1544+
TableField lineStartField("LineStart", TableField::Integer);
1545+
1546+
TableRecord timesRecord;
1547+
timesRecord += ephTimeField;
1548+
timesRecord += expTimeField;
1549+
timesRecord += lineStartField;
1550+
1551+
Table timesTable("LineScanTimes", timesRecord);
1552+
for (size_t i = 0; i < isd["line_scan_rate"].size(); ++i) {
1553+
timesRecord[0] = isd["line_scan_rate"][i][1].get<double>() + isd["center_ephemeris_time"].get<double>();
1554+
timesRecord[1] = isd["line_scan_rate"][i][2].get<double>();
1555+
timesRecord[2] = (int)(isd["line_scan_rate"][i][0].get<double>() + 0.5);
1556+
timesTable += timesRecord;
1557+
}
1558+
this->write(timesTable);
1559+
}
1560+
15351561

15361562
/**
15371563
* If this is an external cube label file, this will give you the cube dn file that this label

isis/src/base/objs/Cube/Cube.h

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ namespace Isis {
245245
bool labelsAttached() const;
246246

247247
void attachSpiceFromIsd(nlohmann::json Isd);
248+
void attachLineScanTableFromIsd(nlohmann::json isd);
248249

249250
void close(bool remove = false);
250251
Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);

isis/src/mex/objs/HrscCamera/HrscCamera.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ namespace Isis {
4242
SetPixelPitch(0.007);
4343
instrumentRotation()->SetFrame(-41210);
4444

45+
ReadLineRates(cube);
46+
4547
// Get required keywords from instrument group
4648
Pvl &lab = *cube.label();
4749
PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
4850

49-
ReadLineRates(lab.fileName());
50-
5151
// Setup detector map for transform of image pixels to detector position
5252
new VariableLineScanCameraDetectorMap(this, p_lineRates);
5353
DetectorMap()->SetDetectorSampleSumming(inst["Summing"]);
@@ -119,14 +119,14 @@ namespace Isis {
119119

120120

121121
/**
122-
* @param filename
122+
* @param cube
123123
*/
124-
void HrscCamera::ReadLineRates(QString filename) {
125-
Table timesTable("LineScanTimes", filename);
124+
void HrscCamera::ReadLineRates(Cube &cube) {
125+
Table timesTable = cube.readTable("LineScanTimes");
126126

127127
if(timesTable.Records() <= 0) {
128128
QString msg = "Table [LineScanTimes] in [";
129-
msg += filename + "] must not be empty";
129+
msg += cube.fileName() + "] must not be empty";
130130
throw IException(IException::Unknown, msg, _FILEINFO_);
131131
}
132132

@@ -138,7 +138,7 @@ namespace Isis {
138138

139139
if(p_lineRates.size() <= 0) {
140140
QString msg = "There is a problem with the data within the Table ";
141-
msg += "[LineScanTimes] in [" + filename + "]";
141+
msg += "[LineScanTimes] in [" + cube.fileName() + "]";
142142
throw IException(IException::Unknown, msg, _FILEINFO_);
143143
}
144144
}

isis/src/mex/objs/HrscCamera/HrscCamera.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace Isis {
6868
virtual int SpkReferenceId() const;
6969

7070
private:
71-
void ReadLineRates(QString filename);
71+
void ReadLineRates(Cube &cube);
7272

7373
std::vector<LineRateChange> p_lineRates; /**< Vector of the variable line rates for this
7474
camera model.*/

0 commit comments

Comments
 (0)