Commit f6a19990 authored by Stuart Sides's avatar Stuart Sides
Browse files

Fixed test

parent 05140137
Loading
Loading
Loading
Loading
+34 −21
Original line number Diff line number Diff line
@@ -29,34 +29,36 @@ void IsisMain() {
  mainLabel = importFits.fitsLabel(0);

  // Get the first label and make sure this is a New Horizons LEISA file
  if (!mainLabel.hasKeyword("MISSION") || !mainLabel.hasKeyword("INSTRU") ||
      mainLabel["MISSION"][0] != "New Horizons" || mainLabel["INSTRU"][0] != "lei") {
  if (!mainLabel.hasKeyword("MISSION") || !mainLabel.hasKeyword("INSTRU")) {
    QString msg = QObject::tr("Input file [%1] does not appear to be a New Horizons LEISA FITS "
                              "file. Input file label value for MISSION is [%2], "
                              "INSTRU is [%3]").
                              "file. Input file label key MISSION or INSTRU is missing").
                  arg(ui.GetFileName("FROM"));
    throw IException(IException::User, msg, _FILEINFO_);
  }
  else if (mainLabel["MISSION"][0] != "New Horizons" || mainLabel["INSTRU"][0] != "lei") {
    QString msg = QObject::tr("Input file [%1] does not appear to be a New Horizons LEISA FITS "
                              "file. Input file label value for MISSION is [%2], INSTRU is [%3]").
                  arg(ui.GetFileName("FROM")).arg(mainLabel["MISSION"][0]).
                  arg(mainLabel["INSTRU"][0]);
    throw IException(IException::User, msg, _FILEINFO_);
  }

  // Check to see if the error image was requested from the FITS file and 
  // Check to see if the calibration error image was requested from the FITS file and 
  // that it has the corresponding extension
  if (ui.WasEntered("ERRORMAP")) {
    PvlGroup extensionLabel = importFits.fitsLabel(5); 
    PvlGroup extensionLabel; 
    try {
      extensionLabel = importFits.fitsLabel(5);
    }
    catch (IException &e) {
      if (!extensionLabel.hasKeyword("XTENSION")) {
        QString msg = QObject::tr("Input file [%1] does not appear to be a calibrated New Horizons "
                                "LEISA FITS file. There is no errormap "
                                "extension").arg(ui.GetFileName("FROM"));

      throw IException(e, IException::Unknown, msg, _FILEINFO_);
                      "LEISA FITS file. XTENSION keyword is missing in the fifth extension.")
                      .arg(ui.GetFileName("FROM"));
        throw IException(IException::Unknown, msg, _FILEINFO_);
      }

      if (!extensionLabel.hasKeyword("EXTNAME")) {
        QString msg = QObject::tr("Input file [%1] does not appear to contain a New Horizons LEISA "
                                "calibrated image. FITS label keyword EXTNAME is missing").
                      "calibrated image. FITS label keyword EXTNAME is missing in the fifth extension").
                      arg(ui.GetFileName("FROM"));
        throw IException(IException::User, msg, _FILEINFO_);
      }
@@ -67,25 +69,29 @@ void IsisMain() {
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }
    catch (IException &e) {
      QString msg = QObject::tr("Unable to find errormap extension in [%1]").arg(ui.GetFileName("FROM"));
      throw IException(e, IException::Unknown, msg, _FILEINFO_);
    }

  }

  // Check to see if the quality image was requested from the FITS file and 
  // that it has the corresponding extension
  if (ui.WasEntered("QUALITY")) {
    PvlGroup  extensionLabel = importFits.fitsLabel(6); 
    PvlGroup  extensionLabel; 
    try {
      extensionLabel = importFits.fitsLabel(6); 
    }
    catch (IException &e) {
      if (!extensionLabel.hasKeyword("XTENSION")) {
        QString msg = QObject::tr("Input file [%1] does not appear to be a calibrated New Horizons "
                                "LEISA FITS file. There is no quality "
                                "extension").arg(ui.GetFileName("FROM"));

      throw IException(e, IException::Unknown, msg, _FILEINFO_);
                      "LEISA FITS file. XTENSION keyword is missing in the sixth extension.")
                      .arg(ui.GetFileName("FROM"));
        throw IException(IException::Unknown, msg, _FILEINFO_);
      }

      if (!extensionLabel.hasKeyword("EXTNAME")) {
        QString msg = QObject::tr("Input file [%1] does not appear to contain a New Horizons LEISA "
                                "calibrated image. FITS label keyword EXTNAME is missing").
                      "calibrated image. FITS label keyword EXTNAME is missing in the sixth extension").
                      arg(ui.GetFileName("FROM"));
        throw IException(IException::User, msg, _FILEINFO_);
      }
@@ -96,6 +102,13 @@ void IsisMain() {
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }
    catch (IException &e) {
      QString msg = QObject::tr("Unable to find quality extension in [%1]").arg(ui.GetFileName("FROM"));
      throw IException(e, IException::Unknown, msg, _FILEINFO_);
    }


  }

  // Import the primary image (LEISA raw/calibrated)
  importFits.SetOrganization(ProcessImport::BIL);
+72 −0
Original line number Diff line number Diff line
@@ -20,4 +20,76 @@ commands:
	  > /dev/null;
	catlab from=$(OUTPUT)/lsb_0034933739_0x53c_sci_1_Quality.cub > \
	  $(OUTPUT)/lsb_0034933739_0x53c_sci_1_Quality.pvl;
	# Test for the calibration error image name
	$(SED) 's+XTENSION+XTEN-ION+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  errormap=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_error-xtension-key.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
	# Test for the calibration error image extension name
	$(SED) 's+EXTNAME+EXzNAME+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  errormap=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_error-extname-key.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
	# Test for the calibration error image extension name incorrect
	$(SED) 's+EXTNAME = '"'"'ERRORMAP+EXTNAME = '"'"'ERRxRMAP+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  errormap=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_error-extname-value.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
	# Test for the calibration quality image name
	$(SED) 's+XTENSION+XTEN-ION+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  quality=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_quality-xtension-key.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
	# Test for the calibration quality image extension name
	$(SED) 's+EXTNAME+EXzNAME+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  quality=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_quality-extname-key.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
	# Test for the calibration quality image extension name incorrect
	$(SED) 's+EXTNAME = '"'"'QUALITY+EXTNAME = '"'"'QUAxITY+g' \
	$(INPUT)/lsb_0034933739_0x53c_sci_1.fit > $(OUTPUT)/temp.fit
	if [ `$(APPNAME) \
	  from=$(OUTPUT)/temp.fit \
	  to=$(OUTPUT)/junk.cub \
	  quality=true \
	  >& $(OUTPUT)/temp.txt` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(temp.fit\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/error_quality-extname-value.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.fit;
+30 −26
Original line number Diff line number Diff line
@@ -38,13 +38,34 @@ void IsisMain() {
  PvlGroup mainLabel = importFits.fitsLabel(0);
  if (mainLabel["MISSION"][0] != "New Horizons" || mainLabel["INSTRU"][0] != "lor") {
    QString msg = QObject::tr("Input file [%1] does not appear to be a New Horizons LORRI FITS "
                              "file. Input file label value for MISSION is [%2], "
                              "INSTRU is [%3]").
                  arg(ui.GetFileName("FROM")).arg(mainLabel["MISSION"][0]).
                  arg(mainLabel["INSTRU"][0]);
    "file. Input file label value for MISSION is [%2] and INSTRU is [%3]").
    arg(ui.GetFileName("FROM")).arg(mainLabel["MISSION"][0]).arg(mainLabel["INSTRU"][0]);
    throw IException(IException::User, msg, _FILEINFO_);
  }

  // Get the label of extension #1 and make sure this is a New Horizons LORRI Error image
  if (ui.WasEntered("ERROR")) {
    PvlGroup errorLabel = importFits.fitsLabel(1);
    if (errorLabel["XTENSION"][0] != "IMAGE" || errorLabel["EXTNAME"][0] != "LORRI Error image") {
      QString msg = QObject::tr("Input file [%1] does not appear to contain a LORRI Error image. "
          "Input file label value for EXTNAME is [%2] and XTENSION is [%3]").
          arg(ui.GetFileName("FROM")).arg(errorLabel["EXTNAME"][0]).arg(errorLabel["XTENSION"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }

  // Get the label of extension #2 and make sure this is a New Horizons LORRI Quality image
  if (ui.WasEntered("QUALITY")) {
    PvlGroup qualityLabel = importFits.fitsLabel(2);
    if (qualityLabel["XTENSION"][0] != "IMAGE" || 
        qualityLabel["EXTNAME"][0] != "LORRI Quality flag image") {
      QString msg = QObject::tr("Input file [%1] does not appear to contain a LORRI Quality image. "
          "Input file label value for EXTNAME is [%2] and XTENSION is [%3]").
          arg(ui.GetFileName("FROM")).arg(qualityLabel["EXTNAME"][0]).arg(qualityLabel["XTENSION"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }

  importFits.setProcessFileStructure(0);

  Cube *output = importFits.SetOutputCube("TO");
@@ -106,14 +127,6 @@ void IsisMain() {

  // Convert the Error image. It is currently assumed to be the second image in the FITS file
  if (ui.WasEntered("ERROR")) {
    // Get the label of the Error image and make sure this is a New Horizons LORRI Error image
    PvlGroup errorLabel = importFits.fitsLabel(1);
    if (errorLabel["XTENSION"][0] != "IMAGE" || errorLabel["EXTNAME"][0] != "LORRI Error image") {
      QString msg = QObject::tr("Input file [%1] does not appear to contain a LORRI Error image "
                                "Input file label value for EXTNAME is [%2]").
                    arg(ui.GetFileName("FROM")).arg(mainLabel["EXTNAME"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }

    importFits.setProcessFileStructure(1);

@@ -134,15 +147,6 @@ void IsisMain() {

  // Convert the Quality image. It is currently assumed to be the third image in the FITS file
  if (ui.WasEntered("QUALITY")) {
    // Get the label of the Quality image and make sure this is a New Horizons LORRI Quality image
    PvlGroup errorLabel = importFits.fitsLabel(2);
    if (errorLabel["XTENSION"][0] != "IMAGE" || 
        errorLabel["EXTNAME"][0] != "LORRI Quality flag image") {
      QString msg = QObject::tr("Input file [%1] does not appear to contain a LORRI Quality image "
                                "Input file label value for EXTNAME is [%2]").
                    arg(ui.GetFileName("FROM")).arg(mainLabel["EXTNAME"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }

    importFits.setProcessFileStructure(2);

@@ -173,9 +177,9 @@ void IsisMain() {
}


void flip(Buffer &in) {
  for(int i = 0; i < in.size() / 2; i++) {
    swap(in[i], in[in.size() - i - 1]);
  }
}
//void flip(Buffer &in) {
//  for(int i = 0; i < in.size() / 2; i++) {
//    swap(in[i], in[in.size() - i - 1]);
//  }
//}
+14 −76
Original line number Diff line number Diff line
@@ -60,32 +60,16 @@ void IsisMain() {
    throw IException(IException::User, msg, _FILEINFO_);
  }

  if (!primaryLabel.hasKeyword("BITPIX", Pvl::Traverse)) {
    FileName in = ui.GetFileName("FROM");
    QString msg = "Input file [" + in.expanded() + "] does not appear to be " +
                  "in New Horizons/MVIC FITS format. BITPIX keyword is missing.";
    throw IException(IException::User, msg, _FILEINFO_);
  }


  // Check to see if the undistorted image was requested from the FITS file and that it has the 
  // corresponding extension and keywords
  if (ui.WasEntered("UNDISTORTED")) {
    PvlGroup undistortedLabel = importFits.fitsLabel(1);
    if (!undistortedLabel.hasKeyword("XTENSION") || !undistortedLabel.hasKeyword("COMMENT") ||
        undistortedLabel["XTENSION"][0] != "IMAGE" || 
        !undistortedLabel["COMMENT"][0].startsWith("This is the bias-subtracted, flattened, distortion-removed image cube.")) {
    if (!undistortedLabel.hasKeyword("COMMENT") ||
        !undistortedLabel["COMMENT"][0].startsWith("This is the bias-subtracted, "
                                                   "flattened, distortion-removed image cube.")) {

      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC Undistorted image. "
                                "FITS label value for EXTNAME is [%2]").
                             arg(ui.GetFileName("FROM")).arg(undistortedLabel["EXTNAME"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }

    if (!undistortedLabel.hasKeyword("BITPIX")) {
      FileName in = ui.GetFileName("FROM");
      QString msg = "Input file [" + in.expanded() + "] does not appear to be " +
                    "in New Horizons/MVIC FITS format. BITPIX keyword is missing from label [1].";
      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC undistorted "
                                "image in XTENSION [2]").arg(ui.GetFileName("FROM"));
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
@@ -94,20 +78,11 @@ void IsisMain() {
  // corresponding extension and keywords
  if (ui.WasEntered("ERROR")) {
    PvlGroup errorLabel = importFits.fitsLabel(2);
    if (!errorLabel.hasKeyword("XTENSION") || !errorLabel.hasKeyword("COMMENT") ||
        errorLabel["XTENSION"][0] != "IMAGE" || 
    if (!errorLabel.hasKeyword("COMMENT") ||
        errorLabel["COMMENT"][0] != "1-sigma error per pixel for the image in extension 1.") {

      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC Error image. "
                                "FITS label value for EXTNAME is [%2]").
                    arg(ui.GetFileName("FROM")).arg(errorLabel["EXTNAME"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }

    if (!errorLabel.hasKeyword("BITPIX")) {
      FileName in = ui.GetFileName("FROM");
      QString msg = "Input file [" + in.expanded() + "] does not appear to be " +
                    "in New Horizons/MVIC FITS format. BITPIX keyword is missing from label [2].";
      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC Error image "
                                "in the XTENSION [3]").arg(ui.GetFileName("FROM"));
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
@@ -116,25 +91,15 @@ void IsisMain() {
  // corresponding extension and keywords
  if (ui.WasEntered("QUALITY")) {
    PvlGroup qualityLabel = importFits.fitsLabel(3);
    if (!qualityLabel.hasKeyword("XTENSION") || !qualityLabel.hasKeyword("COMMENT") ||
        qualityLabel["XTENSION"][0] != "IMAGE" || 
    if (!qualityLabel.hasKeyword("COMMENT") ||
        qualityLabel["COMMENT"][0] != "Data quality flag for the image in extension 1.") {

      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC Quality image. "
                                "FITS label value for EXTNAME is [%2]").
                    arg(ui.GetFileName("FROM")).arg(qualityLabel["EXTNAME"][0]);
      throw IException(IException::User, msg, _FILEINFO_);
    }

    if (!qualityLabel.hasKeyword("BITPIX")) {
      FileName in = ui.GetFileName("FROM");
      QString msg = "Input file [" + in.expanded() + "] does not appear to be " +
                    "in New Horizons/MVIC FITS format. BITPIX keyword is missing from label [3].";
      QString msg = QObject::tr("Input file [%1] does not appear to contain an MVIC Quality image "
                                "in extension [3]").arg(ui.GetFileName("FROM"));
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }


  // Convert the primary image 
  QString bitpix = primaryLabel.findKeyword("BITPIX", Pvl::Traverse);
  int bytesPerPix = abs(toInt(bitpix)) / 8;
@@ -255,6 +220,7 @@ void translateLabels(Pvl &label, Cube *ocube) {
  instId = instId + "_" + scanType;
  inst.addKeyword(PvlKeyword("InstrumentId", instId), PvlGroup::Replace);

  // Not tested because we didn't have any files that do this at the time the test were done
  QString target = (QString)inst["TargetName"];
  if (target.startsWith("RADEC=")) {
    inst.addKeyword(PvlKeyword("TargetName", "Sky"), PvlGroup::Replace);
@@ -359,53 +325,25 @@ void translateLabels(Pvl &label, Cube *ocube) {
    if (calibration.hasKeyword("TdiRate")) {
      calibration.findKeyword("TdiRate").setUnits("hz");
    }
    if (calibration.hasKeyword("SolarSpectrumResolved")) {
    // The following do not need hasKeyword tests because the translater creats them everytime
    // due to them having default values if none is in the FITS file.
    calibration.findKeyword("SolarSpectrumResolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("SolarSpectrumUnresolved")) {
    calibration.findKeyword("SolarSpectrumUnresolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("PholusSpectrumResolved")) {
    calibration.findKeyword("PholusSpectrumResolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("PholusSpectrumUnresolved")) {
    calibration.findKeyword("PholusSpectrumUnresolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("CharonSpectrumResolved")) {
    calibration.findKeyword("CharonSpectrumResolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("CharonSpectrumUnresolved")) {
    calibration.findKeyword("CharonSpectrumUnresolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("JupiterSpectrumResolved")) {
    calibration.findKeyword("JupiterSpectrumResolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("JupiterSpectrumUnresolved")) {
    calibration.findKeyword("JupiterSpectrumUnresolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("PlutoSpectrumResolved")) {
    calibration.findKeyword("PlutoSpectrumResolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("PlutoSpectrumUnresolved")) {
    calibration.findKeyword("PlutoSpectrumUnresolved").setUnits("(erg/cm^2/s/sr)/(DN/s/pix)");
    }
    if (calibration.hasKeyword("SolarPivotWavelength")) {
    calibration.findKeyword("SolarPivotWavelength").setUnits("cm");
    }
    if (calibration.hasKeyword("JupiterPivotWavelength")) {
    calibration.findKeyword("JupiterPivotWavelength").setUnits("cm");
    }
    if (calibration.hasKeyword("PholusPivotWavelength")) {
    calibration.findKeyword("PholusPivotWavelength").setUnits("cm");
    }
    if (calibration.hasKeyword("PlutoPivotWavelength")) {
    calibration.findKeyword("PlutoPivotWavelength").setUnits("cm");
    }
    if (calibration.hasKeyword("CharonPivotWavelength")) {
    calibration.findKeyword("CharonPivotWavelength").setUnits("cm");
  }
}
}


//void flip(Buffer &in) {