Commit 97f73cd9 authored by Adam Goins's avatar Adam Goins
Browse files

Merge branch 'kaguya' of github.com:USGS-Astrogeology/ISIS3 into kaguya

parents 2da5eeb3 715155b9
Loading
Loading
Loading
Loading
+71 −47
Original line number Diff line number Diff line
@@ -3,37 +3,48 @@
#include <cstdio>
#include <string>

#include "FileName.h"
#include "ProcessImportPds.h"

#include "UserInterface.h"
#include "FileName.h"

using namespace std;
using namespace Isis;

void IsisMain() {
  ProcessImportPds p;
  ProcessImportPds importPds;
  UserInterface &ui = Application::GetUserInterface();

  QString labelFile = ui.GetFileName("FROM");
  FileName inFile = ui.GetFileName("FROM");
  QString id;
  Pvl label(inFile.expanded());
  QString labelFile = inFile.expanded();
  Pvl label(labelFile);

  QString dataFile = "";
  if ( inFile.extension().toLower() == "lbl" ) {
    dataFile = inFile.path() + (QString) label.findKeyword("FILE_NAME");
  }
  else {
    dataFile = labelFile;
  }

  QString id = "";
  try {
    id = (QString) label.findKeyword("DATA_SET_ID");
  }
  catch(IException &e) {
    QString msg = "Unable to read [DATA_SET_ID] from input file [" +
                 inFile.expanded() + "]";
    QString msg = "Unable to read [DATA_SET_ID] from label file [" 
                  + labelFile + "]";
    throw IException(e, IException::Unknown, msg, _FILEINFO_);
  }

  id = id.simplified().trimmed();
  if(id != "TC_MAP" && id != "TCO_MAP") {
    QString msg = "Input file [" + inFile.expanded() + "] does not appear to be " +
                  "in Kaguya Terrain Camera level 2 format. " +
                  "DATA_SET_ID is [" + id + "]";
  if (id != "TC_MAP" 
      && id != "TCO_MAP"
      && id != "TC1_Level2B"
      && id != "TC2_Level2B") {
    QString msg = "Input file [" + labelFile + "] does not appear to be " +
                  "a supported Kaguya Terrain Camera format. " +
                  "DATA_SET_ID is [" + id + "]" +
                  "Valid formats include [TC_MAP, TCO_MAP, TC1_Level2B]";
    throw IException(IException::Unknown, msg, _FILEINFO_);
  }

@@ -41,74 +52,87 @@ void IsisMain() {
    label.addKeyword(PvlKeyword("TARGET_NAME", "MOON"), Pvl::Replace);
  }

  p.SetPdsFile(label, labelFile);
  importPds.SetPdsFile(label, dataFile);

  Cube *outcube = p.SetOutputCube("TO");
  Cube *outcube = importPds.SetOutputCube("TO");

  // Get user entered special pixel ranges
  if (ui.GetBoolean("SETNULLRANGE")) {
    p.SetNull(ui.GetDouble("NULLMIN"), ui.GetDouble("NULLMAX"));
    importPds.SetNull(ui.GetDouble("NULLMIN"), ui.GetDouble("NULLMAX"));
  }
  if (ui.GetBoolean("SETHRSRANGE")) {
    p.SetHRS(ui.GetDouble("HRSMIN"), ui.GetDouble("HRSMAX"));
    importPds.SetHRS(ui.GetDouble("HRSMIN"), ui.GetDouble("HRSMAX"));
  }
  if (ui.GetBoolean("SETHISRANGE")) {
    p.SetHIS(ui.GetDouble("HISMIN"), ui.GetDouble("HISMAX"));
    importPds.SetHIS(ui.GetDouble("HISMIN"), ui.GetDouble("HISMAX"));
  }
  if (ui.GetBoolean("SETLRSRANGE")) {
    p.SetLRS(ui.GetDouble("LRSMIN"), ui.GetDouble("LRSMAX"));
    importPds.SetLRS(ui.GetDouble("LRSMIN"), ui.GetDouble("LRSMAX"));
  }
  if (ui.GetBoolean("SETLISRANGE")) {
    p.SetLIS(ui.GetDouble("LISMIN"), ui.GetDouble("LISMAX"));
    importPds.SetLIS(ui.GetDouble("LISMIN"), ui.GetDouble("LISMAX"));
  }

  p.SetOrganization(Isis::ProcessImport::BSQ);
  importPds.SetOrganization(Isis::ProcessImport::BSQ);

  p.StartProcess();
  importPds.StartProcess();

  // Get the mapping labels
  Pvl otherLabels;
  p.TranslatePdsProjection(otherLabels);
  importPds.TranslatePdsProjection(otherLabels);

  // Translate the remaining MI MAP labels
  PvlGroup dataDir(Preference::Preferences().findGroup("DataDirectory"));
  QString transDir = (QString) dataDir["Kaguya"] + "/translations/";
  
  FileName transFile(transDir + "tcmapBandBin.trn");
  FileName transFile(transDir + "kaguyaTcBandBin.trn");
  PvlToPvlTranslationManager bandBinXlater(label, transFile.expanded());
  bandBinXlater.Auto(otherLabels);
  
  transFile = transDir + "tcmapInstrument.trn";
  transFile = transDir + "kaguyaTcInstrument.trn";
  PvlToPvlTranslationManager instXlater(label, transFile.expanded());
  instXlater.Auto(otherLabels);
  
  transFile = transDir + "tcmapArchive.trn";
  transFile = transDir + "kaguyaTcArchive.trn";
  PvlToPvlTranslationManager archiveXlater(label, transFile.expanded());
  archiveXlater.Auto(otherLabels);
  
  if(otherLabels.hasGroup("Mapping") &&
    (otherLabels.findGroup("Mapping").keywords() > 0)) {
  if ( otherLabels.hasGroup("Mapping") 
       && otherLabels.findGroup("Mapping").keywords() > 0 ) {
    outcube->putGroup(otherLabels.findGroup("Mapping"));
  }
  if(otherLabels.hasGroup("Instrument") &&
    (otherLabels.findGroup("Instrument").keywords() > 0)) {
  if ( otherLabels.hasGroup("Instrument") 
       && otherLabels.findGroup("Instrument").keywords() > 0 ) {
    outcube->putGroup(otherLabels.findGroup("Instrument"));
  }
  if(otherLabels.hasGroup("BandBin") &&
    (otherLabels.findGroup("BandBin").keywords() > 0)) {
    outcube->putGroup(otherLabels.findGroup("BandBin"));
  if ( otherLabels.hasGroup("BandBin") 
       && otherLabels.findGroup("BandBin").keywords() > 0 ) {

    PvlGroup &bandBinGroup = otherLabels.findGroup("BandBin");
    if (!bandBinGroup.hasKeyword("FilterName")) {
      bandBinGroup += PvlKeyword("FilterName", "BroadBand");
    }
  if(otherLabels.hasGroup("Archive") &&
    (otherLabels.findGroup("Archive").keywords() > 0)) {
    outcube->putGroup(otherLabels.findGroup("Archive"));
    if (!bandBinGroup.hasKeyword("Center")) {
      bandBinGroup += PvlKeyword("Center", "640", "nanometers");
    }

    if (!bandBinGroup.hasKeyword("Width")) {
      bandBinGroup += PvlKeyword("Width", "420", "nanometers");
    }
    outcube->putGroup(bandBinGroup);
  }
  else {
    // Add the BandBin group
  PvlGroup bbin("BandBin");
  bbin += PvlKeyword("FilterName", "BroadBand");
  bbin += PvlKeyword("Center", "640nm");
  bbin += PvlKeyword("Width", "420nm");
  outcube->putGroup(bbin);
    PvlGroup bandBinGroup("BandBin");
    bandBinGroup += PvlKeyword("FilterName", "BroadBand");
    bandBinGroup += PvlKeyword("Center", "640nm");
    bandBinGroup += PvlKeyword("Width", "420nm");
    outcube->putGroup(bandBinGroup);
  }

  if ( otherLabels.hasGroup("Archive") 
       && otherLabels.findGroup("Archive").keywords() > 0 ) {
    outcube->putGroup(otherLabels.findGroup("Archive"));
  }

  p.EndProcess();
  importPds.EndProcess();
}
+13 −3
Original line number Diff line number Diff line
@@ -2,11 +2,18 @@

<application name="kaguyatc2isis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">

  <brief>Import PDS formatted Kaguya Terrain Camera level 2 image cube into Isis format cube</brief>
  <brief>
    Import L2B0 or L2B2 Kaguya TC image to ISIS3 cube.
  </brief>

  <description>
    This program will import a PDS formatted Kaguya Terrain Camera (TC) level 2  
    image into an Isis cube. 
    This program will import a Kaguya Terrain Camera (TC)   
    file from a PDS3 formatted image to an ISIS3 formatted cube.
    Note that not all TC images may be supported by this program.
    Supported input images include radiometrically corrected
    unprojected images, TC maps, or TC Ortho maps.
    To verify, input image labels must have DATA_SET_ID matching
    TC1_Level2B, TC2_Level2B, TC_MAP or TCO_MAP.
  </description>

  <history>
@@ -24,6 +31,9 @@
    <change name="Janet Barrett" date="2014-02-11">
      Added check for TARGET_NAME keyword. Fixes #2036.
    </change>
    <change name="Jeannie Backer" date="2018-10-02">
      Added support for Kaguya L2B0 (TC1_Level2B and TC2_Level2B) files. 
    </change>
  </history>

  <category>
+12 −0
Original line number Diff line number Diff line
# Tests import of Kaguya TC1 L2B0 image. 
#
# history 2018-10-02 Jeannie Backer - Original version.
APPNAME = kaguyatc2isis

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/TC1W2B0_01_00296N081E2387.img \
	           to=$(OUTPUT)/TC1W2B0_01_00296N081E2387.cub > /dev/null;
	  catlab from=$(OUTPUT)/TC1W2B0_01_00296N081E2387.cub \
	         to=$(OUTPUT)/TC1W2B0_01_00296N081E2387.pvl > /dev/null;
+12 −0
Original line number Diff line number Diff line
# Tests import of Kaguya TC2 L2B0 image. 
#
# history 2018-10-02 Jeannie Backer - Original version.
APPNAME = kaguyatc2isis

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/TC2W2B0_01_02735N583E3115.img \
	           to=$(OUTPUT)/TC2W2B0_01_02735N583E3115.cub > /dev/null;
	  catlab from=$(OUTPUT)/TC2W2B0_01_02735N583E3115.cub \
	         to=$(OUTPUT)/TC2W2B0_01_02735N583E3115.pvl > /dev/null;