Unverified Commit dbd3d59e authored by Austin Sanders's avatar Austin Sanders Committed by GitHub
Browse files

Updated kaguyasp2ascii to support newer (detached) data (#5568)

* Modified to work with new (detached) data

* Updated changelog

* Allow data specification outside current directory
parent 9ac2592e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ release.
- Added backplane options for SunIllumination and SurfaceObliqueDetectorResolution to phocube [#5467](https://github.com/DOI-USGS/ISIS3/issues/5467)

### Changed
- Modified kaguyasp2isis to work with new (detached) data [#5436](https://github.com/DOI-USGS/ISIS3/issues/5436)
- Added jigsaw error message for csminit'd images without csm parameters[#5486](https://github.com/DOI-USGS/ISIS3/issues/5486)
- Changed `qwt` dependency version to 6.2.0 or below [#5498](https://github.com/DOI-USGS/ISIS3/issues/5498)
- Pinned `suitesparse` dependency version to maximum not including 7.7.0 [#5496](https://github.com/DOI-USGS/ISIS3/issues/5496)
+2 −2
Original line number Diff line number Diff line
@@ -80,10 +80,10 @@
          Input Kaguya SP file
        </brief>
        <description>
          This is the input Kaguya SP file
          This is the input Kaguya SP file.  For an attached label, use the .spc file, or for a detached label, use the .lbl file.
        </description>
        <filter>
          *.spc
          *.lbl *.spc
        </filter>
      </parameter>
      <parameter name="TO">
+25 −12
Original line number Diff line number Diff line
@@ -25,8 +25,20 @@ void IsisMain() {
  ProcessImportPds p;
  UserInterface &ui = Application::GetUserInterface();

  FileName inFile = ui.GetFileName("FROM");
  Pvl lab(inFile.expanded());
  QString inFile = ui.GetFileName("FROM");
  Pvl lab(inFile);
  QString dataFile = lab.findKeyword("FILE_NAME")[0];

  // Detached labels use format keyword = "dataFile" value <unit>
  int keywordIndex = 1;

  if (FileName(inFile).baseName() == FileName(dataFile).baseName()){
    // data files usually do not include path information.  If input basename matches datafile basename, include path information
    // this allows users to specify data that is not in the current directory.
    dataFile = inFile;
    // Attached labels use format keyword = value <units>
    keywordIndex = 0;
  }

  ofstream os;
  QString outFile = FileName(ui.GetFileName("TO")).expanded();
@@ -59,32 +71,32 @@ void IsisMain() {
  int qaptr = 0;

  if (lab.hasKeyword("^SP_SPECTRUM_WAV")) {
    wavptr = toInt(lab.findKeyword("^SP_SPECTRUM_WAV")[0]) - 1;
    wavptr = toInt(lab.findKeyword("^SP_SPECTRUM_WAV")[keywordIndex]) - 1;
  }
  if (lab.hasKeyword("^SP_SPECTRUM_RAW")) {
    rawptr = toInt(lab.findKeyword("^SP_SPECTRUM_RAW")[0]) - 1;
    rawptr = toInt(lab.findKeyword("^SP_SPECTRUM_RAW")[keywordIndex]) - 1;
  }
  if (lab.hasKeyword("^SP_SPECTRUM_RAD")) {
    radptr = toInt(lab.findKeyword("^SP_SPECTRUM_RAD")[0]) - 1;
    radptr = toInt(lab.findKeyword("^SP_SPECTRUM_RAD")[keywordIndex]) - 1;
  }
  //older-format file without calibrated NIR2 data
  if (lab.hasKeyword("^SP_SPECTRUM_REF")) {
    refptr1 = toInt(lab.findKeyword("^SP_SPECTRUM_REF")[0]) - 1;
    refptr1 = toInt(lab.findKeyword("^SP_SPECTRUM_REF")[keywordIndex]) - 1;
  }
  //newer-format file with calibrated NIR2 data and 2 different Reflectances
  if (lab.hasKeyword("^SP_SPECTRUM_REF1")) {
    refptr1 = toInt(lab.findKeyword("^SP_SPECTRUM_REF1")[0]) - 1;
    refptr1 = toInt(lab.findKeyword("^SP_SPECTRUM_REF1")[keywordIndex]) - 1;
  }
  if (lab.hasKeyword("^SP_SPECTRUM_REF2")) {
    refptr2 = toInt(lab.findKeyword("^SP_SPECTRUM_REF2")[0]) - 1;
    refptr2 = toInt(lab.findKeyword("^SP_SPECTRUM_REF2")[keywordIndex]) - 1;
  }
  if (lab.hasKeyword("^SP_SPECTRUM_QA")) {
    qaptr = toInt(lab.findKeyword("^SP_SPECTRUM_QA")[0]) - 1;
    qaptr = toInt(lab.findKeyword("^SP_SPECTRUM_QA")[keywordIndex]) - 1;
  }

  FILE *spcptr;
  if ((spcptr = fopen(inFile.expanded().toLatin1().data(),"rb")) == 0) {
    QString msg = "Error opening input Kaguya SP file [" + inFile.expanded() + "]";
  if ((spcptr = fopen(dataFile.toLatin1().data(),"rb")) == 0) {
    QString msg = "Error opening input Kaguya SP file [" + dataFile + "]";
    throw IException(IException::User, msg, _FILEINFO_);
  }

@@ -101,7 +113,7 @@ void IsisMain() {
  if (!lab.hasObject("SP_SPECTRUM_WAV") || !lab.hasObject("SP_SPECTRUM_QA") ||
      !lab.hasObject("SP_SPECTRUM_RAD") || !(lab.hasObject("SP_SPECTRUM_REF") ||
      (lab.hasObject("SP_SPECTRUM_REF1") && lab.hasObject("SP_SPECTRUM_REF2")))) {
    QString msg = "Input file [" + inFile.expanded() + "] is not a valid ";
    QString msg = "Input file [" + inFile + "] is not a valid ";
    msg += "Kaguya Spectral Profiler file";
    throw IException(IException::User, msg, _FILEINFO_);
  }
@@ -261,6 +273,7 @@ void IsisMain() {

  PvlObject refobj;
  PvlObject refobj2;

  if (lab.hasKeyword("^SP_SPECTRUM_REF")) {
    refobj = lab.findObject("SP_SPECTRUM_REF");
  }