Unverified Commit 992df27a authored by Amy Stamile's avatar Amy Stamile Committed by GitHub
Browse files

Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds (#5705)

* in-progress-work

* convert table back to isis

* fix changelog

* Addressed PR feedback
parent 0676eb65
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ release.
- Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629)
- Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629)
- Fixed SpiceClient to handle redirect requests.
- Fixed SpiceClient to handle redirect requests.
- Fixed jigsaw to default OUTADJUSTMENTH5 option to false and allow this feature to run on read-only images [#5700](https://github.com/DOI-USGS/ISIS3/issues/5700)
- Fixed jigsaw to default OUTADJUSTMENTH5 option to false and allow this feature to run on read-only images [#5700](https://github.com/DOI-USGS/ISIS3/issues/5700)
- Fixed Cube::fromIsd to add "LineScanTimes" table from HRSC isds [#5668](https://github.com/DOI-USGS/ISIS3/issues/5668)


## [9.0.0] - 09-25-2024
## [9.0.0] - 09-25-2024


+26 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,12 @@ namespace Isis {
   */
   */
  void Cube::fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access) {
  void Cube::fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access) {
    fromLabel(fileName, label, access);
    fromLabel(fileName, label, access);

    PvlGroup &instGrp = label.findGroup("Instrument", Pvl::Traverse);
    if (isd.contains("line_scan_rate") && (QString)instGrp["InstrumentId"] == "HRSC") {
      attachLineScanTableFromIsd(isd);
    }
    
    attachSpiceFromIsd(isd);
    attachSpiceFromIsd(isd);


    close();
    close();
@@ -1532,6 +1538,26 @@ namespace Isis {
    this->camera();
    this->camera();
  }
  }


  void Cube::attachLineScanTableFromIsd(nlohmann::json isd) {
      TableField ephTimeField("EphemerisTime", TableField::Double);
      TableField expTimeField("ExposureTime", TableField::Double);
      TableField lineStartField("LineStart", TableField::Integer);

      TableRecord timesRecord;
      timesRecord += ephTimeField;
      timesRecord += expTimeField;
      timesRecord += lineStartField;

      Table timesTable("LineScanTimes", timesRecord);
      for (size_t i = 0; i < isd["line_scan_rate"].size(); ++i) {
        timesRecord[0] = isd["line_scan_rate"][i][1].get<double>() + isd["center_ephemeris_time"].get<double>();
        timesRecord[1] = isd["line_scan_rate"][i][2].get<double>();
        timesRecord[2] = (int)(isd["line_scan_rate"][i][0].get<double>() + 0.5);
        timesTable += timesRecord;
      }
      this->write(timesTable);
  }



  /**
  /**
   * If this is an external cube label file, this will give you the cube dn file that this label
   * If this is an external cube label file, this will give you the cube dn file that this label
+1 −0
Original line number Original line Diff line number Diff line
@@ -245,6 +245,7 @@ namespace Isis {
      bool labelsAttached() const;
      bool labelsAttached() const;


      void attachSpiceFromIsd(nlohmann::json Isd);
      void attachSpiceFromIsd(nlohmann::json Isd);
      void attachLineScanTableFromIsd(nlohmann::json isd);


      void close(bool remove = false);
      void close(bool remove = false);
      Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
      Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
+7 −7
Original line number Original line Diff line number Diff line
@@ -42,12 +42,12 @@ namespace Isis {
    SetPixelPitch(0.007);
    SetPixelPitch(0.007);
    instrumentRotation()->SetFrame(-41210);
    instrumentRotation()->SetFrame(-41210);


    ReadLineRates(cube);

    // Get required keywords from instrument group
    // Get required keywords from instrument group
    Pvl &lab = *cube.label();
    Pvl &lab = *cube.label();
    PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
    PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);


    ReadLineRates(lab.fileName());

    // Setup detector map for transform of image pixels to detector position
    // Setup detector map for transform of image pixels to detector position
    new VariableLineScanCameraDetectorMap(this, p_lineRates);
    new VariableLineScanCameraDetectorMap(this, p_lineRates);
    DetectorMap()->SetDetectorSampleSumming(inst["Summing"]);
    DetectorMap()->SetDetectorSampleSumming(inst["Summing"]);
@@ -119,14 +119,14 @@ namespace Isis {




  /**
  /**
   * @param filename
   * @param cube
   */
   */
  void HrscCamera::ReadLineRates(QString filename) {
  void HrscCamera::ReadLineRates(Cube &cube) {
    Table timesTable("LineScanTimes", filename);
    Table timesTable = cube.readTable("LineScanTimes");


    if(timesTable.Records() <= 0) {
    if(timesTable.Records() <= 0) {
      QString msg = "Table [LineScanTimes] in [";
      QString msg = "Table [LineScanTimes] in [";
      msg += filename + "] must not be empty";
      msg += cube.fileName() + "] must not be empty";
      throw IException(IException::Unknown, msg, _FILEINFO_);
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }
    }


@@ -138,7 +138,7 @@ namespace Isis {


    if(p_lineRates.size() <= 0) {
    if(p_lineRates.size() <= 0) {
      QString msg = "There is a problem with the data within the Table ";
      QString msg = "There is a problem with the data within the Table ";
      msg += "[LineScanTimes] in [" + filename + "]";
      msg += "[LineScanTimes] in [" + cube.fileName() + "]";
      throw IException(IException::Unknown, msg, _FILEINFO_);
      throw IException(IException::Unknown, msg, _FILEINFO_);
    }
    }
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -68,7 +68,7 @@ namespace Isis {
      virtual int SpkReferenceId() const;
      virtual int SpkReferenceId() const;


    private:
    private:
      void ReadLineRates(QString filename);
      void ReadLineRates(Cube &cube);


      std::vector<LineRateChange> p_lineRates; /**< Vector of the variable line rates for this
      std::vector<LineRateChange> p_lineRates; /**< Vector of the variable line rates for this
                                                    camera model.*/
                                                    camera model.*/
Loading