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

New Ctxcal Flat file Option #5338

Merged
merged 7 commits into from
Mar 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ release.
### 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.
- Fixed TrackTool, FindTool, and AdvancedTrackTool not reporting RA and DEC for images targeting the Sky. [#5409](https://github.com/DOI-USGS/ISIS3/pull/5409)
- Added new option in `ctxcal` to use monthly computed flatfield files for "Frown" removal in CTX images. [#5338](https://github.com/DOI-USGS/ISIS3/pull/5338)


## [8.1.0] - 2024-01-08

Expand Down
17 changes: 16 additions & 1 deletion isis/src/mro/apps/ctxcal/ctxcal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,22 @@ namespace Isis {
flatFile.open(ui.GetCubeName("FLATFILE"));
}
else {
FileName flat = FileName("$mro/calibration/ctxFlat_????.cub").highestVersion();
FileName flat;
if (ui.GetBoolean("MONTHLYFLAT")) {
FileName outputFileName(icube->fileName());
QString outputFileBase = outputFileName.baseName();

QStringRef month(&outputFileBase, 0, 3);
flat = FileName("$mro/calibration/ctxFlatFiles/" + month + ".flat.cub");
if (!flat.fileExists()) {
QString msg = "Could not find flat file [" + flat.expanded() + "]. "
"Either the data area is not set or a month is missing.";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
}
else {
flat = FileName("$mro/calibration/ctxFlat_????.cub").highestVersion();
}
flatFile.open(flat.expanded());
}
flat = new Brick(5000, 1, 1, flatFile.pixelType());
Expand Down
14 changes: 14 additions & 0 deletions isis/src/mro/apps/ctxcal/ctxcal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
<change name="Kelvin Rodriguez" date="2021-02-24">
Added ability to get the sun distance from the camera.
</change>
<change name="Adam Paquette" date="2023-11-15">
Exposed new calibration files to users via a new flag. Addresses #5338
</change>
</history>

<category>
Expand Down Expand Up @@ -214,6 +217,17 @@
default will be used.
</description>
</parameter>
<parameter name="MONTHLYFLAT">
<brief> Change the default flat file to a monthly mission flat file</brief>
<description>
If turned on, ctxcal will use the default mission monthly flat file
for calibration.
</description>
<type>boolean</type>
<default>
<item>No</item>
</default>
</parameter>
</group>

<group name="Calibration Parameters">
Expand Down
2 changes: 1 addition & 1 deletion isis/tests/CameraFixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace Isis {
void MroCtxCube::SetUp() {
TempTestingFiles::SetUp();

QString testPath = tempDir.path() + "/test.cub";
QString testPath = tempDir.path() + "/B10_test.cub";
QFile::copy("data/mroCtxImage/ctxTestImage.cub", testPath);
testCube.reset(new Cube(testPath));
}
Expand Down
23 changes: 23 additions & 0 deletions isis/tests/FunctionalTestsCtxcal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ TEST_F(MroCtxCube, FunctionalTestCtxcalFlatfile) {
EXPECT_DOUBLE_EQ(oCubeStats->StandardDeviation(), 0.0018248585597074806);
}

TEST_F(MroCtxCube, FunctionalTestCtxcalMonthlyFlatfile) {
QString outCubeFileName = tempDir.path() + "/outTemp.cub";
QVector<QString> args = {"to="+outCubeFileName, "monthlyflat=True"};

UserInterface options(APP_XML, args);

try {
ctxcal(testCube.get(), options);
}
catch (IException &e) {
FAIL() << "Unable to open image: " << e.what() << std::endl;
}

Cube oCube(outCubeFileName, "r");

Histogram *oCubeStats = oCube.histogram();

EXPECT_DOUBLE_EQ(oCubeStats->Average(), 0.080543650835752489);
EXPECT_DOUBLE_EQ(oCubeStats->Sum(), 32.217460334300995);
EXPECT_DOUBLE_EQ(oCubeStats->ValidPixels(), 400);
EXPECT_DOUBLE_EQ(oCubeStats->StandardDeviation(), 0.0012787322597001109);
}


TEST_F(MroCtxCube, FunctionalTestCtxcalIofFalse) {
QString outCubeFileName = tempDir.path() + "/outTemp.cub";
Expand Down