Commit 6b9a202d authored by Kristin Berry's avatar Kristin Berry
Browse files

Checked in new application tgocassisrdrgen. Fixes # 5167

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@8243 41f8697f-d340-4b68-9986-7bafba869bb8
parent 6a2c08c1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
	echo "Please set ISISROOT";
else
	include $(ISISROOT)/make/isismake.apps
endif
 No newline at end of file
+59 −0
Original line number Diff line number Diff line
#include "Isis.h"

#include <QString>
#include <QDomDocument>

#include "Application.h"
#include "Cube.h"
#include "ExportDescription.h"
#include "FileName.h"
#include "Process.h"
#include "ProcessExportPds4.h"
#include "Pvl.h"
#include "PvlKeyword.h"
#include "PvlToXmlTranslationManager.h"

using namespace Isis;
using namespace std;

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

    // Check if input file is indeed, a cube
  if (ui.GetFileName("FROM").right(3) != "cub") {
    QString msg = "Input file [" + ui.GetFileName("FROM") +
                "] does not appear to be a cube";
    throw  IException(IException::User, msg, _FILEINFO_);
  }

  // Setup the process and set the input cube
  ProcessExportPds4 p;
  Cube *icube = p.SetInputCube("FROM");

  PvlObject *label= icube->label();
  PvlKeyword &instrument = label->findObject("IsisCube").findGroup("Instrument").findKeyword("InstrumentId");

  // Check if the cube is able to be translated into a CaSSIS xml file
  // This could very well be unnecessary
  if (!instrument.isEquivalent("CaSSIS")) {
    QString msg = "Input file [" + ui.GetFileName("FROM") +
                "] does not appear to be a CaSSIS RDR product. The image" +
                "instrument is not the CaSSIS instrument";
    throw  IException(IException::User, msg, _FILEINFO_);
  }

/*
  * Add additional pds label data here
  */

  QDomDocument &pdsLabel = p.GetLabel();
  PvlToXmlTranslationManager cubeLab(*(icube->label()),
                                    "$tgo/translations/tgoCassisExport.trn");
  cubeLab.Auto(pdsLabel);

  p.StandardPds4Label();
  
  QString outFile = ui.GetFileName("TO");
  
  p.WritePds4(outFile);
}
+69 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

<application name="tgocassisrdrgen" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">
  <brief>
    Converts CaSSIS cubes into PDS 4 standard format
  </brief>

  <description>
    SOMETHING
  </description>

  <history>
    <change name="Adam Paquette" date="2017-05-23">
      Original Version
    </change>
    <change name="Makayla Shepherd" date="2017-06-01">
      Added detached label.
    </change>
    <change name="Adam Paquette" date="2017-06-02">
      Added the cassis specific translation file for label output.
    </change>
    <change name="Adam Paquette" date="2017-06-04">
      Changed the order that the elements appear in the output label.
    </change>
    <change name="Marjorie Hahn" date="2017-06-05">
      Added a default test to ensure that if the exported PDS4 data is reingested, 
      then it is the same as the original cube.
    </change>
    <change name="Marjorie Hahn" date="2017-06-08">
      Moved code to write out .img and .xml PDS4 data to WritePds4 in ProcessExportPds4.
    </change>
  </history>

  <category>
    <missionItem>ExoMars Trace Gas Orbiter</missionItem>
  </category>

  <groups>
    <group name="Files">
      <parameter name="FROM">
        <type>cube</type>
        <fileMode>input</fileMode>
        <brief>
          Input RDR CaSSIS formated ISIS cube
        </brief>
        <description>
          Input cube that is a CaSSIS formated RDR cube, to be translated into a corresponding .img
          file and associated detached pds4 label. Currently, the cube must be a CaSSIS specific cube to
          be translated at all.
        </description>
        <filter>*.cub</filter>
      </parameter>

      <parameter name="TO">
        <type>filename</type>
        <fileMode>output</fileMode>
        <brief>
          Output IMG file. Also determines XML file name.
        </brief>
        <description>
          Output IMG file where the image data will be. The value that is entered also determines
          the name of the detached XML label, where the .img extension is replaced with .xml.
          Example: test.img is entered, the detached label would be named test.xml
        </description>
        <filter>*.img</filter>
      </parameter>
    </group>
  </groups>
</application>
+4 −0
Original line number Diff line number Diff line
BLANKS = "%-6s"    
LENGTH = "%-40s"

include $(ISISROOT)/make/isismake.tststree
+25 −0
Original line number Diff line number Diff line
APPNAME = tgocassisrdrgen

include $(ISISROOT)/make/isismake.tsts

commands: 
	$(APPNAME) from=$(INPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.cub \
	to=$(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.img > /dev/null;
	
	# Reingest the PDS4 data
	raw2isis from=$(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.img \
	to=$(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.cub \
	SAMPLES=2048 \
	LINES=254 \
	BITTYPE=REAL \
	BYTEORDER=LSB > /dev/null;
	
	# Compare the output cube from raw2isis to the original input cube to
	# ensure that they are identical
	cubediff from=$(INPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.cub \
	from2=$(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.cub \
	to=$(OUTPUT)/cubediffresults.txt > /dev/null;
	          
	# Change the output xml file to a txt file for test comparison
	mv $(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.xml \
	$(OUTPUT)/CAS-MCO-2016-11-26T22.32.39.582-BLU-03025-00.txt > /dev/null;