Commit 72f2fbfb authored by Amy Stamile's avatar Amy Stamile Committed by Jesse Mapel
Browse files

Generates Serial Numbers using CSM label information (#4437)

* Creates Serial Numbers using CSM label information

* Updated second SerialNumberList:add function to accommodate CSM label
parent ceb3ce68
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
Group = Keyword1
  Auto
  InputKey       = CSMPlatformId
  InputGroup     = "IsisCube,CsmInfo"
  InputPosition  = (IsisCube, CsmInfo)
  OutputName     = Keyword1
  OutputPosition = (Group, SerialNumberKeywords)
  Translation    = (* , *)
End_Group

Group = Keyword2
  Auto
  InputKey       = CSMInstrumentId
  InputGroup     = "IsisCube,CsmInfo"
  InputPosition  = (IsisCube, CsmInfo)
  OutputName     = Keyword2
  OutputPosition = (Group, SerialNumberKeywords)
  Translation    = (*, *)
End_Group

Group = Keyword3
  Auto
  InputKey       = ReferenceTime
  InputGroup     = "IsisCube,CsmInfo"
  InputPosition  = (IsisCube, CsmInfo)
  OutputName     = Keyword3
  OutputPosition = (Group, SerialNumberKeywords)
  Translation    = (*, *)
End_Group
End
+50 −42
Original line number Diff line number Diff line
@@ -97,6 +97,13 @@ namespace Isis {
  PvlGroup SerialNumber::FindSerialTranslation(Pvl &label) {
    Pvl outLabel;

    // check if label has CSM information
    if(label.findObject("IsisCube").hasGroup("CsmInfo")) {
      static QString csmTransFile = "$ISISROOT/appdata/translations/CsmSerialNumber.trn";
      PvlToPvlTranslationManager csmTranslator(label, csmTransFile);
      csmTranslator.Auto(outLabel);
    }
    else {
      // Get the mission name
      static QString missionTransFile = "$ISISROOT/appdata/translations/MissionName2DataDir.trn";
      static PvlToPvlTranslationManager missionXlater(missionTransFile);
@@ -139,6 +146,7 @@ namespace Isis {
      }
      translationIterator->second.SetLabel(label);
      translationIterator->second.Auto(outLabel);
    }

    PvlGroup snGroup = outLabel.findGroup("SerialNumberKeywords");
    snGroup += PvlKeyword("ObservationKeys", toString(snGroup.keywords()));
+48 −15
Original line number Diff line number Diff line
@@ -181,9 +181,19 @@ namespace Isis {
      nextpair.serialNumber = sn;
      nextpair.observationNumber = on;

      // Need to obtain the SpacecraftName and InstrumentId from the Instrument
      // If a CSM cube, obtain the CSMPlatformID and CSMInstrumentId from the CsmInfo
      // group for use in bundle adjustment
      if (cubeObj.hasGroup("Instrument")) {
      if (cubeObj.hasGroup("CsmInfo")) {
        PvlGroup csmGroup = cubeObj.findGroup("CsmInfo");
        if (csmGroup.hasKeyword("CSMPlatformID") && csmGroup.hasKeyword("CSMInstrumentId")) {
          nextpair.spacecraftName = cubeObj.findGroup("CsmInfo")["CSMPlatformID"][0];
          nextpair.instrumentId = cubeObj.findGroup("CsmInfo")["CSMInstrumentId"][0];
        }
      }

      // Otherwise obtain the SpacecraftName and InstrumentId from the Instrument
      // group for use in bundle adjustment
      else if (cubeObj.hasGroup("Instrument")) {
        PvlGroup instGroup = cubeObj.findGroup("Instrument");
        if (instGroup.hasKeyword("SpacecraftName") && instGroup.hasKeyword("InstrumentId")) {
          nextpair.spacecraftName = cubeObj.findGroup("Instrument")["SpacecraftName"][0];
@@ -287,6 +297,9 @@ namespace Isis {
        throw IException(IException::User, msg, _FILEINFO_);
      }

      // Check if it is not a CSM label before checking SpacecraftName and InstrumentId
      if (!cubeObj.hasGroup("CsmInfo")) {

        // Need to obtain the SpacecraftName and InstrumentId from the Instrument
        // group for use in bundle adjustment
        if (!cubeObj.hasGroup("Instrument")) {
@@ -300,15 +313,35 @@ namespace Isis {
                        + " needed for performing bundle adjustment.";
          throw IException(IException::User, msg, _FILEINFO_);
        }
      }
      // Check if CSM label has CSMPlatformID and CSMInstrumentId
      else {
        PvlGroup csmGroup = cubeObj.findGroup("CSMInfo");
        if (!csmGroup.hasKeyword("CSMPlatformID") || !csmGroup.hasKeyword("CSMInstrumentId")) {
          QString msg = "Unable to find CSMPlatformID or CSMInstrumentId keywords in " + filename
                        + " needed for performing bundle adjustment.";
          throw IException(IException::User, msg, _FILEINFO_);
        }
      }

      Pair nextpair;
      nextpair.filename = Isis::FileName(filename).expanded();
      nextpair.serialNumber = serialNumber;
      nextpair.observationNumber = observationNumber;

      // Need to obtain the SpacecraftName and InstrumentId from the Instrument
      // If a CSM cube, obtain the CSMPlatformID and CSMInstrumentId from the CsmInfo
      // group for use in bundle adjustment
      if (cubeObj.hasGroup("Instrument")) {
      if (cubeObj.hasGroup("CsmInfo")) {
        PvlGroup csmGroup = cubeObj.findGroup("CsmInfo");
        if (csmGroup.hasKeyword("CSMPlatformID") && csmGroup.hasKeyword("CSMInstrumentId")) {
          nextpair.spacecraftName = cubeObj.findGroup("CsmInfo")["CSMPlatformID"][0];
          nextpair.instrumentId = cubeObj.findGroup("CsmInfo")["CSMInstrumentId"][0];
        }
      }

      // Otherwise obtain the SpacecraftName and InstrumentId from the Instrument
      // group for use in bundle adjustment
      else if (cubeObj.hasGroup("Instrument")) {
        PvlGroup instGroup = cubeObj.findGroup("Instrument");
        if (instGroup.hasKeyword("SpacecraftName") && instGroup.hasKeyword("InstrumentId")) {
          nextpair.spacecraftName = cubeObj.findGroup("Instrument")["SpacecraftName"][0];
+16 −1
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#include "TestUtilities.h"
#include "FileName.h"
#include "Fixtures.h"
#include "SerialNumber.h"
#include "SerialNumberList.h"

#include <nlohmann/json.hpp>
using json = nlohmann::json;
@@ -507,3 +509,16 @@ TEST_F(CSMCameraFixture, Declination) {
      " Declination is not supported for CSM camera models\"";
  }
}


TEST_F(CSMCameraSetFixture, SerialNumber) {
  QString sn = SerialNumber::Compose(*testCube);
  SerialNumberList snl;

  snl.add(testCube->fileName());
  QString instId = snl.spacecraftInstrumentId(sn);

  EXPECT_PRED_FORMAT2(AssertQStringsEqual, sn, "TestPlatform/TestInstrument/2000-01-01T11:58:55.816");
  EXPECT_TRUE(snl.hasSerialNumber(sn));
  EXPECT_PRED_FORMAT2(AssertQStringsEqual, instId, "TESTPLATFORM/TESTINSTRUMENT");
}