Unverified Commit fc9abbb2 authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

New Ctxcal Flat file Option (#5338)



* Added ability to use new monthly flat files for ctxcal

* Added error handling if we can't find the monthly flat file

* Added initial test for new parameter

* Finalized ctxcal test

* Addressed changelog merge conflicts

* Updated history entry in ctxcal

---------

Co-authored-by: default avatarKelvin Rodriguez <krodriguez@usgs.gov>
parent c70dd7ce
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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

+16 −1
Original line number Diff line number Diff line
@@ -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());
+14 −0
Original line number Diff line number Diff line
@@ -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>
@@ -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">
+1 −1
Original line number Diff line number Diff line
@@ -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));
  }
+23 −0
Original line number Diff line number Diff line
@@ -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";