Commit 199c20a5 authored by Adam Goins's avatar Adam Goins
Browse files

Modifying tgocassisunstitch to parse the archive framelet groups from the stitched cube

parent a49053c1
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -75,13 +75,14 @@ void IsisMain() {
  PvlKeyword filterLines = inputLabel->findKeyword("FilterLines", PvlObject::Traverse);
  PvlKeyword filterWavelength = inputLabel->findKeyword("FilterCenters", PvlObject::Traverse);
  PvlKeyword filterWidth = inputLabel->findKeyword("FilterWidths", PvlObject::Traverse);

  for (int i = 0; i < filterKey.size(); i++) {
    g_frameletInfoList.append(FilterInfo(filterIkCodes[i].toInt(),
                              filterKey[i],
                              filterStartSamples[i].toInt(),
                              filterStartSamples[i].toDouble(),
                              filterStartLines[i].toDouble(),
                              filterSamples[i].toInt(),
                              filterLines[i].toInt(),
                              filterSamples[i].toDouble(),
                              filterLines[i].toDouble(),
                              filterWavelength[i].toDouble(),
                              filterWidth[i].toDouble()));
  }
@@ -151,16 +152,28 @@ void IsisMain() {
  for (int i = 0; i < g_outputCubes.size(); i++) {
    progress.CheckStatus();
    for (int j = 0; j < inputLabel->findObject("IsisCube").groups(); j++) {
      g_outputCubes[i]->putGroup(inputLabel->findObject("IsisCube").group(j));
      PvlGroup group = inputLabel->findObject("IsisCube").group(j);

      // The stitched frame has ArchiveRED, ArchiveNIR, ArchivePAN, and ArchiveBLU.
      // We won't add the archive group unless
      if ( group.name().contains("Archive") &&
           group.name() != "Archive" + g_frameletInfoList[i].m_filterName) {
             continue;
           }

      g_outputCubes[i]->putGroup(group);

    }
    // Update the labels
    Pvl *frameletLabel = g_outputCubes[i]->label();
    frameletLabel->findGroup("Instrument", PvlObject::Traverse).addKeyword(PvlKeyword("Filter",
                                          g_frameletInfoList[i].m_filterName), PvlObject::Replace);

    frameletLabel->findGroup("Archive" + g_frameletInfoList[i].m_filterName, PvlObject::Traverse).setName( "Archive" );

    PvlGroup &bandBin = frameletLabel->findGroup("BandBin", PvlObject::Traverse);

    bandBin.addKeyword(PvlKeyword("Name", g_frameletInfoList[i].m_filterName),
    bandBin.addKeyword(PvlKeyword("FilterName", g_frameletInfoList[i].m_filterName),
                                                PvlObject::Replace);
    bandBin.addKeyword(PvlKeyword("Center", toString(g_frameletInfoList[i].m_wavelength)));
    bandBin.addKeyword(PvlKeyword("Width", toString(g_frameletInfoList[i].m_width)));
@@ -214,9 +227,14 @@ void IsisMain() {
 *                           from in.Line() < [...] to inLine() <= [...] to write all lines
 *                           up to and including the last line. Fixes an error where the last lines
 *                           written would be a line of null pixel DN's.
 *
 *   @history 2018-02-14 Adam Goins - Modified the copying of the data in the buffer to include
 *                           the sample offset (m_startSample) for a cube.
 *
 */
void unstitchFullFrame(Buffer &in) {
  for (int i=0; i < g_frameletInfoList.size(); i++) {

    if (in.Line() >= g_frameletInfoList[i].m_startLine
        && in.Line() <= (g_frameletInfoList[i].m_startLine + g_frameletInfoList[i].m_lines)) {
      int outputCubeLineNumber = (in.Line()-1) % g_frameletInfoList[i].m_startLine + 1;
@@ -224,7 +242,7 @@ void unstitchFullFrame(Buffer &in) {
      mgr.SetLine(outputCubeLineNumber, 1);

      for (int j = 0; j < mgr.size(); j++) {
        mgr[j] = in[j];
        mgr[j] = in[j + g_frameletInfoList[i].m_startSample];
      }
      g_outputCubes[i]->write(mgr);
      return;