Skip to content

Commit

Permalink
convert table back to isis
Browse files Browse the repository at this point in the history
  • Loading branch information
amystamile-usgs committed Jan 13, 2025
1 parent f9ae045 commit f611af9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
46 changes: 24 additions & 22 deletions isis/src/base/objs/Cube/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ namespace Isis {
*/
void Cube::fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access) {
fromLabel(fileName, label, access);

if (isd.contains("line_scan_rate")) {
attachLineScanTableFromIsd(isd);
}
attachSpiceFromIsd(isd);

close();
Expand Down Expand Up @@ -1510,26 +1514,6 @@ 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<double>();
timesRecord[1] = isd["line_scan_rate"][i][2].get<double>();
timesRecord[2] = isd["line_scan_rate"][i][0].get<int>();
timesTable += timesRecord;
}
this->write(timesTable);
}

PvlGroup currentKernels = this->group("Kernels");

Pvl *label = this->label();
Expand All @@ -1549,9 +1533,27 @@ 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";
}

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


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
2 changes: 1 addition & 1 deletion isis/tests/CubeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) {
EXPECT_PRED_FORMAT2(AssertQStringsEqual, cam->instrumentNameLong(), "Visual Imaging Subsystem Camera B");
}

TEST(CubeTest, TestCubeAttachSpiceFromHrscIsd) {
TEST(CubeTest, TestCubeAttachLineScanTableFromIsd) {
std::istringstream labelStrm(R"(
Object = IsisCube
Object = Core
Expand Down

0 comments on commit f611af9

Please sign in to comment.