Unverified Commit 159718f7 authored by Tim Giroux's avatar Tim Giroux Committed by GitHub
Browse files

pds2isis gtest (#4144)

* write tests with cropped data

* add cropped data

* test DN's and remove accidental paths

* remove accidental prints

* fix build failure

* remove local path
parent 183da173
Loading
Loading
Loading
Loading
+0 −7
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
+84 −0
Original line number Diff line number Diff line
#include "ProcessImportPds.h"

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

using namespace std;
namespace Isis {
  void pds2isis(UserInterface &ui, Pvl *log) {
    ProcessImportPds p;
    Pvl label;
    QString labelFile = ui.GetFileName("FROM");
    QString imageFile("");
    if(ui.WasEntered("IMAGE")) {
      imageFile = ui.GetFileName("IMAGE");
    }

    p.SetPdsFile(labelFile, imageFile, label);

  
    CubeAttributeOutput &att = ui.GetOutputAttribute("TO");
    Cube *ocube = p.SetOutputCube(ui.GetFileName("TO"), att);

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

    // Export the cube
    p.StartProcess();

    // Get as many of the other labels as we can
    Pvl otherLabels;
    p.TranslatePdsProjection(otherLabels);
    if(p.IsIsis2()) {
      p.TranslateIsis2Labels(otherLabels);
    }
    else {
      p.TranslatePdsLabels(otherLabels);
    }

    if(otherLabels.hasGroup("Mapping") &&
        (otherLabels.findGroup("Mapping").keywords() > 0)) {
      ocube->putGroup(otherLabels.findGroup("Mapping"));
    }
    if(otherLabels.hasGroup("Instrument") &&
        (otherLabels.findGroup("Instrument").keywords() > 0)) {
      ocube->putGroup(otherLabels.findGroup("Instrument"));
    }
    if(otherLabels.hasGroup("BandBin") &&
        (otherLabels.findGroup("BandBin").keywords() > 0)) {
      ocube->putGroup(otherLabels.findGroup("BandBin"));
    }
    if(otherLabels.hasGroup("Archive") &&
        (otherLabels.findGroup("Archive").keywords() > 0)) {
      ocube->putGroup(otherLabels.findGroup("Archive"));
    }
    
    //  Check for and log any change from the default projection offsets and multipliers
    if (p.GetProjectionOffsetChange()) {
      PvlGroup results = p.GetProjectionOffsetGroup();
      results.setName("Results");
      results[0].addComment("Projection offsets and multipliers have been changed from");
      results[0].addComment("defaults. New values are below.");
      log->addGroup(results);
    }

    p.EndProcess();

    return;
  }
}
+11 −0
Original line number Diff line number Diff line
#ifndef pds2isis_h
#define pds2isis_h

#include "Pvl.h"
#include "UserInterface.h"

namespace Isis{
  extern void pds2isis(UserInterface &ui, Pvl *log);
}

#endif
+0 −4
Original line number Diff line number Diff line
BLANKS = "%-6s"    
LENGTH = "%-40s"

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


include $(ISISROOT)/make/isismake.tsts

# Test translation of PDS BAND_BIN group with BAND_BIN prefixed keywords.
commands:
	$(APPNAME) from=$(INPUT)/gaspra_nims_hires_radiance.lbl \
	  to=$(OUTPUT)/gaspra_nims_hires_radiance.cub > /dev/null; \
	catlab from=$(OUTPUT)/gaspra_nims_hires_radiance.cub \
	  to=$(OUTPUT)/gaspra_nims_hires_radiance.pvl > /dev/null;
Loading