Commit d69209ed authored by Tyler Wilson's avatar Tyler Wilson Committed by Adam Paquette
Browse files

Added support in ONC ingestion for updated keyword values, along with a few other changes.

parent 8d20d67d
Loading
Loading
Loading
Loading
+55 −46
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<application name="hyb2onc2isis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">
<!-- $Id: hyb2onc2isis.xml 6226 2017-07-05 20:46:13Z kewilliams@usgs.gov $ -->
<application name="hyb2onc2isis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">

  <brief>Import PDS/FITS formatted Hayabusa2 image into ISIS cube</brief>
  <brief>Import FITS formatted Hayabusa2 images into the ISIS cube format</brief>

  <description>
    <p>
       This application will import and convert a Hayabusa2 Optical Navigation Camera (ONC) FITS image to an ISIS cube.
       This application will import and convert a Hayabusa2 Optical Navigation Camera (ONC)
       FIT image to an ISIS cube.
      
    </p>
    <br/>
@@ -53,8 +54,8 @@
       cameras (ONC-W1,ONC-W2). 
    </p>
    <p>
       The wide-angle cameras each have a square 65.24 x 65.24 deg. field of view (FOV). The wide-angle
       camera ONC-W1 and ONC-W2 have focal lengths of
       The wide-angle cameras each have a square 65.24 x 65.24 deg. field of view (FOV).
       The wide-angle camera ONC-W1 and ONC-W2 have focal lengths of
       10.35 mm and 10.44 mm, respectively. The telescope camera 
       has a 6.35 x 6.35 deg. FOV. The telescopic camera ONC-T has a focal length of 121.1 mm. 
    </p>
@@ -129,12 +130,15 @@
    <h2>References</h2>
    <br/>
    <cite>
      Suzuki, H. et al. (2017) Initial Inflight Calibration for Hayabusa2 Optical Navigation Camera (ONC) for Scientific Observations of Asteroid Ryugu (in review for Icarus).
      Suzuki, H. et al. (2017) Initial Inflight Calibration for Hayabusa2 Optical
      Navigation Camera (ONC) for Scientific Observations of Asteroid Ryugu (in review for Icarus).
    </cite>
    <br/>
    <br/>
    <cite>
        Kameda, S. et al. (2015) Detectability of hydrous minerals using ONC-T camera onboard the Hayabusa2 spacecraft, Advances in Space Research, Volume 56, Issue 7, Pages 1519-1524, ISSN 0273-1177, http://dx.doi.org/10.1016/j.asr.2015.06.037.
        Kameda, S. et al. (2015) Detectability of hydrous minerals using ONC-T camera onboard
        the Hayabusa2 spacecraft, Advances in Space Research, Volume 56, Issue 7, Pages 1519-1524,
        ISSN 0273-1177, http://dx.doi.org/10.1016/j.asr.2015.06.037.
        (http://www.sciencedirect.com/science/article/pii/S0273117715004743)
    </cite>
    <br/>
@@ -149,6 +153,11 @@
    <change name="Kaj Williams and Ian Humphrey" date="2017-07-26">
      Added references and more text.
    </change>
    <change name="Tyler Wilson" date="2018-11-30">
      Updated the ingestion routine to handle new keywords, and retain the ability to
      process FIT files using the old keywords.  Also set TARGET=RYUGU in the event the user
      does not specify a target, and the target in the fit label is set to SKY.
    </change>
  </history>

  <category>
@@ -171,14 +180,14 @@
           the header contained therein.  Some FITS label values are transferred 
           to the output ISIS files as well for completeness.
        </description>      
        <filter>*.lbl *.LBL</filter>
        <filter>*.fit</filter>
      </parameter>
      
      <parameter name="TO">
         <type>cube</type>
         <pixelType>real</pixelType>
         <fileMode>output</fileMode>
         <brief>Output ISIS cube filename</brief>
         <brief>Output ISIS3 cube filename</brief>
         <description>
           Use this parameter to select the output filename of the ISIS cube 
           generated by this application.
@@ -202,7 +211,7 @@
                 projecting data to the celestial sphere. 
              </p>
            </description>
            <internalDefault>Label Value</internalDefault>
            <internalDefault>SKY</internalDefault>
        </parameter>
    </group>
  </groups>
+92 −19
Original line number Diff line number Diff line
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "Isis.h"

#include <QDebug>
#include <QString>

#include "FileName.h"
@@ -30,11 +23,13 @@ void IsisMain () {
  UserInterface &ui = Application::GetUserInterface();
  importFits.setFitsFile(FileName(ui.GetFileName("FROM")));
  importFits.setProcessFileStructure(0);

  bool updatedKeywords = true;
  bool distortionCorrection = true;
  Cube *outputCube = importFits.SetOutputCube("TO");

  // Get the directory where the Hayabusa translation tables are.
  QString transDir = "$ISISROOT/appdata/translations/";
  PvlGroup dataDir (Preference::Preferences().findGroup("DataDirectory"));
  QString transDir = (QString) dataDir["Hayabusa2"] + "/translations/";

  // Create a PVL to store the translated labels in
  Pvl outputLabel;
@@ -51,8 +46,12 @@ void IsisMain () {
    throw IException(e, IException::Unknown, msg, _FILEINFO_);
  }


  QString instid;
  QString missid;
  QString naifid;
  QString formatType;

  try {
    instid = fitsLabel.findGroup("FitsLabels").findKeyword("INSTRUME")[0];
    missid = fitsLabel.findGroup("FitsLabels").findKeyword ("SPCECRFT")[0]; 
@@ -63,6 +62,33 @@ void IsisMain () {
    throw IException(e, IException::Io,msg, _FILEINFO_);
  }

  try {
    naifid = fitsLabel.findGroup("FitsLabels").findKeyword("NAIFID")[0];
  }
  catch(IException &e) {
    updatedKeywords=false;
  }

  try {
    formatType = fitsLabel.findGroup("FitsLabels").findKeyword("EXTNAME")[0];
  }
  catch(IException &e) {
    QString msg = "Unable to read EXTNAME from input file ["
        +FileName(ui.GetFileName("FROM")).expanded() + "]";
    throw IException(e, IException::Io,msg, _FILEINFO_);
  }

  try {
    naifid = fitsLabel.findGroup("FitsLabels").findKeyword("NAIFID")[0];
  }
  catch(IException &e) {
    updatedKeywords=false;
  }

  if (formatType.contains("2a") || formatType.contains("2b"))
    distortionCorrection = false;


  missid = missid.simplified().trimmed();
  if (QString::compare(missid, "HAYABUSA-2", Qt::CaseInsensitive) != 0) {
    QString msg = "Input file [" + FileName(ui.GetFileName("FROM")).expanded() + 
@@ -77,13 +103,42 @@ void IsisMain () {
  }

  // Translate the Instrument group
  FileName transFile(transDir + "Hayabusa2OncInstrument.trn");

  FileName transFile(transDir + "hyb2oncInstrument.trn");

  if (updatedKeywords) {
    transFile = transDir+"hyb2oncInstrumentUpdated.trn";
  }
  PvlToPvlTranslationManager instrumentXlater (fitsLabel, transFile.expanded());
  instrumentXlater.Auto(outputLabel);


  //  Update target if user specifies it
  PvlGroup &instGrp = outputLabel.findGroup("Instrument",Pvl::Traverse);
  QString target;

  instGrp.addKeyword(PvlKeyword("DistortionCorrection"));
  try {
    target = fitsLabel.findGroup("FitsLabels").findKeyword("TARGET")[0];
  }
  catch(IException &e) {
    QString msg = "Unable to read TARGET from input file ["
        +FileName(ui.GetFileName("FROM")).expanded() + "]";
    throw IException(e, IException::Io,msg, _FILEINFO_);
  }
  if (target=="SKY") {
    instGrp["TargetName"] = "RYUGU";
  }

  if (distortionCorrection) {
    instGrp["DistortionCorrection"] = "1";
  }
  else {
     instGrp["DistortionCorrection"] = "0";
  }


  //If the user wants to specify a different target, overwrite this value
  if (ui.WasEntered("TARGET")) {
    instGrp["TargetName"] = ui.GetString("TARGET");
  }
@@ -91,7 +146,13 @@ void IsisMain () {
  outputCube->putGroup(instGrp);

  // Translate the BandBin group
  transFile = transDir + "Hayabusa2OncBandBin.trn";

  transFile = transDir + "hyb2oncBandBin.trn";
  if (updatedKeywords) {
    transFile = transDir + "hyb2oncBandBinUpdated.trn";
  }


  PvlToPvlTranslationManager bandBinXlater (fitsLabel, transFile.expanded());
  bandBinXlater.Auto(outputLabel);
  PvlGroup &bandGrp = outputLabel.findGroup("BandBin",Pvl::Traverse);
@@ -102,7 +163,12 @@ void IsisMain () {
  outputCube->putGroup(outputLabel.findGroup("BandBin",Pvl::Traverse));

  // Translate the Archive group
  transFile = transDir + "Hayabusa2OncArchive.trn";

  transFile = transDir + "hyb2oncArchive.trn";
  if (updatedKeywords) {
    transFile = transDir + "hyb2oncArchiveUpdated.trn";
  }

  PvlToPvlTranslationManager archiveXlater (fitsLabel, transFile.expanded());
  archiveXlater.Auto(outputLabel);
  PvlGroup &archGrp = outputLabel.findGroup("Archive", Pvl::Traverse);
@@ -117,7 +183,13 @@ void IsisMain () {


  // Create a Kernels group
  transFile = transDir + "Hayabusa2OncKernels.trn";
  if (updatedKeywords) {
    transFile = transDir + "hyb2oncKernelsUpdated.trn";
  }
  else {
    transFile = transDir + "hyb2oncKernels.trn";
  }

  PvlToPvlTranslationManager kernelsXlater(fitsLabel, transFile.expanded());
  kernelsXlater.Auto(outputLabel);
  outputCube->putGroup(outputLabel.findGroup("Kernels", Pvl::Traverse));
@@ -133,3 +205,4 @@ void IsisMain () {
  importFits.Finalize();

}