Skip to content

Commit

Permalink
Fits Import fix (DOI-USGS#5469)
Browse files Browse the repository at this point in the history
* Fixed FitsToJson subprocess error

* Added changelog entry
  • Loading branch information
acpaquette committed Apr 18, 2024
1 parent 42439eb commit dae345d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ release.
- Fixed ISIS failing to expand env variables with an "_" in them. [#5402](https://github.com/DOI-USGS/ISIS3/pull/5402)
- Fixed <i>noproj</i> bug where match cube not NULL when not specifying MATCH parameter [#5381](https://github.com/USGS-Astrogeology/ISIS3/issues/5381)
- Fixed rclone.conf/downloadIsisData pointing to old naif kernel location, updated to archived locations and https [5394](https://github.com/DOI-USGS/ISIS3/issues/5394)
- Fixed a parsing error in FitsToJson when an empty comment was reached. [#5469](https://github.com/DOI-USGS/ISIS3/pull/5469)

## [8.0.2] - 2023-12-05
### Changed
Expand Down
8 changes: 6 additions & 2 deletions isis/src/base/objs/FitsToJson/FitsToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace Isis {
line.TrimHead(" ");
}
// If the line still has anything in it, treat it is as a comment.
if (line.size() > 0) {
if (line.size() > 2) {
line.TrimHead(" /");
label.addComment(line.ToQt());
if (line != line.Token("[")) {
Expand All @@ -101,9 +101,13 @@ namespace Isis {
line = readBuf;
place += 80;
}

// Save off the PvlGroup and the number of records read from this label
fitsPvl.addGroup(*fitsLabel);
headerSizes->append((int)ceil(place / 2880.0));

// Move the file pointer past the padding after the "END" (i.e., points to start of data)
std::streamoff jump;
std::streamoff jump = 0;
jump = headerSizes->last() * 2880 - place;
fileStream.seekg(jump, std::ios_base::cur);

Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/objs/ProcessImportFits/ProcessImportFits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace Isis {
line.TrimHead(" ");
}
// If the line still has anything in it, treat it is as a comment.
if (line.size() > 0) {
if (line.size() > 2) {
line.TrimHead(" /");
label.addComment(line.ToQt());
// A possible format for units, other possiblites exist.
Expand Down
44 changes: 22 additions & 22 deletions isis/tests/FitsToJsonTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ TEST(FitsToJson, FitsConversion) {
FAIL() << "Unable to convert lorri fits label to json " << e.toString().toStdString().c_str() << std::endl;
}
// Instrument info
EXPECT_EQ(jsonData["FitsLabels"]["HOSTNAME"]["Value"], "NEW HORIZONS");
EXPECT_EQ(jsonData["FitsLabels"]["INSTRU"]["Value"], "lor");
EXPECT_EQ(jsonData["FitsLabels"]["TARGET"]["Value"], "IO");
EXPECT_EQ(jsonData["FitsLabels"]["SPCUTCAL"]["Value"], "2007-02-28T13:14:19.358");
EXPECT_EQ(jsonData["FitsLabels"]["SPCSCLK"]["Value"], "1/0034974376:48500");
EXPECT_EQ(jsonData["FitsLabels"]["SPCSCDP"]["Value"], "1748718848500.0");
EXPECT_EQ(jsonData["FitsLabels"]["EXPTIME"]["Value"], "0.02");
EXPECT_EQ(jsonData["FitsLabels"][0]["HOSTNAME"]["Value"], "NEW HORIZONS");
EXPECT_EQ(jsonData["FitsLabels"][0]["INSTRU"]["Value"], "lor");
EXPECT_EQ(jsonData["FitsLabels"][0]["TARGET"]["Value"], "IO");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCUTCAL"]["Value"], "2007-02-28T13:14:19.358");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCSCLK"]["Value"], "1/0034974376:48500");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCSCDP"]["Value"], "1748718848500.0");
EXPECT_EQ(jsonData["FitsLabels"][0]["EXPTIME"]["Value"], "0.02");

// Archive info
EXPECT_EQ(jsonData["FitsLabels"]["HSCOMPR"]["Value"], "LOSSLESS");
EXPECT_EQ(jsonData["FitsLabels"]["OBSCOMPL"]["Value"], "COMPLETE");
EXPECT_EQ(jsonData["FitsLabels"]["REQDESC"]["Value"], "Jupiter shine");
EXPECT_EQ(jsonData["FitsLabels"][0]["HSCOMPR"]["Value"], "LOSSLESS");
EXPECT_EQ(jsonData["FitsLabels"][0]["OBSCOMPL"]["Value"], "COMPLETE");
EXPECT_EQ(jsonData["FitsLabels"][0]["REQDESC"]["Value"], "Jupiter shine");

// Kernels info
EXPECT_EQ(jsonData["FitsLabels"]["FORMAT"]["Value"], "0");
EXPECT_EQ(jsonData["FitsLabels"][0]["FORMAT"]["Value"], "0");


fileTemplate = "data/leisa2isis/lsb_0034933739_0x53c_sci_1_cropped.fit";
Expand All @@ -45,21 +45,21 @@ TEST(FitsToJson, FitsConversion) {
}

// Instrument info
EXPECT_EQ(jsonData["FitsLabels"]["HOSTNAME"]["Value"], "NEW HORIZONS");
EXPECT_EQ(jsonData["FitsLabels"]["INSTRU"]["Value"], "lei");
EXPECT_EQ(jsonData["FitsLabels"]["TARGET"]["Value"], "EUROPA");
EXPECT_EQ(jsonData["FitsLabels"]["SPCSCLK0"]["Value"], "1/0034931099:00000");
EXPECT_EQ(jsonData["FitsLabels"]["RALPHEXP"]["Value"], "0.676");
EXPECT_EQ(jsonData["FitsLabels"][0]["HOSTNAME"]["Value"], "NEW HORIZONS");
EXPECT_EQ(jsonData["FitsLabels"][0]["INSTRU"]["Value"], "lei");
EXPECT_EQ(jsonData["FitsLabels"][0]["TARGET"]["Value"], "EUROPA");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCSCLK0"]["Value"], "1/0034931099:00000");
EXPECT_EQ(jsonData["FitsLabels"][0]["RALPHEXP"]["Value"], "0.676");

// Archive info
EXPECT_EQ(jsonData["FitsLabels"]["SPCSCET"]["Value"], "225897372.0736388");
EXPECT_EQ(jsonData["FitsLabels"]["DURMET"]["Value"], "251.0");
EXPECT_EQ(jsonData["FitsLabels"]["DETECTOR"]["Value"], "LEISA");
EXPECT_EQ(jsonData["FitsLabels"]["SCANTYPE"]["Value"], "LEISA");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCSCET"]["Value"], "225897372.0736388");
EXPECT_EQ(jsonData["FitsLabels"][0]["DURMET"]["Value"], "251.0");
EXPECT_EQ(jsonData["FitsLabels"][0]["DETECTOR"]["Value"], "LEISA");
EXPECT_EQ(jsonData["FitsLabels"][0]["SCANTYPE"]["Value"], "LEISA");

// BandBin info
EXPECT_EQ(jsonData["FitsLabels"]["FILTER"]["Value"], "WEDGE");
EXPECT_EQ(jsonData["FitsLabels"][0]["FILTER"]["Value"], "WEDGE");

// Kernels info
EXPECT_EQ(jsonData["FitsLabels"]["SPCINSID"]["Value"], "-98201");
EXPECT_EQ(jsonData["FitsLabels"][0]["SPCINSID"]["Value"], "-98201");
}

0 comments on commit dae345d

Please sign in to comment.