Commit d59bb70f authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Changed ContaminationEvent keyword names to EmpiricalCorrection for...

Changed ContaminationEvent keyword names to EmpiricalCorrection for Messenger's mdiscal. Also added the ability for users to turn this correction off and added the keyword to the output PDS product for mdis2pds. In addition, fixed a bug in mdiscal so that it now will perform linearity, absolute coefficient, and smear corrections even when flat field correction is turned off. Increased the ProductId version and software versions for these programs also. Fixes #2332, #2333, #2338

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6372 41f8697f-d340-4b68-9986-7bafba869bb8
parent 6692b875
Loading
Loading
Loading
Loading
+133 −122
Original line number Diff line number Diff line
#include "Isis.h"

#include <cmath>
#include <string>
#include <sstream>
#include <fstream>
#include <sstream>
#include <string>

#include "UserInterface.h"
#include "Progress.h"
#include "FileName.h"
#include "IException.h"
#include "ProcessExportPds.h"
#include "BufferManager.h"
#include "Cube.h"
#include "FileName.h"
#include "Histogram.h"
#include "IException.h"
#include "IString.h"
#include "LineManager.h"
#include "OriginalLabel.h"
#include "ProcessExportPds.h"
#include "Progress.h"
#include "PvlTranslationManager.h"
#include "BufferManager.h"
#include "LineManager.h"
#include "UserInterface.h"

using namespace std;
using namespace Isis;

inline QString Quote(const QString &value, const char qChar = '"') {
inline QString quote(const QString &value, const char qChar='"') {
  if (value.isEmpty()) return (value);
  if (value[0] == qChar) return (value);
  return (QString(qChar + value + qChar));
}

inline double SetRound(double value, const int precision) {
inline double setRound(double value, const int precision) {
  double scale = pow(10.0, precision);
  value = rint(value * scale) / scale;
  return (value);
}

inline void ValidateUnit(PvlKeyword &key, const QString &kunit) {
inline void validateUnit(PvlKeyword &key, const QString &kunit) {
  PvlKeyword temp = key;
  key.clear();
  for (int i = 0; i < temp.size(); i++) {
    try {
      //  If this works, check unit, otherwise an exception is thrown
      (void) toDouble(temp[i]);
      toDouble(temp[i]);
      QString unit = temp.unit(i);
      if (unit.isEmpty()) unit = kunit;
      key.addValue(temp[i], unit);
@@ -51,46 +51,46 @@ inline void ValidateUnit(PvlKeyword &key, const QString &kunit) {
  return;
}

inline void FixUnit(PvlObject &obj, const QString &key, const QString &unit) {
inline void fixUnit(PvlObject &obj, const QString &key, const QString &unit) {
  if (obj.hasKeyword(key, PvlObject::Traverse)) {
    ValidateUnit(obj.findKeyword(key, PvlObject::Traverse), unit);
    validateUnit(obj.findKeyword(key, PvlObject::Traverse), unit);
  }
  return;
}

inline void FixQuotes(PvlContainer &kcont, const QString &value = "N/A") {
inline void fixQuotes(PvlContainer &kcont, const QString &value="N/A") {
  PvlContainer::PvlKeywordIterator kiter;
  for (kiter = kcont.begin(); kiter != kcont.end(); ++kiter) {
    for (int nv = 0; nv < kiter->size(); nv++) {
      if((*kiter)[nv] == value)(*kiter)[nv] = Quote((*kiter)[nv]);
      if ((*kiter)[nv] == value)(*kiter)[nv] = quote((*kiter)[nv]);
    }
  }
}

inline void FixLabels(PvlObject &obj) {
inline void fixLabels(PvlObject &obj) {
  // Current object-owned keywords
  FixQuotes(obj);
  fixQuotes(obj);

  // Fix all nested objects
  PvlObject::PvlObjectIterator o;
  for (o = obj.beginObject(); o != obj.endObject(); ++o) {
    FixLabels(*o);
    fixLabels(*o);
  }

  // Fix local groups
  PvlObject::PvlGroupIterator g;
  for (g = obj.beginGroup(); g != obj.endGroup(); ++g) {
    FixQuotes(*g);
    fixQuotes(*g);
  }
  return;
}


void IsisMain() {
  const QString mdis2pds_program = "mdis2pds";
  const QString mdis2pds_version = "1.0";
  const QString mdis2pds_revision = "$Revision$";
  const QString mdis2pds_runtime = Application::DateTime();
  const QString mdis2pdsProgram = "mdis2pds";
  const QString mdis2pdsVersion = "1.1";
  const QString mdis2pdsRevision = "$Revision$";
  const QString mdis2pdsRuntime = Application::DateTime();

  UserInterface &ui = Application::GetUserInterface();
  FileName input(ui.GetFileName("FROM"));
@@ -104,6 +104,14 @@ void IsisMain() {
  Histogram *hist = incube->histogram(0);
  double minmin = 0.0;
  double maxmax = 0.0;
  // if the type of calibration is automatic and
  //     1) the given min percent is valid, then set minmin to the percent obtained from this min
  //     2) the given min percent is not valid, then set minmin to the histogram's min
  //     3) the given max percent is valid, then set maxmax to the percent obtained from this max
  //     4) the given max percent is not valid, then set maxmax to the histogram's max
  // Otherwise, (calibration is manual)
  //     set minmin to the given min value
  //     set maxmax to the given max value
  if (ui.GetString("TYPE").compare("AUTOMATIC") == 0) {
    minmin = (ui.GetDouble("MINPER") <= 0.000001) ?
             hist->Minimum() :
@@ -155,7 +163,8 @@ void IsisMain() {
    processPds.SetOutputHis(HIGH_INSTR_SAT4);
    dataSetID += "4";
  }
  else if(nbits > 8  &&  nbits < 16) {
  else if (nbits < 16) { // 8 < nbits < 16
                         // NOTE: xml restricts BITS to between 8 and 32, inclusive
    processPds.SetOutputType(UnsignedWord);
    processPds.SetOutputRange(3.0, pow(2.0, (double)(nbits)) - 3.0);
    processPds.SetOutputNull(0);
@@ -165,8 +174,8 @@ void IsisMain() {
    processPds.SetOutputHrs(pow(2.0, (double)(nbits)) - 1.0);
    dataSetID += "0";
  }
  else {
    QString msg = "[" + QString(nbits) + "] is not a supported bit length.";
  else { // 16 < nbits < 32 
    QString msg = "[" + toString(nbits) + "] is not a supported bit length.";
    throw IException(IException::User, msg, _FILEINFO_);
  }
  dataSetID += "-CDR-CALDATA-V1.0";
@@ -193,58 +202,31 @@ void IsisMain() {
  // Translates the ISIS labels along with the original EDR labels
  origLabel.addObject(*(incube->label()));
  PvlTranslationManager labels(origLabel,
                               "$messenger/translations/mdisCdrLabel.trn");
                               "$messenger/translations/mdisCDRLabel.trn");
  labels.Auto(pdsLabel);

  p.CheckStatus();

  // Add keyword comments
  PvlKeyword &recordType(pdsLabel.findKeyword("RECORD_TYPE"));
  recordType.addComment("/*** FILE FORMAT ***/");

  PvlKeyword &image(pdsLabel.findKeyword("^IMAGE"));
  image.addComment("/*** POINTERS TO START BYTE OFFSET OF OBJECTS IN IMAGE FILE ***/");

  PvlKeyword &missionName(pdsLabel.findKeyword("MISSION_NAME"));
  missionName.addComment("/*** GENERAL DATA DESCRIPTION PARAMETERS ***/");

  PvlKeyword &startTime(pdsLabel.findKeyword("START_TIME"));
  startTime.addComment("/*** TIME PARAMETERS ***/");

  PvlKeyword &instrumentName(pdsLabel.findKeyword("INSTRUMENT_NAME"));
  instrumentName.addComment("/*** INSTRUMENT ENGINEERING PARAMETERS ***/");

  PvlKeyword &messMetExp(pdsLabel.findKeyword("MESS:MET_EXP"));
  messMetExp.addComment("/*** INSTRUMENT RAW PARAMETERS ***/");

  PvlKeyword &geometry(pdsLabel.findKeyword("RIGHT_ASCENSION"));
  geometry.addComment("/*** GEOMETRY INFORMATION ***/");

  PvlKeyword &target(pdsLabel.findKeyword("SC_TARGET_POSITION_VECTOR"));
  target.addComment("/*** TARGET PARAMETERS ***/");

  PvlKeyword &sensor(pdsLabel.findKeyword("SLANT_DISTANCE"));
  sensor.addComment("/*** TARGET WITHIN SENSOR FOV ***/");

  PvlKeyword &spacecraftPosition(pdsLabel.findKeyword("SUB_SPACECRAFT_LATITUDE"));
  spacecraftPosition.addComment("/*** SPACECRAFT POSITION WITH RESPECT TO CENTRAL BODY ***/");

  PvlKeyword &spacecraftLocation(pdsLabel.findKeyword("SPACECRAFT_SOLAR_DISTANCE"));
  spacecraftLocation.addComment("/*** SPACECRAFT LOCATION ***/");

  PvlKeyword &solarDistance(pdsLabel.findKeyword("SOLAR_DISTANCE"));
  solarDistance.addComment("/*** VIEWING AND LIGHTING GEOMETRY (SUN ON TARGET) ***/");

  PvlGroup &subframe(pdsLabel.findGroup("SUBFRAME1_PARAMETERS"));
  subframe.addComment("/*** GEOMETRY FOR EACH SUBFRAME ***/");
  // The translation file automatically adds this keyword from
  // "EmpiricalCorrectionFactor" using a default of "N/A" if not found. This
  // keyword was previously named "ContaminationEventFactor"
  // So here we replace the "N/A" with the value of the keyword
  // "ContaminationEventFactor", if it exists.
  PvlKeyword &empiricalCorrection(pdsLabel.findKeyword("MESS:EC_FACTOR"));
  if (empiricalCorrection[0] == "N/A") {
    if (incube->label()->hasKeyword("ContaminationEventFactor", Pvl::Traverse)) {
      empiricalCorrection.setValue(incube->label()->findKeyword("ContaminationEventFactor", 
                                                                Pvl::Traverse)[0]);
    }
  }

  p.CheckStatus();

  // Creates keywords from the input's hist above
  PvlKeyword minDn("MINIMUM", toString(SetRound(hist->Minimum(), 16)));
  PvlKeyword maxDn("MAXIMUM", toString(SetRound(hist->Maximum(), 16)));
  PvlKeyword meanDn("MEAN", toString(SetRound(hist->Average(), 16)));
  PvlKeyword stddev("STANDARD_DEVIATION", toString(SetRound(hist->StandardDeviation(), 16)));
  PvlKeyword minDn("MINIMUM", toString(setRound(hist->Minimum(), 16)));
  PvlKeyword maxDn("MAXIMUM", toString(setRound(hist->Maximum(), 16)));
  PvlKeyword meanDn("MEAN", toString(setRound(hist->Average(), 16)));
  PvlKeyword stddev("STANDARD_DEVIATION", toString(setRound(hist->StandardDeviation(), 16)));

  PvlKeyword saturated("SATURATED_PIXEL_COUNT", toString(hist->HisPixels()));

@@ -257,74 +239,101 @@ void IsisMain() {
  imageObj.addKeyword(stddev);
  saturated.addComment("/*** PIXEL COUNTS ***/");
  imageObj.addKeyword(saturated);
  if(imageObj.hasKeyword("DARK_STRIP_MEAN")) {
  // This line is commented out since mdisCDRLabel.trn automatically creates a
  // DARK_STRIP_MEAN keyword with default = N/A if it is not found in the input cube
  // if (imageObj.hasKeyword("DARK_STRIP_MEAN")) {
  PvlKeyword &darkStripMean = imageObj.findKeyword("DARK_STRIP_MEAN");

  try {
      if(darkStripMean.size() > 0) {
        darkStripMean[0] = toString(SetRound(toDouble(darkStripMean[0]), 16));
      }
    darkStripMean[0] = toString(setRound(toDouble(darkStripMean[0]), 16));
  }
  catch (IException &) {
    // If we fail to convert this keyword to a number, then preserve
    // its existing value
  }
  }
  //}

  p.CheckStatus();

  // Fixes bad keywords
  PvlKeyword &data_set_id = pdsLabel.findKeyword("DATA_SET_ID", Pvl::Traverse);
  data_set_id.setValue(dataSetID);
  PvlKeyword &product_id = pdsLabel.findKeyword("PRODUCT_ID", Pvl::Traverse);
  if((product_id.size() == 0) || ((product_id.size() > 0) && (product_id[0] == "N/A"))) {
    product_id.setValue(output.baseName());
  // data set id
  PvlKeyword &dataSetIdKeyword = pdsLabel.findKeyword("DATA_SET_ID", 
                                                      Pvl::Traverse);
  dataSetIdKeyword.setValue(dataSetID);
  
  // product id
  PvlKeyword &productIdKeyword = pdsLabel.findKeyword("PRODUCT_ID", 
                                                      Pvl::Traverse);
  if (productIdKeyword[0] == "N/A") {
    productIdKeyword.setValue(output.baseName());
  }
  PvlKeyword &product_creation_time = pdsLabel.findKeyword("PRODUCT_CREATION_TIME", Pvl::Traverse);
  product_creation_time.setValue(mdis2pds_runtime);
  
  PvlKeyword &software_name = pdsLabel.findKeyword("SOFTWARE_NAME", Pvl::Traverse);
  if((software_name.size() > 0) && (software_name[0] == "N/A")) {
    software_name.setValue(mdis2pds_program);
  // product creation time
  PvlKeyword &productCreationTimeKeyword = pdsLabel.findKeyword("PRODUCT_CREATION_TIME", 
                                                                Pvl::Traverse);
  productCreationTimeKeyword.setValue(mdis2pdsRuntime);
  
  // software name
  PvlKeyword &softwareNameKeyword = pdsLabel.findKeyword("SOFTWARE_NAME", 
                                                         Pvl::Traverse);
  if (softwareNameKeyword[0] == "N/A") {
    softwareNameKeyword.setValue(mdis2pdsProgram);
  }
  
  PvlKeyword &software_version_id = pdsLabel.findKeyword("SOFTWARE_VERSION_ID", Pvl::Traverse);
  if(software_version_id.size() > 0) {
    if(software_version_id[0] == "N/A") {
      software_version_id.setValue(Quote(mdis2pds_version));
  // software version id
  PvlKeyword &softwareVersionIdKeyword = pdsLabel.findKeyword("SOFTWARE_VERSION_ID", 
                                                              Pvl::Traverse);
  if (softwareVersionIdKeyword[0] == "N/A") {
    softwareVersionIdKeyword.setValue(quote(mdis2pdsVersion));
  }
  else {
      software_version_id.setValue(software_version_id[0]);
    }
    softwareVersionIdKeyword.setValue(softwareVersionIdKeyword[0]);
  }
  
  PvlKeyword &filter_number = pdsLabel.findKeyword("FILTER_NUMBER", Pvl::Traverse);
  if((filter_number.size() > 0)) {
    filter_number.setValue(Quote(filter_number[0]));
  // filter number
  PvlKeyword &filterNumberKeyword = pdsLabel.findKeyword("FILTER_NUMBER", 
                                                         Pvl::Traverse);
  if ((filterNumberKeyword.size() > 0)) {
    filterNumberKeyword.setValue(quote(filterNumberKeyword[0]));
  }


  // Add quotes
  PvlKeyword &data_quality_id = pdsLabel.findKeyword("DATA_QUALITY_ID", Pvl::Traverse);
  data_quality_id.setValue(Quote(data_quality_id));
  PvlKeyword &sequence_name = pdsLabel.findKeyword("SEQUENCE_NAME", Pvl::Traverse);
  sequence_name.setValue(Quote(sequence_name));

  PvlKeyword &start_count = pdsLabel.findKeyword("SPACECRAFT_CLOCK_START_COUNT", Pvl::Traverse);
  start_count.setValue(Quote(start_count));
  PvlKeyword &stop_count = pdsLabel.findKeyword("SPACECRAFT_CLOCK_STOP_COUNT", Pvl::Traverse);
  stop_count.setValue(Quote(stop_count));

  PvlKeyword &site_id = pdsLabel.findKeyword("SITE_ID", Pvl::Traverse);
  site_id.setValue(Quote(site_id));
  PvlKeyword &source_product_id = pdsLabel.findKeyword("SOURCE_PRODUCT_ID", Pvl::Traverse);
  for(int i = 0; i < source_product_id.size(); i++) {
    source_product_id[i] = Quote(source_product_id[i]);
  // data quality id
  PvlKeyword &dataQualityIdKeyword = pdsLabel.findKeyword("DATA_QUALITY_ID", 
                                                          Pvl::Traverse);
  dataQualityIdKeyword.setValue(quote(dataQualityIdKeyword));
  
  // sequence name
  PvlKeyword &sequenceNameKeyword = pdsLabel.findKeyword("SEQUENCE_NAME", 
                                                         Pvl::Traverse);
  sequenceNameKeyword.setValue(quote(sequenceNameKeyword));
  
  // spacecraft clock start count
  PvlKeyword &startCountKeyword = pdsLabel.findKeyword("SPACECRAFT_CLOCK_START_COUNT", 
                                                       Pvl::Traverse);
  startCountKeyword.setValue(quote(startCountKeyword));
  
  // spacecraft clock stop count
  PvlKeyword &stopCountKeyword = pdsLabel.findKeyword("SPACECRAFT_CLOCK_STOP_COUNT", 
                                                      Pvl::Traverse);
  stopCountKeyword.setValue(quote(stopCountKeyword));
  
  // site id
  PvlKeyword &siteIdKeyword = pdsLabel.findKeyword("SITE_ID", 
                                                   Pvl::Traverse);
  siteIdKeyword.setValue(quote(siteIdKeyword));
  
  // source product id
  PvlKeyword &sourceProductIdKeyword = pdsLabel.findKeyword("SOURCE_PRODUCT_ID", 
                                                            Pvl::Traverse);
  for (int i = 0; i < sourceProductIdKeyword.size(); i++) {
    sourceProductIdKeyword[i] = quote(sourceProductIdKeyword[i]);
  }

  //  Enforce parentheses for scalars
  if(source_product_id.size() == 1)
    source_product_id.setValue('(' + source_product_id[0] + ')');
  if (sourceProductIdKeyword.size() == 1) {
    sourceProductIdKeyword.setValue('(' + sourceProductIdKeyword[0] + ')');
  }

  // Removes keywords
  PvlObject &imageObject(pdsLabel.findObject("IMAGE"));
@@ -335,10 +344,10 @@ void IsisMain() {
  p.CheckStatus();

  //  Fix all the hosed units upon ingest.  They are illformed.
  FixUnit(pdsLabel, "RETICLE_POINT_RA", "DEG");
  FixUnit(pdsLabel, "RETICLE_POINT_DECLINATION", "DEG");
  FixUnit(pdsLabel, "RETICLE_POINT_LATITUDE", "DEG");
  FixUnit(pdsLabel, "RETICLE_POINT_LONGITUDE", "DEG");
  fixUnit(pdsLabel, "RETICLE_POINT_RA", "DEG");
  fixUnit(pdsLabel, "RETICLE_POINT_DECLINATION", "DEG");
  fixUnit(pdsLabel, "RETICLE_POINT_LATITUDE", "DEG");
  fixUnit(pdsLabel, "RETICLE_POINT_LONGITUDE", "DEG");

  //  Now address nested keywords in SUBFRAME groups
  for (int i = 1; i <= 5; i++) {
@@ -346,19 +355,21 @@ void IsisMain() {
    QString group = "SUBFRAME" + n + "_PARAMETERS";
    if (pdsLabel.hasGroup(group)) {
      PvlGroup &grp = pdsLabel.findGroup(group);
      ValidateUnit(grp.findKeyword("RETICLE_POINT_LATITUDE"), "DEG");
      ValidateUnit(grp.findKeyword("RETICLE_POINT_LONGITUDE"), "DEG");
      validateUnit(grp.findKeyword("RETICLE_POINT_LATITUDE"), "DEG");
      validateUnit(grp.findKeyword("RETICLE_POINT_LONGITUDE"), "DEG");
    }
  }

  p.CheckStatus();

//  Finally, fix keywords by Quoting missing N/A values
  FixLabels(pdsLabel);
  fixLabels(pdsLabel);
  p.CheckStatus();

  // All done...write result.
  ofstream outstream(output.expanded().toAscii().data());
  pdsLabel.setFormatTemplate("$messenger/templates/labels/mdisPdsCDR.pft");
  QString ofile(output.expanded());
  ofstream outstream(ofile.toAscii().data());
  processPds.OutputLabel(outstream);

  processPds.StartProcess(outstream);
+54 −21
Original line number Diff line number Diff line
@@ -7,12 +7,12 @@
  </brief>

  <description>
    <b>mdis2pds</b> will process a Messenger  MDIS cube and export it to PDS/CDR
    format.  The resulting file will have a PDS compliant label and data object 
    according to the SIS document.    <b>mdis2pds</b> assumes the input file has 
    at least been run through mdis2isis and mdiscal.  This will ensure that 
    proper values of the  PRODUCT_ID and SOURCE_PRODUCT_ID are included in the 
    output CDR label.  
    The <b>mdis2pds</b> program will process a Messenger  MDIS cube and export it to CDR type PDS
    product. The output file will have a PDS compliant label and a data object that contains the
    keywords described in the MDIS CDR/RDR SIS document (see link below). The input file must
    have been imported and calibrated using the ISIS programs mdis2isis and mdiscal, respectively.
    This will ensure that the proper values of the PRODUCT_ID and SOURCE_PRODUCT_ID are included in
    the output CDR label.  
  </description>

  <history>
@@ -21,7 +21,7 @@
    </change>
    <change name="Christopher Austin" date="2008-08-14">
      Shortened and optimized the code handling the histograms. Removed the
      32 bit strech.
      32 bit stretch.
    </change>
    <change name="Christopher Austin" date="2008-08-22">
      Fixed for correct source.  Previously was using incorrect comparison data.
@@ -42,24 +42,57 @@
    <change name="Kris Becker" date="2008-09-19">
      Fixed N/A quoting, misplaced units and data values that exceeded 20 
      characters.  Also quoted the SOFTWARE_VERSION_ID and FILTER_NUMBER 
        keyword values.  Added units to RETICLE_POINT_* keywords where missing.
      keyword values.  Added units to RETICLE_POINT_* keywords were missing.
    </change>
    <change name="Steven Lambright" date="2011-03-31">
      The DarkStripMean keyword can now be "N/A"
    </change>
    <change name="Kris Becker" date="2011-06-15">
        Added ORBIT_NUMBER to translation table for inclusion in output RDR 
        (CDR) file.
      Added ORBIT_NUMBER to translation table for inclusion in output RDR (CDR) file.
    </change>
    <change name="Kris Becker" date="2011-07-21">
      Added quotes to the SITE_ID keyword.
    </change>
    <change name="Jeannie Backer" date="2015-09-01">
      Added MESS:EC_FACTOR keyword to output label. Increased software version number to 1.1.
      Made code more compliant with ISIS coding standards. Added PDS format template for
      the output CDR product. Fixes #2333
    </change>
  </history>

  <category>
    <missionItem>Messenger</missionItem>
  </category>

  <seeAlso>
    <applications>
      <item>
        mdis2isis
      </item>
      <item>
        spiceinit
      </item>
      <item>
        mdiscal
      </item>
    </applications>
    <documents>
      <document>
        <title>
            MDIS CDR/RDR Software Interface Specification (SIS)
        </title>
        <source>
          <filename>MDIS_CDR_RDRSIS.PDF</filename>
          <path>http://pdsimage.wr.usgs.gov/Missions/MESSENGER/MSGRMDS_5001/DOCUMENT/</path>
        </source>
        <author>
          Scott Murchie, Alan Mick, Louise Prockter, Andrew Rivkin, 
          Edward Guinness, and Jennifer Ward
        </author>
      </document>
    </documents>
  </seeAlso>

  <groups>

    <group name="Files">
@@ -69,7 +102,7 @@
        <fileMode>input</fileMode>
        <brief> Input Messenger cube </brief>
        <description>
          Input filename of a messenger cube file to be exported into a cdr image.
          Input filename of a messenger cube file to be exported into a CDR image.
        </description>
        <filter> *.cub </filter>
      </parameter>
@@ -78,7 +111,7 @@
        <type>filename</type>
        <fileMode>output</fileMode>
        <brief>
          Final output filename.
          Final output filename
        </brief>
        <description>
          Output filename, by  default the filename will be generated from the
@@ -98,13 +131,13 @@
        </brief>
        <description>
          This parameter is used to select one of two ways to stretch output
          pixels.  The are AUTOMATIC or MANUAL.
          pixels.  They are AUTOMATIC or MANUAL.
        </description>
        <list>
          <option value="AUTOMATIC">
            <brief>Automatically calculate stretch</brief>
            <description>
              Automatically calculate stretch from the input cube. No strecth
              Automatically calculate stretch from the input cube. No stretch
              will be used if BITS equals 32, MINPER equals 0.0, and MAXPER
              equals 100.0.
            </description>
@@ -153,8 +186,8 @@
        </brief>
        <description>
          The cumulative percentage value to be mapped to the minimum 
          valid pixel for the specified number of bits. For example: With BITS=10
          and MINPER=1.0, the DN which corresponds to the cummulative
          valid pixel for the specified number of bits. For example, with BITS=10
          and MINPER=1.0, the DN which corresponds to the cumulative
          percent of 1.0 will be mapped to 3, where 0 represents NULL, 1
          represents LRS and 2 represents LIS.
        </description>
@@ -170,12 +203,12 @@
        <type>double</type>
        <default><item>100.0</item></default>
        <brief>
          Mazimum DN valid percentage
          Maximum DN valid percentage
        </brief>
        <description>
          The cumulative percentage value to be mapped to the maximum 
          valid pixel for the specified number of bits. For example: With BITS=10
          and MINPER=99.0, the DN which corresponds to the cummulative
          valid pixel for the specified number of bits. For example, with BITS=10
          and MINPER=99.0, the DN which corresponds to the cumulative
          percent of 99.0 will be mapped to 1021, 1021=(2**bits)-1-2. 
          Where 1023 represents HIS and 1022 represents HRS.
        </description>
@@ -201,8 +234,8 @@
        <description>
          The number of bits to compress the input data to. The valid data as
          well as the five special pixel values (NULL, LIS, LRS, HIS, HRS) will be
            compressed into this number of bits. The output data type will be
            automaticity choosen using this value. A value of 8 will create 
          compressed to this number of bits. The output data type will be
          automatically chosen using this value. A value of 8 will create 
          unsigned byte output files. Values from 9 to 16 will create unsigned
          word output files. Unused bits in the unsigned word output file will be
          set to zero.
+56 −0
Original line number Diff line number Diff line
# Tests BITS parameter for mdis2pds
#
# defaults to type=automatic, 
#             min = -1, 
#             max =  1, 
#             minper = 0, 
#             maxper = 100, 
# test with bits = 8, 12, 16
# test with bits = 4, 64 to test error throws
APPNAME = mdis2pds

output08bit.cub.TOLERANCE = 0.0000000002
output16bit.cub.TOLERANCE = 0.0000000002
output12bit.cub.TOLERANCE = 0.0000000002
#NOPREFERENCES=

include $(ISISROOT)/make/isismake.tsts

commands:
	# 8 bit
	$(APPNAME) from=$(INPUT)/EN0108840044M.cal.cub \
	to=$(OUTPUT)/output08bit \
	bits=8 > /dev/null;
	catlab from=$(OUTPUT)/output08bit.IMG \
	to=$(OUTPUT)/output08bit.pvl > /dev/null;
	pds2isis from=$(OUTPUT)/output08bit.IMG \
	to=$(OUTPUT)/output08bit > /dev/null;
	$(RM) $(OUTPUT)/output08bit.IMG;
	# 16 bit
	$(APPNAME) from=$(INPUT)/EN0108840044M.cal.cub \
	to=$(OUTPUT)/output16bit \
	bits=16 > /dev/null;
	catlab from=$(OUTPUT)/output16bit.IMG \
	to=$(OUTPUT)/output16bit.pvl > /dev/null;
	pds2isis from=$(OUTPUT)/output16bit.IMG \
	to=$(OUTPUT)/output16bit > /dev/null;
	$(RM) $(OUTPUT)/output16bit.IMG;
	# 12 bit
	$(APPNAME) from=$(INPUT)/EN0108840044M.cal.cub \
	to=$(OUTPUT)/output12bit \
	bits=12 > /dev/null;
	catlab from=$(OUTPUT)/output12bit.IMG \
	to=$(OUTPUT)/output12bit.pvl > /dev/null;
	pds2isis from=$(OUTPUT)/output12bit.IMG \
	to=$(OUTPUT)/output12bit > /dev/null;
	$(RM) $(OUTPUT)/output12bit.IMG;
	# Test for bits between 16 and 32
	if [[ `$(APPNAME) \
	  from=$(INPUT)/EN0108840044M.cal.cub \
	  to=$(OUTPUT)/output04bit \
	  bits=24 \
	  2>> $(OUTPUT)/error.txt` ]]; \
	then \
	  true; \
	fi;
	$(RM) $(OUTPUT)/output04bit.IMG;
+29 −8

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0
Original line number Diff line number Diff line
# Tests mdis2pds with user-defined (manual) stretch of -1 to 1.
#
# parameters  type=manual, 
#             min = -1, 
#             max =  1, 
# defaults to minper=0, 
#             maxper=100, 
#             bits=32
APPNAME = mdis2pds

output.cub.TOLERANCE = 0.0000000002
Loading