void TranslateHiriseEdrLabels (Filename &labelFile, Cube *ocube) { //Create a PVL to store the translated labels Pvl outLabel; // Get the directory where the MRO HiRISE translation tables are. PvlGroup dataDir (Preference::Preferences().FindGroup("DataDirectory")); iString transDir = (string) dataDir["Mro"] + "/translations/"; // Get a filename for the HiRISE EDR label Pvl labelPvl (labelFile.Expanded()); // Translate the Instrument group Filename transFile (transDir + "hiriseInstrument.trn"); PvlTranslationManager instrumentXlater (labelPvl, transFile.Expanded()); instrumentXlater.Auto (outLabel); // Translate the BandBin group transFile = transDir + "hiriseBandBin.trn"; PvlTranslationManager bandBinXlater (labelPvl, transFile.Expanded()); bandBinXlater.Auto (outLabel); // Translate the Archive group transFile = transDir + "hiriseArchive.trn"; PvlTranslationManager archiveXlater (labelPvl, transFile.Expanded()); archiveXlater.Auto (outLabel); // Create the Instrument group keyword CcdId from the ProductId // SCS 28-03-06 Do it in the instrument translation table instead of here // PvlGroup &archiveGroup(outLabel.FindGroup("Archive", Pvl::Traverse)); // iString productId = (string)archiveGroup.FindKeyword("ProductId"); // productId.Token("_"); // productId.Token("_"); // productId = productId.Token("_"); // outLabel.FindGroup("Instrument", Pvl::Traverse) += // PvlKeyword ("CcdId", productId); // Create the Kernel Group PvlGroup kerns("Kernels"); kerns += PvlKeyword("NaifIkCode", "-74699"); // Write the Instrument, BandBin, Archive, and Kernels groups to the output // cube label ocube->PutGroup (outLabel.FindGroup("Instrument", Pvl::Traverse)); ocube->PutGroup (outLabel.FindGroup("BandBin", Pvl::Traverse)); ocube->PutGroup (outLabel.FindGroup("Archive", Pvl::Traverse)); ocube->PutGroup (kerns); }
void IsisMain () { ProcessImportPds p; Pvl pdsLabel; UserInterface &ui = Application::GetUserInterface(); FileName inFile = ui.GetFileName("FROM"); QString imageFile(""); if (ui.WasEntered("IMAGE")) { imageFile = ui.GetFileName("IMAGE"); } // Generate the housekeeping filenames QString hkLabel(""); QString hkData(""); if (ui.WasEntered("HKFROM") ) { hkLabel = ui.GetFileName("HKFROM"); } else { hkLabel = inFile.originalPath() + "/" + inFile.baseName() + "_HK.LBL"; // Determine the housekeeping file FileName hkFile(hkLabel); if (!hkFile.fileExists()) { hkFile = hkLabel.replace("_1B_", "_1A_"); if (hkFile.fileExists()) hkLabel = hkFile.expanded(); } } if (ui.WasEntered("HKTABLE")) { hkData = ui.GetFileName("HKTABLE"); } QString instid; QString missid; try { Pvl lab(inFile.expanded()); instid = (QString) lab.findKeyword ("CHANNEL_ID"); missid = (QString) lab.findKeyword ("INSTRUMENT_HOST_ID"); } catch (IException &e) { QString msg = "Unable to read [INSTRUMENT_ID] or [MISSION_ID] from input file [" + inFile.expanded() + "]"; throw IException(e, IException::Io,msg, _FILEINFO_); } instid = instid.simplified().trimmed(); missid = missid.simplified().trimmed(); if (missid != "DAWN" && instid != "VIS" && instid != "IR") { QString msg = "Input file [" + inFile.expanded() + "] does not appear to be a " + "DAWN Visual and InfraRed Mapping Spectrometer (VIR) EDR or RDR file."; throw IException(IException::Unknown, msg, _FILEINFO_); } QString target; if (ui.WasEntered("TARGET")) { target = ui.GetString("TARGET"); } // p.SetPdsFile (inFile.expanded(),imageFile,pdsLabel); // QString labelFile = ui.GetFileName("FROM"); p.SetPdsFile (inFile.expanded(),imageFile,pdsLabel); p.SetOrganization(Isis::ProcessImport::BIP); Cube *outcube = p.SetOutputCube ("TO"); // p.SaveFileHeader(); Pvl labelPvl (inFile.expanded()); p.StartProcess (); // Get the directory where the DAWN translation tables are. PvlGroup dataDir (Preference::Preferences().findGroup("DataDirectory")); QString transDir = (QString) dataDir["Dawn"] + "/translations/"; // Create a PVL to store the translated labels in Pvl outLabel; // Translate the BandBin group FileName transFile (transDir + "dawnvirBandBin.trn"); PvlTranslationManager bandBinXlater (labelPvl, transFile.expanded()); bandBinXlater.Auto(outLabel); // Translate the Archive group transFile = transDir + "dawnvirArchive.trn"; PvlTranslationManager archiveXlater (labelPvl, transFile.expanded()); archiveXlater.Auto(outLabel); // Translate the Instrument group transFile = transDir + "dawnvirInstrument.trn"; PvlTranslationManager instrumentXlater (labelPvl, transFile.expanded()); instrumentXlater.Auto(outLabel); // Update target if user specifies it if (!target.isEmpty()) { PvlGroup &igrp = outLabel.findGroup("Instrument",Pvl::Traverse); igrp["TargetName"] = target; } // Write the BandBin, Archive, and Instrument groups // to the output cube label outcube->putGroup(outLabel.findGroup("BandBin",Pvl::Traverse)); outcube->putGroup(outLabel.findGroup("Archive",Pvl::Traverse)); outcube->putGroup(outLabel.findGroup("Instrument",Pvl::Traverse)); PvlGroup kerns("Kernels"); if (instid == "VIS") { kerns += PvlKeyword("NaifFrameCode","-203211"); } else if (instid == "IR") { kerns += PvlKeyword("NaifFrameCode","-203213"); } else { QString msg = "Input file [" + inFile.expanded() + "] has an invalid " + "InstrumentId."; throw IException(IException::Unknown, msg, _FILEINFO_); } outcube->putGroup(kerns); // Now handle generation of housekeeping data try { ImportPdsTable hktable(hkLabel, hkData); hktable.setType("ScetTimeClock", "CHARACTER"); hktable.setType("ShutterStatus", "CHARACTER"); hktable.setType("MirrorSin", "DOUBLE"); hktable.setType("MirrorCos", "DOUBLE"); Table hktab = hktable.importTable("ScetTimeClock,ShutterStatus,MirrorSin,MirrorCos", "VIRHouseKeeping"); hktab.Label().addKeyword(PvlKeyword("SourceFile", hkLabel)); outcube->write(hktab); } catch (IException &e) { QString mess = "Cannot read/open housekeeping data"; throw IException(e, IException::User, mess, _FILEINFO_); } p.EndProcess (); }
void TranslateLabels (Filename in, Cube *ocube) { // Get the directory where the Clementine translation tables are. PvlGroup &dataDir = Preference::Preferences().FindGroup("DataDirectory"); // Transfer the instrument group to the output cube iString transDir = (string) dataDir["clementine1"]; Filename transFile (transDir + "/translations/clementine.trn"); Pvl pdsLab(in.Expanded()); PvlTranslationManager labelXlater (pdsLab, transFile.Expanded()); // Pvl outputLabels; Pvl *outputLabel = ocube->Label(); labelXlater.Auto(*(outputLabel)); //Instrument group PvlGroup inst = outputLabel->FindGroup ("Instrument",Pvl::Traverse); PvlKeyword &startTime = inst.FindKeyword("StartTime"); startTime.SetValue( startTime[0].substr(0, startTime[0].size()-1)); // Old PDS labels used keyword INSTRUMENT_COMPRESSION_TYPE & PDS Labels now use ENCODING_TYPE if(pdsLab.FindObject("Image").HasKeyword("InstrumentCompressionType")){ inst += PvlKeyword("EncodingFormat",(string) pdsLab.FindObject("Image")["InstrumentCompressionType"]); } else { inst += PvlKeyword("EncodingFormat",(string) pdsLab.FindObject("Image")["EncodingType"]); } if (((string)inst["InstrumentId"]) == "HIRES") { inst += PvlKeyword("MCPGainModeID", (string)pdsLab["MCP_Gain_Mode_ID"], ""); } ocube->PutGroup(inst); PvlGroup bBin = outputLabel->FindGroup ("BandBin", Pvl::Traverse); std::string filter = pdsLab["FilterName"]; if (filter != "F") { //Band Bin group double center = pdsLab["CenterFilterWavelength"]; center /= 1000.0; bBin.FindKeyword("Center").SetValue(center,"micrometers"); } double width = pdsLab["Bandwidth"]; width /= 1000.0; bBin.FindKeyword("Width").SetValue(width,"micrometers"); ocube->PutGroup(bBin); //Kernel group PvlGroup kern("Kernels"); if (((string)inst["InstrumentId"]) == "HIRES") { kern += PvlKeyword("NaifFrameCode","-40001"); } if (((string)inst["InstrumentId"]) == "UVVIS") { kern += PvlKeyword("NaifFrameCode","-40002"); } if (((string)inst["InstrumentId"]) == "NIR") { kern += PvlKeyword("NaifFrameCode","-40003"); } if (((string)inst["InstrumentId"]) == "LWIR") { kern += PvlKeyword("NaifFrameCode","-40004"); } ocube->PutGroup(kern); OriginalLabel org(pdsLab); ocube->Write(org); }
void TranslateLabels(Pvl &pdsLabel, Cube *ocube) { // Get the directory where the MOC translation tables are. PvlGroup &dataDir = Preference::Preferences().FindGroup("DataDirectory"); // Transfer the instrument group to the output cube iString transDir = (string) dataDir["Galileo"]; Filename transFile (transDir + "/translations/galileoSsi.trn"); // Get the translation manager ready PvlTranslationManager labelXlater (pdsLabel, transFile.Expanded()); // Pvl outputLabels; Pvl *outputLabel = ocube->Label(); labelXlater.Auto(*(outputLabel)); //Add to the Archive Group PvlGroup &arch = outputLabel->FindGroup("Archive",Pvl::Traverse); PvlGroup &inst = outputLabel->FindGroup("Instrument",Pvl::Traverse); arch.AddKeyword(PvlKeyword("DataType","RADIANCE")); string CTC = (string) arch.FindKeyword("ObservationId"); string CTCout = CTC.substr(0,2); arch.AddKeyword(PvlKeyword("CalTargetCode",CTCout)); // Add to the Instrument Group iString itest =(string) inst.FindKeyword("StartTime"); itest.Remove("Z"); inst.FindKeyword("StartTime").SetValue(itest); //change exposure duration to seconds double expDur = inst.FindKeyword("exposureDuration"); double expDurOut = expDur / 1000.0; inst.FindKeyword("exposureDuration").SetValue(expDurOut,"seconds"); inst.AddKeyword(PvlKeyword("FrameDuration", (string) pdsLabel["frameDuration"],"seconds")); //Calculate the Frame_Rate_Id keyword string frameModeId = "FULL"; int summingMode = 1; if(summed) { frameModeId = "SUMMATION"; summingMode = 2; } inst.AddKeyword(PvlKeyword("Summing",summingMode)); inst.AddKeyword(PvlKeyword("FrameModeId",frameModeId)); // Create the Band bin Group PvlGroup &bandBin = outputLabel->FindGroup("BandBin",Pvl::Traverse); string filterName = pdsLabel["FILTER_NAME"]; string waveLength = ""; string width = ""; if (filterName == "CLEAR") { waveLength = "0.611"; width = ".44"; } if (filterName == "VIOLET") { waveLength = "0.404"; width = ".05"; } if (filterName == "GREEN") { waveLength = "0.559"; width = ".06"; } if (filterName == "RED") { waveLength = "0.671"; width = ".06"; } if (filterName == "IR-7270") { waveLength = "0.734"; width = ".01"; } if (filterName == "IR-7560") { waveLength = "0.756"; width = ".018"; } if (filterName == "IR-8890") { waveLength = "0.887"; width = ".116"; } if (filterName == "INFRARED") { waveLength = "0.986"; width = ".04"; } bandBin.AddKeyword(PvlKeyword("Center",waveLength, "micrometers")); bandBin.AddKeyword(PvlKeyword("Width",width,"micrometers")); //create the kernel group PvlGroup kern("Kernels"); kern += PvlKeyword("NaifFrameCode",-77001); ocube->PutGroup(kern); }