Commit 305767c9 authored by Jeannie Backer's avatar Jeannie Backer
Browse files

PROG: Updated distortion model documentation and boundary check. References #5155

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@8144 41f8697f-d340-4b68-9986-7bafba869bb8
parent b52e74ef
Loading
Loading
Loading
Loading
+31 −19
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ void IsisMain() {
  UserInterface &ui = Application::GetUserInterface();
  FileName xmlFileName = ui.GetFileName("FROM");

  try {
    ProcessImport importer;
    translateCoreInfo(xmlFileName, importer);

@@ -43,6 +44,11 @@ void IsisMain() {
    outputCube->write(xmlLabel);
  
    importer.EndProcess();
  }
  catch (IException &e) {
    QString msg = "Given file does not appear to be a valid TGO CaSSIS product.";
      throw IException(e, IException::User, msg, _FILEINFO_);
  }

  return;
}
@@ -199,16 +205,22 @@ void translateLabels(FileName &inputLabel, Cube *outputCube) {
    if (filter.compare("PAN", Qt::CaseInsensitive) == 0) {
      spacecraftCode = -143421;
    }
    if (filter.compare("RED", Qt::CaseInsensitive) == 0) {
    else if (filter.compare("RED", Qt::CaseInsensitive) == 0) {
      spacecraftCode = -143422;
    }
    if (filter.compare("NIR", Qt::CaseInsensitive) == 0) {
    else if (filter.compare("NIR", Qt::CaseInsensitive) == 0) {
      spacecraftCode = -143423;
    }
    if (filter.compare("BLU", Qt::CaseInsensitive) == 0) {
    else if (filter.compare("BLU", Qt::CaseInsensitive) == 0) {
      spacecraftCode = -143424;
    }
    else {
      QString msg = "Unrecognized filter name [" 
        + filter
        + "].";
        throw IException(IException::User, msg, _FILEINFO_);

    }
    // Add Kernel to BandBin Group
    bandBin.addKeyword(PvlKeyword("NaifIkCode", toString(spacecraftCode)));
  }
+3 −0
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@
    <change name="Makayla Shepherd" date="2017-05-30">
      Updated to work with XmlToPvlTranslationManager rename. Fixes #4889.
    </change>
    <change name="Jeannie Backer" date="2017-09-05">
      Added check to verify input input xml file corresponds to valid filter image. 
    </change>
  </history>

  <category>
+0 −19
Original line number Diff line number Diff line
# Added Kristin Berry 2017-12-21 for new test data and significant updates to tgocassisi2isis. 
# References # 4584

APPNAME = tgocassis2isis

include $(ISISROOT)/make/isismake.tsts

commands: 
# TEST: Throws an error for a bad Spacecraft name
	if [ `$(APPNAME) \
	  from=$(INPUT)/CAS-MCO-2016-11-26T22.35.51.907-RED-01033-B1-BROKEN.xml \
	  to=$(OUTPUT)/BROKEN.cub \
	  2>> $(OUTPUT)/error.txt > /dev/null` ]; \
	  then true; \
	  fi; 
# Cleanup
	$(RM) $(OUTPUT)/BROKEN.cub; 
     
+40 −0
Original line number Diff line number Diff line
# Verify that input is valid TGO CaSSIS image.
#
# history 2016-12-21 Kristin Berry - Original version. References # 4584
# history 2017-09-18 Jeannie Backer - Added checks for Instrument and Filter.

APPNAME = tgocassis2isis

include $(ISISROOT)/make/isismake.tsts

commands: 
# TEST: Throws an error for a bad Spacecraft name
	echo "Test SpacecraftName:" > $(OUTPUT)/errors.txt;
	if [ `$(APPNAME) \
	  from=$(INPUT)/CAS-MCO-2016-11-26T22.35.51.907-RED-01033-B1-SpacecraftError.xml \
	  to=$(OUTPUT)/BROKEN.cub \
	  2>> $(OUTPUT)/errors.txt > /dev/null` ]; \
	  then true; \
	  fi; 
# TEST: Throws an error for a bad instrument name
	echo "" >> $(OUTPUT)/errors.txt ;
	echo "Test InstrumentId:" >> $(OUTPUT)/errors.txt ;
	if [ `$(APPNAME) \
	  from=$(INPUT)/CAS-MCO-2016-11-26T22.35.51.907-RED-01033-B1-InstrumentError.xml \
	  to=$(OUTPUT)/BROKEN.cub \
	  2>> $(OUTPUT)/errors.txt > /dev/null` ]; \
	  then true; \
	  fi; 
# TEST: Throws an error for a bad filter name
	echo "" >> $(OUTPUT)/errors.txt ;
	echo "Test FilterName:" >> $(OUTPUT)/errors.txt ;
	if [ `$(APPNAME) \
	  from=$(INPUT)/CAS-MCO-2016-11-20T15.30.00.349-DMP-00000-00.xml \
	  to=$(OUTPUT)/BROKEN.cub \
	  2>> $(OUTPUT)/errors.txt > /dev/null` ]; \
	  then true; \
	  fi; 
# Cleanup
	$(RM) $(OUTPUT)/BROKEN.cub; 
     
+34 −11
Original line number Diff line number Diff line
@@ -101,11 +101,23 @@ namespace Isis {

    // calculate divisor using A3_corr coeffiecients
    double divider = chiDotA(dx, dy, m_A3_corr);
    // Note: The zeros for the divider variable fall well outside the boundary
    // of the focal plane. (See $ISIS3DATA/tgo/assets/distortion/DistortionModelA3CorrRoots.jpg).
    // We expect this case not to happen, but if it does, just return the input
    // values
    if (qFuzzyCompare(divider + 1.0,  1.0) == 0) {
    // This distortion model is only valid for values on the CCD:
    // -1/2 * pixel pitch * CCD width  = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
    // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
    // 
    // Also, the zeros for the divider variable fall well outside the boundary
    // of the CCD. (See $ISIS3DATA/tgo/assets/distortion/DistortionModelA3CorrRoots.jpg).
    // 
    // So, whenever x or y are too far from center or divider is near zero,
    // return the given inputs
    double pixelPitch = p_camera->getDouble("INS" + toString(naifIkCode) + "PIXEL_PITCH");
    double width  = p_camera->getDouble("INS" + toString(naifIkCode) + "FILTER_SAMPLES");
    double height = p_camera->getDouble("INS" + toString(naifIkCode) + "FILTER_LINES");
    if ( qFuzzyCompare(divider + 1.0,  1.0) == 0
         || dx < -0.5*pixelSize*width  - 0.2
         || dx >  0.5*pixelSize*width  + 0.2
         || dy < -0.5*pixelSize*height - 0.5
         || dy >  0.5*pixelSize*height + 0.2 ) {
      p_undistortedFocalPlaneX = dx;
      p_undistortedFocalPlaneY = dy;
      return true;
@@ -157,12 +169,23 @@ namespace Isis {

    // calculate divisor using A3_dist coeffiecients
    double divider = chiDotA(ux, uy, m_A3_dist);
    // Note: The zeros for the divider variable fall well outside the boundary
    // of the focal plane. (See
    // $ISIS3DATA/tgo/assets/distortion/DistortionModelA3DistRoots.jpg).
    // We expect this case not to happen, but if it does, just return the input
    // values
    if (qFuzzyCompare(divider + 1.0,  1.0) == 0) {
    // This distortion model is only valid for values on the CCD:
    // -1/2 * pixel pitch * CCD width  = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
    // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
    // 
    // Also, the zeros for the divider variable fall well outside the boundary
    // of the CCD. (See $ISIS3DATA/tgo/assets/distortion/DistortionModelA3DistRoots.jpg).
    // 
    // So, whenever x or y are too far from center or divider is near zero,
    // return the given inputs
    double pixelPitch = p_camera->getDouble("INS" + toString(naifIkCode) + "PIXEL_PITCH");
    double width  = p_camera->getDouble("INS" + toString(naifIkCode) + "FILTER_SAMPLES");
    double height = p_camera->getDouble("INS" + toString(naifIkCode) + "FILTER_LINES");
    if ( qFuzzyCompare(divider + 1.0,  1.0) == 0
         || ux < -0.5*pixelSize*width  - 0.2
         || ux >  0.5*pixelSize*width  + 0.2
         || uy < -0.5*pixelSize*height - 0.5
         || uy >  0.5*pixelSize*height + 0.2 ) {
      p_focalPlaneX = ux;
      p_focalPlaneY = uy;
      return true;
Loading