Commit 41def84a authored by Kaitlyn Lee's avatar Kaitlyn Lee Committed by Stuart Sides
Browse files

Phocube will export RA and declination planes even if the point is not on the...

Phocube will export RA and declination planes even if the point is not on the planet. Fixes #4446 (#657)

* Made it so that RA and Dec are added last.

* Updated code to be up to standards.

* Added RA and dec test.

* Updated history comment.

* Renamed test.

* Fixed typo in documentation

* Refactored code so that RA and dec are placed in the correct bands instead of moving them to the last two bands.

* Updated documentation, test now checks cube label.
parent 94bacdc1
Loading
Loading
Loading
Loading
+169 −81
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ bool bodyFixedX;
bool bodyFixedY;
bool bodyFixedZ;

int raBandNum;

void phocubeDN(Buffer &in, Buffer &out);
void phocube(Buffer &out);

@@ -134,6 +136,8 @@ void IsisMain() {
  bodyFixedX = false;
  bodyFixedY = false;
  bodyFixedZ = false;
  raBandNum = 0;  // 0 based, if RA is 5th band, raBandNum will be 4

  if (!noCamera) {
    if ((phase = ui.GetBoolean("PHASE"))) nbands++;
    if ((emission = ui.GetBoolean("EMISSION"))) nbands++;
@@ -169,7 +173,7 @@ void IsisMain() {
    throw IException(IException::User, message, _FILEINFO_);
  }

  // If outputting a a dn band, retrieve the orignal values for the filter name from the input cube,
  // If outputting a dn band, retrieve the orignal values for the filter name from the input cube,
  // if it exists.  Otherwise, the default will be "DN"
  QString bname = "DN";
  if ( dn && icube->hasGroup("BandBin") ) {
@@ -184,33 +188,105 @@ void IsisMain() {

  // Create a bandbin group for the output label
  PvlKeyword name("Name");
  if (dn) name += bname;
  if (phase) name += "Phase Angle";
  if (emission) name += "Emission Angle";
  if (incidence) name += "Incidence Angle";
  if (localEmission) name += "Local Emission Angle";
  if (localIncidence) name += "Local Incidence Angle";
  if (latitude) name += "Latitude";
  if (longitude) name += "Longitude";
  if (pixelResolution) name += "Pixel Resolution";
  if (lineResolution) name += "Line Resolution";
  if (sampleResolution) name += "Sample Resolution";
  if (detectorResolution) name += "Detector Resolution";
  if (obliqueDetectorResolution) name += "Oblique Detector Resolution";
  if (northAzimuth) name += "North Azimuth";
  if (sunAzimuth) name += "Sun Azimuth";
  if (spacecraftAzimuth) name += "Spacecraft Azimuth";
  if (offnadirAngle) name += "OffNadir Angle";
  if (subSpacecraftGroundAzimuth) name += "Sub Spacecraft Ground Azimuth";
  if (subSolarGroundAzimuth) name += "Sub Solar Ground Azimuth";
  if (morphologyRank) name += "Morphology Rank";
  if (albedoRank) name += "Albedo Rank";
  if (ra) name += "Right Ascension";
  if (declination) name += "Declination";
  if (bodyFixedX) name += "Body Fixed X";
  if (bodyFixedY) name += "Body Fixed Y";
  if (bodyFixedZ) name += "Body Fixed Z";

  if (dn) {
    name += bname;
    raBandNum++;
  } 
  if (phase) {
    name += "Phase Angle";
    raBandNum++;
  } 
  if (emission) {
    name += "Emission Angle";
    raBandNum++;
  }
  if (incidence) {
    name += "Incidence Angle";
    raBandNum++;
  }
  if (localEmission) {
    name += "Local Emission Angle";
    raBandNum++;
  }
  if (localIncidence) {
    name += "Local Incidence Angle";
    raBandNum++;
  }
  if (latitude) {
    name += "Latitude";
    raBandNum++;
  }
  if (longitude) {
    name += "Longitude";
    raBandNum++;
  }
  if (pixelResolution) {
    name += "Pixel Resolution";
    raBandNum++;
  }
  if (lineResolution) {
    name += "Line Resolution";
    raBandNum++;
  }
  if (sampleResolution) {
    name += "Sample Resolution";
    raBandNum++;
  }
  if (detectorResolution) {
    name += "Detector Resolution";
    raBandNum++;
  }
  if (obliqueDetectorResolution) {
    name += "Oblique Detector Resolution";
    raBandNum++;
  }
  if (northAzimuth) {
    name += "North Azimuth";
    raBandNum++;
  }
  if (sunAzimuth) {
    name += "Sun Azimuth";
    raBandNum++;
  }
  if (spacecraftAzimuth) {
    name += "Spacecraft Azimuth";
    raBandNum++;
  }
  if (offnadirAngle) {
    name += "OffNadir Angle";
    raBandNum++;
  }
  if (subSpacecraftGroundAzimuth) {
    name += "Sub Spacecraft Ground Azimuth";
    raBandNum++;
  }
  if (subSolarGroundAzimuth) {
    name += "Sub Solar Ground Azimuth";
    raBandNum++;
  }
  if (morphologyRank) {
    name += "Morphology Rank";
    raBandNum++;
  }
  if (albedoRank) {
    name += "Albedo Rank";
    raBandNum++;
  }
  if (ra) {
    name += "Right Ascension";
  }
  if (declination) {
    name += "Declination";
  }
  if (bodyFixedX) {
    name += "Body Fixed X";
  }
  if (bodyFixedY) {
    name += "Body Fixed Y";
  }
  if (bodyFixedZ) {
    name += "Body Fixed Z";
  }

  // Create the output cube.  Note we add the input cube to expedite propagation
  // of input cube elements (label, blobs, etc...).  It will be cleared
@@ -292,6 +368,7 @@ void phocube(Buffer &out) {
      double samp = out.Sample(index);
      double line = out.Line(index);

      // Checks to see if the point is in outer space
      bool isGood = false;
      if (noCamera) {
        isGood = proj->SetWorld(samp, line);
@@ -301,6 +378,7 @@ void phocube(Buffer &out) {
      }

      if (isGood) {

        if (phase) {
          out[index] = cam->PhaseAngle();
          index += 64 * 64;
@@ -408,13 +486,17 @@ void phocube(Buffer &out) {

        // Special Mosaic indexes
        if (morphologyRank) {
          if (!p_mosd) { p_mosd = getMosaicIndicies(*cam, mosd); }
          if (!p_mosd) {
            p_mosd = getMosaicIndicies(*cam, mosd);
          }
          out[index] = mosd.m_morph;
          index += 64 * 64;
        }

        if (albedoRank) {
          if (!p_mosd) { p_mosd = getMosaicIndicies(*cam, mosd); }
          if (!p_mosd) {
            p_mosd = getMosaicIndicies(*cam, mosd);
          }
          out[index] = mosd.m_albedo;
          index += 64 * 64;
        }
@@ -429,7 +511,6 @@ void phocube(Buffer &out) {
          index += 64 * 64;
        }

        
        if (!noCamera) {
          double pB[3];
          cam->Coordinate(pB);
@@ -447,12 +528,20 @@ void phocube(Buffer &out) {
            index += 64 * 64;
          }
        }
        
      }
      // Trim outerspace

      // Trim outer space except RA and dec bands
      else {
        for (int b = (skipDN) ? 1 : 0; b < nbands; b++) {
          if(ra && b == raBandNum) {
            out[index] = cam->RightAscension();
          }
          else if (declination && b == raBandNum + 1) {
            out[index] = cam->Declination();
          }
          else {
            out[index] = Isis::NULL8;
          }
          index += 64 * 64;
        }
      }
@@ -525,4 +614,3 @@ void UpdateBandKey(const QString &keyname, PvlGroup &bb, const int &nvals,
  bb.addKeyword(makeKey(keyname, nvals, defVal), PvlContainer::Replace);
  return;
}
+198 −195
Original line number Diff line number Diff line
@@ -106,8 +106,8 @@ xsi:noNamespaceSchemaLocation=
     <li><def link="Subsolar Ground Azimuth">SUBSOLARGROUNDAZIMUTH</def></li>
     <li>MORPHOLOGYRANK</li>
     <li>ALBEDORANK</li>
     <li>RADEC (<def link="Right Ascension">Right Ascension</def>, <def link="Declination">Declination</def> )</li>
     <li><def link="Body Fixed Coordinate">BODYFIXED</def></li>
     <li>RADEC (<def link="Right Ascension">Right Ascension</def>, <def link="Declination">Declination</def> )</li>
     </ul>
	The following options are available for Level2 images:
     <ul>
@@ -302,6 +302,9 @@ xsi:noNamespaceSchemaLocation=
		<change name="Kaj Williams" date="2017-06-09">
      Renamed albedo to albedoRank, and morph (or morphology) to morphRank (or MorphologyRank). Ref #4008.
    </change>
    <change name="Kaitlyn Lee" date="2019-02-15">
      Allowed RA and DEC to be exported regardless if the pixel is off body. Fixes #4446.
    </change>
  </history>

  <category>
+12 −0
Original line number Diff line number Diff line
# Tests RA and declination bands to make sure values are displayed even if not on the planet.
APPNAME = phocube

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/EW0131773041G.cal.cub \
	  to=$(OUTPUT)/radec_bands.cub \
	  pixelresolution=true \
	  radec=true > /dev/null; 
	catlab from= $(OUTPUT)/radec_bands.cub \
	  to=$(OUTPUT)/output.pvl > /dev/null;