Unverified Commit 49ee253b authored by jcwbacker's avatar jcwbacker Committed by GitHub
Browse files

Merge pull request #226 from jcwbacker/hayabusa

Added subframe and radiometric info for hayabusa1 export.
parents 8ecbff2e 01564afd
Loading
Loading
Loading
Loading
+51 −6
Original line number Diff line number Diff line
#include "Isis.h"

#include <QRegularExpression>
#include <QDomDocument>
#include <QDomElement>
#include <QString>

#include "Application.h"
@@ -29,16 +30,60 @@ void IsisMain() {

  // Setup the process and set the input cube
  ProcessExportPds4 process;
  Cube *icube = process.SetInputCube("FROM");
  Cube *inputCube = process.SetInputCube("FROM");
  Pvl *inputLabel = inputCube->label();

  process.StandardPds4Label();
  QDomDocument &pdsLabel = process.StandardPds4Label();
  /*
   * Add additional pds label data here
   */
  QDomDocument &pdsLabel = process.GetLabel();
  PvlToXmlTranslationManager cubeLab(*(icube->label()),
//  QDomDocument &pdsLabel = process.GetLabel();
  PvlToXmlTranslationManager xlator(*(inputLabel),
                                    "$hayabusa/translations/hyb1Pds4Export.trn");
  cubeLab.Auto(pdsLabel);
  xlator.Auto(pdsLabel);

  PvlGroup instGroup = inputLabel->findObject("IsisCube").findGroup("Instrument");
  QStringList xmlPath;
  xmlPath << "Product_Observational" 
          << "Observation_Area" 
          << "Discipline_Area" 
          << "img:Imaging" 
          << "img:Subframe_Parameters";
  if (instGroup.hasKeyword("FirstLine") && instGroup.hasKeyword("LastLine")) {

    int lines = (int) instGroup["LastLine"] - (int) instGroup["FirstLine"];
    QDomElement baseElement = pdsLabel.documentElement();
    QDomElement subframeParametersElement = process.getElement(xmlPath, baseElement);

    QDomElement linesElement = pdsLabel.createElement("img:lines");
    PvlToXmlTranslationManager::setElementValue(linesElement, toString(lines));
    subframeParametersElement.appendChild(linesElement);

  }

  if (instGroup.hasKeyword("FirstSample") && instGroup.hasKeyword("LastSample")) {
    int samples = (int) instGroup["LastSample"] - (int) instGroup["FirstSample"];
    QDomElement baseElement = pdsLabel.documentElement();
    QDomElement subframeParametersElement = process.getElement(xmlPath, baseElement);

    QDomElement samplesElement = pdsLabel.createElement("img:samples");
    PvlToXmlTranslationManager::setElementValue(samplesElement, toString(samples));
    subframeParametersElement.appendChild(samplesElement);
  }

  double radianceScalingFactor = 1.0;
  if (instGroup.hasKeyword("RadianceScaleFactor")) {
    radianceScalingFactor *= (double)instGroup["RadianceScaleFactor"];
  }
  if (instGroup.hasKeyword("RadianceStandard")) {
    radianceScalingFactor *= (double)instGroup["RadianceStandard"];
  }
  xmlPath[4] = "img:Radiometric_Correction_Parameters";
  QDomElement baseElement = pdsLabel.documentElement();
  QDomElement radiometricParametersElement = process.getElement(xmlPath, baseElement);
  QDomElement radianceFactorElement = pdsLabel.createElement("img:radiance_scaling_factor_WO_units");
  PvlToXmlTranslationManager::setElementValue(radianceFactorElement, toString(radianceScalingFactor));
  radiometricParametersElement.appendChild(radianceFactorElement);

  ProcessExportPds4::translateUnits(pdsLabel);