Skip to content

Commit

Permalink
Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds (#5705)
Browse files Browse the repository at this point in the history
* in-progress-work

* convert table back to isis

* fix changelog

* Addressed PR feedback
  • Loading branch information
amystamile-usgs authored Jan 17, 2025
1 parent 0676eb6 commit 992df27
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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

Expand Down
26 changes: 26 additions & 0 deletions isis/src/base/objs/Cube/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ namespace Isis {
*/
void Cube::fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access) {
fromLabel(fileName, label, access);

PvlGroup &instGrp = label.findGroup("Instrument", Pvl::Traverse);
if (isd.contains("line_scan_rate") && (QString)instGrp["InstrumentId"] == "HRSC") {
attachLineScanTableFromIsd(isd);
}

attachSpiceFromIsd(isd);

close();
Expand Down Expand Up @@ -1532,6 +1538,26 @@ namespace Isis {
this->camera();
}

void Cube::attachLineScanTableFromIsd(nlohmann::json isd) {
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<double>() + isd["center_ephemeris_time"].get<double>();
timesRecord[1] = isd["line_scan_rate"][i][2].get<double>();
timesRecord[2] = (int)(isd["line_scan_rate"][i][0].get<double>() + 0.5);
timesTable += timesRecord;
}
this->write(timesTable);
}


/**
* If this is an external cube label file, this will give you the cube dn file that this label
Expand Down
1 change: 1 addition & 0 deletions isis/src/base/objs/Cube/Cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ namespace Isis {
bool labelsAttached() const;

void attachSpiceFromIsd(nlohmann::json Isd);
void attachLineScanTableFromIsd(nlohmann::json isd);

void close(bool remove = false);
Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
Expand Down
14 changes: 7 additions & 7 deletions isis/src/mex/objs/HrscCamera/HrscCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down Expand Up @@ -119,14 +119,14 @@ namespace Isis {


/**
* @param filename
* @param cube
*/
void HrscCamera::ReadLineRates(QString filename) {
Table timesTable("LineScanTimes", filename);
void HrscCamera::ReadLineRates(Cube &cube) {
Table timesTable = cube.readTable("LineScanTimes");

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_);
}

Expand All @@ -138,7 +138,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_);
}
}
Expand Down
2 changes: 1 addition & 1 deletion isis/src/mex/objs/HrscCamera/HrscCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace Isis {
virtual int SpkReferenceId() const;

private:
void ReadLineRates(QString filename);
void ReadLineRates(Cube &cube);

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

0 comments on commit 992df27

Please sign in to comment.