Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fits Import fix #5469

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ release.
- 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 findFeaturesSegment trying to merge networks when only 1 segmented network was successfully created [5416](https://github.com/DOI-USGS/ISIS3/issues/5416)
- 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)

### Added
- Added 8 new functions to the Sensor Utility Library: Slant Distance, Target Center Distance, Right Ascension Declination, Local Solar Time, Line Resolution, Sample Resolution, Pixel Resolution, and Solar Longitude.
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");
}