Loading isis/src/base/apps/isis2pds/isis2pds.cpp +40 −30 Original line number Diff line number Diff line Loading @@ -38,11 +38,13 @@ void IsisMain() { p.SetInputCube("FROM"); if (ui.GetString("STRETCH") == "LINEAR") { if(ui.GetString("BITTYPE") != "32BIT") if (ui.GetString("BITTYPE") != "32BIT") { p.SetInputRange(); } if(ui.GetString("STRETCH") == "MANUAL") } if (ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); } double min = -DBL_MAX; double max = DBL_MAX; Loading Loading @@ -75,13 +77,16 @@ void IsisMain() { setRangeAndPixels(ui, p, min, max, NONE); } if(ui.GetString("ENDIAN") == "MSB") if (ui.GetString("ENDIAN") == "MSB") { p.SetOutputEndian(Isis::Msb); else if(ui.GetString("ENDIAN") == "LSB") } else if (ui.GetString("ENDIAN") == "LSB") { p.SetOutputEndian(Isis::Lsb); } if(ui.GetString("LABTYPE") == "FIXED") if (ui.GetString("LABTYPE") == "FIXED") { p.SetExportType(ProcessExportPds::Fixed); } if (ui.GetBoolean("CHECKSUM")) { p.setCanGenerateChecksum(true); Loading Loading @@ -130,11 +135,13 @@ void IsisMain() { QString outFileName(outFile.expanded()); if (ui.GetString("STRETCH") == "LINEAR") { if(ui.GetString("BITTYPE") != "32BIT") if (ui.GetString("BITTYPE") != "32BIT") { process.SetInputRange(); } if(ui.GetString("STRETCH") == "MANUAL") } if (ui.GetString("STRETCH") == "MANUAL") { process.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); } double min = -DBL_MAX; double max = DBL_MAX; Loading Loading @@ -167,10 +174,12 @@ void IsisMain() { setRangeAndPixels(ui, process, min, max, NONE); } if(ui.GetString("ENDIAN") == "MSB") if (ui.GetString("ENDIAN") == "MSB") { process.SetOutputEndian(Isis::Msb); else if(ui.GetString("ENDIAN") == "LSB") } else if (ui.GetString("ENDIAN") == "LSB") { process.SetOutputEndian(Isis::Lsb); } // Records what it did to the print.prt file PvlGroup results("DNs Used"); Loading @@ -184,6 +193,7 @@ void IsisMain() { Application::Log(results); process.StandardPds4Label(); // ProcessExportPds4::translateUnits(pdsLabel);//??? process.WritePds4(outFileName); } Loading isis/src/base/apps/isis2pds/tsts/pds4/Makefile +10 −1 Original line number Diff line number Diff line Loading @@ -7,8 +7,17 @@ commands: # Remove parts of output that can occur in any order and convert to txt for comparison $(SED) 's+\Product_Observational.*>+\Product_Observational>+' \ $(OUTPUT)/dawnEqui.xml > $(OUTPUT)/dawnEqui.txt; $(OUTPUT)/dawnEqui.xml \ > $(OUTPUT)/tempLabel1.txt; $(SED) 's+\modification_date.*>+\modification_date>+' \ $(OUTPUT)/tempLabel1.txt \ > $(OUTPUT)/tempLabel2.txt; $(SED) 's+\ISIS version.*<+\ISIS version.<+' \ $(OUTPUT)/tempLabel2.txt \ > $(OUTPUT)/dawnEqui.txt; $(RM) $(OUTPUT)/dawnEqui.xml > /dev/null; $(RM) $(OUTPUT)/tempLabel1.txt > /dev/null; $(RM) $(OUTPUT)/tempLabel2.txt > /dev/null; $(RM) $(OUTPUT)/dawnEqui.img > /dev/null; isis/src/base/apps/stats/tsts/default/Makefile +2 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ commands: > /dev/null; $(APPNAME) from=$(INPUT)/isisTruth.cub \ | grep -v stats \ | grep -v "stats:" \ | grep -v Processed \ >& $(OUTPUT)/output.pvl; isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp +254 −119 Original line number Diff line number Diff line Loading @@ -24,8 +24,10 @@ #include <QDomDocument> #include <QMap> #include <QRegularExpression> #include <QString> #include "Application.h" #include "FileName.h" #include "IException.h" #include "Projection.h" Loading @@ -43,6 +45,9 @@ namespace Isis { * */ ProcessExportPds4::ProcessExportPds4() { m_lid = ""; qSetGlobalQHashSeed(1031); // hash seed to force consistent output m_domDoc = new QDomDocument(""); Loading Loading @@ -104,12 +109,19 @@ namespace Isis { /** * Create a standard PDS label for type IMAGE. The image label will be * Creates a PDS4 label. The image label will be * stored internally in the class. * * This method has a similar function to * ProcessExportPds::CreateImageLabel. However, it will create * images of object type Array_3D_Image, Array_2D_Image, or * Array_3D_Spectrum. */ void ProcessExportPds4::CreateImageLabel() { try { // <Product_Observational> // <Identification_Area> identificationArea(); } catch (IException &e) { Loading @@ -117,6 +129,8 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> standardInstrument(); } catch (IException &e) { Loading @@ -124,25 +138,34 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // <disp:Display_Settings> displaySettings(); } catch (IException &e) { QString msg = "Unable to translate and export display settings."; throw IException(e, IException::Programmer, msg, _FILEINFO_); } // Temporarily removed spectral processing because it needs further work. // // try { // standardBandBin(); // } // catch (IException &e) { // QString msg = "Unable to translate and export spectral information."; // throw IException(e, IException::Programmer, msg, _FILEINFO_); // } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // <sp:Spectral_Characteristics> OR <img:Imaging> standardBandBin(); } catch (IException &e) { QString msg = "Unable to translate and export spectral information."; throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // display settings, and cartography handled in this method: // <card:Cartography> StandardAllMapping(); } catch (IException &e) { Loading @@ -150,8 +173,9 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // file observation area StandardImageImage(); // <Product_Observational> // <File_Area_Observational> fileAreaObservational(); } catch (IException &e) { QString msg = "Unable to translate and export standard image information."; Loading @@ -166,11 +190,13 @@ namespace Isis { */ void ProcessExportPds4::standardInstrument() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; FileName translationFileName; if (inputLabel->findObject("IsisCube").hasGroup("Instrument")) { // Translate the Instrument group transfile = "$base/translations/pds4ExportInstrument.trn"; PvlToXmlTranslationManager instXlator(*inputLabel, transfile.expanded()); translationFileName = "$base/translations/pds4ExportInstrument.trn"; PvlToXmlTranslationManager instXlator(*inputLabel, translationFileName.expanded()); instXlator.Auto(*m_domDoc); // If instrument and spacecraft values were translated, create the combined name Loading Loading @@ -232,24 +258,68 @@ namespace Isis { } // Translate the Target name try { transfile = "$base/translations/pds4ExportTargetFromInstrument.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, transfile.expanded()); translationFileName = "$base/translations/pds4ExportTargetFromInstrument.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, translationFileName.expanded()); targXlator.Auto(*m_domDoc); // move target to just below Observing_System. QDomElement targetIdNode = obsAreaNode.firstChildElement("Target_Identification"); obsAreaNode.insertAfter(targetIdNode, obsAreaNode.firstChildElement("Observing_System")); } catch (IException &e1) { try { transfile = "$base/translations/pds4ExportTargetFromMapping.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, transfile.expanded()); else if (inputLabel->findObject("IsisCube").hasGroup("Mapping")) { translationFileName = "$base/translations/pds4ExportTargetFromMapping.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, translationFileName.expanded()); targXlator.Auto(*m_domDoc); } else { throw IException(IException::Unknown, "Unable to find a target in input cube.", _FILEINFO_); } catch (IException &e2) { IException finalError(IException::Unknown, "Unable to find a target in input cube.", _FILEINFO_); finalError.append(e1); finalError.append(e2); throw finalError; } /** * Allows mission specific programs to set logical_identifier * required for PDS4 labels. This value is added to the xml file * by the identificationArea() method. * * The input string should be colon separated string with 6 * identifiers: * * <ol> * <li> urn </li> * <li> space_agency (ususally nasa) </li> * <li> archiving_organization (usually pds) </li> * <li> bundle_id </li> * <li> collection_id </li> * <li> product_id </li> * </ol> * * Example: * urn:esa:psa:em16_tgo_frd:data_raw:frd_raw_sc_d_20150625T133700-20150625T135700 * * @author 2018-05-21 Jeannie Backer * * @param lid The logical identifier value required for PDS4 * compliant labels. */ void ProcessExportPds4::setLogicalId(QString lid) { m_lid = lid; } /** * Allows mission specific programs to use specified * versions of dictionaries. * * @author 2018-05-21 Jeannie Backer * * @param schema The string of schema to be set. */ void ProcessExportPds4::setSchemaLocation(QString schema) { m_schemaLocation = schema; } Loading @@ -259,10 +329,46 @@ namespace Isis { */ void ProcessExportPds4::identificationArea() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; transfile = "$base/translations/pds4ExportIdentificationArea.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); FileName translationFileName; translationFileName = "$base/translations/pds4ExportIdentificationArea.trn"; PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); if (m_lid.isEmpty()) { m_lid = "urn:nasa:pds:TBD:TBD:TBD"; } QDomElement identificationElement; QStringList identificationPath; identificationPath.append("Product_Observational"); identificationPath.append("Identification_Area"); try { identificationElement = getElement(identificationPath); if( identificationElement.isNull() ) { throw IException(IException::Unknown, "", _FILEINFO_); } } catch(IException &e) { QString msg = "Could not find Identification_Area element " "to add modification history under."; throw IException(IException::Programmer, msg, _FILEINFO_); } QDomElement lidElement = identificationElement.firstChildElement("logical_identifier"); PvlToXmlTranslationManager::resetElementValue(lidElement, m_lid); // Get export history and add <Modification_History> element. // These regular expressions match the pipe followed by the date from // the Application::Version() return value. QRegularExpression versionRegex(" \\| \\d{4}\\-\\d{2}\\-\\d{2}"); QString historyDescription = "Created PDS4 output product from ISIS cube with the " + FileName(Application::Name()).baseName() + " application from ISIS version " + Application::Version().remove(versionRegex) + "."; // This regular expression matches the time from the Application::DateTime return value. QRegularExpression dateRegex("T\\d{2}:\\d{2}:\\d{2}"); QString historyDate = Application::DateTime().remove(dateRegex); addHistory(historyDescription, historyDate); } Loading @@ -273,9 +379,9 @@ namespace Isis { void ProcessExportPds4::displaySettings() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; transfile = "$base/translations/pds4ExportDisplaySettings.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); FileName translationFileName; translationFileName = "$base/translations/pds4ExportDisplaySettings.trn"; PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); // Add header info Loading @@ -294,14 +400,9 @@ namespace Isis { // Spectra // Get the input Isis cube label and find the BandBin group if it has one Pvl *inputLabel = InputCubes[0]->label(); if(inputLabel->hasObject("IsisCube") && !(inputLabel->findObject("IsisCube").hasGroup("BandBin"))) return; FileName transfile; transfile = "$base/translations/pds4ExportBandBin.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); xlator.Auto(*m_domDoc); QString imageObject = imageObjectType(*inputLabel); if (imageObject.compare("Array_3D_Spectrum") == 0) { // Add header info addSchema("PDS4_SP_1100.sch", "PDS4_SP_1100.xsd", Loading @@ -309,17 +410,32 @@ namespace Isis { "http://pds.nasa.gov/pds4/sp/v1"); } QString translationFile = "$base/translations/pds4ExportBandBin"; translationFile += imageObject.remove(0,9); // remove first 9 characters: Array_2D_ or Array_3D_ translationFile += ".trn"; FileName translationFileName(translationFile); PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); } /** * Create and internalize a standard image output label from the input image. * @todo determine whether to treat single band as 2d array * Create and internalize an image output label from the input * image. This method has a similar function to * ProcessExportPds::StandardImageImage. */ void ProcessExportPds4::StandardImageImage() { void ProcessExportPds4::fileAreaObservational() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; QString imageObject = imageObjectType(*inputLabel); transfile = "$base/translations/pds4ExportArray3DImage.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); QString translationFile = "$base/translations/pds4Export"; translationFile += QString(imageObject).remove('_'); translationFile += ".trn"; FileName translationFileName(translationFile); PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); QDomElement rootElement = m_domDoc->documentElement(); Loading Loading @@ -350,15 +466,14 @@ namespace Isis { } if (!fileAreaObservationalElement.isNull()) { QDomElement array3DImageElement = fileAreaObservationalElement.firstChildElement("Array_3D_Image"); if (!array3DImageElement.isNull()) { QDomElement arrayImageElement = fileAreaObservationalElement.firstChildElement(imageObject); if (!arrayImageElement.isNull()) { // reorder axis elements. // Translation order: elements, axis_name, sequence_number // Correct order: axis_name, elements, sequence_number QDomElement axisArrayElement = array3DImageElement.firstChildElement("Axis_Array"); QDomElement axisArrayElement = arrayImageElement.firstChildElement("Axis_Array"); while( !axisArrayElement.isNull() ) { QDomElement axisNameElement = axisArrayElement.firstChildElement("axis_name"); axisArrayElement.insertBefore(axisNameElement, Loading @@ -367,8 +482,8 @@ namespace Isis { } QDomElement elementArrayElement = m_domDoc->createElement("Element_Array"); array3DImageElement.insertBefore(elementArrayElement, array3DImageElement.firstChildElement("Axis_Array")); arrayImageElement.insertBefore(elementArrayElement, arrayImageElement.firstChildElement("Axis_Array")); QDomElement dataTypeElement = m_domDoc->createElement("data_type"); PvlToXmlTranslationManager::setElementValue(dataTypeElement, Loading @@ -389,6 +504,26 @@ namespace Isis { } QString ProcessExportPds4::imageObjectType(Pvl &inputLabel) { // not sure how to easily determine whether an isis3 cube should be // exported as spectral. for now, we will only export image arrays #if 0 if (inputLabel.findObject("IsisCube").hasGroup("BandBin")) { return "Array_3D_Spectrum"; } #endif int bands = (int) inputLabel.findObject("IsisCube") .findObject("Core") .findGroup("Dimensions") .findKeyword("Bands"); if (bands > 1) { return "Array_3D_Image"; } return "Array_2D_Image"; } /** * Adds necessary information to the xml header for a pds4 class. * Loading isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h +9 −3 Original line number Diff line number Diff line Loading @@ -98,22 +98,28 @@ namespace Isis { void WritePds4(QString outFile); QDomElement getElement(QStringList xmlPath, QDomElement parent=QDomElement()); void addHistory(QString description, QString date = "tbd", QString version = "1.0"); void setLogicalId(QString lid); void setSchemaLocation(QString schema); static void translateUnits(QDomDocument &label, QString transMapFile = "$base/translations/pds4ExportUnits.pvl"); protected: void addSchema(QString sch, QString xsd, QString xmlns, QString xmlnsURI) ; protected: // void addSchema(QString sch, QString xsd, QString xmlns, QString xmlnsURI) ; void identificationArea(); void standardInstrument(); void standardBandBin(); void displaySettings(); void fileAreaObservational(); QString imageObjectType(Pvl &inputLabel); QString PDS4PixelType(PixelType pixelType, ByteOrder endianType); static QMap<QString, QString> createUnitMap(Pvl configPvl); static void translateChildUnits(QDomElement parent, QMap<QString, QString> transMap); QDomDocument *m_domDoc; //!< XML label QString m_schemaLocation; //!< QString with all schema locations required QDomDocument *m_domDoc; //!< XML label. QString m_schemaLocation; //!< QString with all schema locations required. QString m_lid; //!< QString with specified logical identifier. }; } Loading Loading
isis/src/base/apps/isis2pds/isis2pds.cpp +40 −30 Original line number Diff line number Diff line Loading @@ -38,11 +38,13 @@ void IsisMain() { p.SetInputCube("FROM"); if (ui.GetString("STRETCH") == "LINEAR") { if(ui.GetString("BITTYPE") != "32BIT") if (ui.GetString("BITTYPE") != "32BIT") { p.SetInputRange(); } if(ui.GetString("STRETCH") == "MANUAL") } if (ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); } double min = -DBL_MAX; double max = DBL_MAX; Loading Loading @@ -75,13 +77,16 @@ void IsisMain() { setRangeAndPixels(ui, p, min, max, NONE); } if(ui.GetString("ENDIAN") == "MSB") if (ui.GetString("ENDIAN") == "MSB") { p.SetOutputEndian(Isis::Msb); else if(ui.GetString("ENDIAN") == "LSB") } else if (ui.GetString("ENDIAN") == "LSB") { p.SetOutputEndian(Isis::Lsb); } if(ui.GetString("LABTYPE") == "FIXED") if (ui.GetString("LABTYPE") == "FIXED") { p.SetExportType(ProcessExportPds::Fixed); } if (ui.GetBoolean("CHECKSUM")) { p.setCanGenerateChecksum(true); Loading Loading @@ -130,11 +135,13 @@ void IsisMain() { QString outFileName(outFile.expanded()); if (ui.GetString("STRETCH") == "LINEAR") { if(ui.GetString("BITTYPE") != "32BIT") if (ui.GetString("BITTYPE") != "32BIT") { process.SetInputRange(); } if(ui.GetString("STRETCH") == "MANUAL") } if (ui.GetString("STRETCH") == "MANUAL") { process.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); } double min = -DBL_MAX; double max = DBL_MAX; Loading Loading @@ -167,10 +174,12 @@ void IsisMain() { setRangeAndPixels(ui, process, min, max, NONE); } if(ui.GetString("ENDIAN") == "MSB") if (ui.GetString("ENDIAN") == "MSB") { process.SetOutputEndian(Isis::Msb); else if(ui.GetString("ENDIAN") == "LSB") } else if (ui.GetString("ENDIAN") == "LSB") { process.SetOutputEndian(Isis::Lsb); } // Records what it did to the print.prt file PvlGroup results("DNs Used"); Loading @@ -184,6 +193,7 @@ void IsisMain() { Application::Log(results); process.StandardPds4Label(); // ProcessExportPds4::translateUnits(pdsLabel);//??? process.WritePds4(outFileName); } Loading
isis/src/base/apps/isis2pds/tsts/pds4/Makefile +10 −1 Original line number Diff line number Diff line Loading @@ -7,8 +7,17 @@ commands: # Remove parts of output that can occur in any order and convert to txt for comparison $(SED) 's+\Product_Observational.*>+\Product_Observational>+' \ $(OUTPUT)/dawnEqui.xml > $(OUTPUT)/dawnEqui.txt; $(OUTPUT)/dawnEqui.xml \ > $(OUTPUT)/tempLabel1.txt; $(SED) 's+\modification_date.*>+\modification_date>+' \ $(OUTPUT)/tempLabel1.txt \ > $(OUTPUT)/tempLabel2.txt; $(SED) 's+\ISIS version.*<+\ISIS version.<+' \ $(OUTPUT)/tempLabel2.txt \ > $(OUTPUT)/dawnEqui.txt; $(RM) $(OUTPUT)/dawnEqui.xml > /dev/null; $(RM) $(OUTPUT)/tempLabel1.txt > /dev/null; $(RM) $(OUTPUT)/tempLabel2.txt > /dev/null; $(RM) $(OUTPUT)/dawnEqui.img > /dev/null;
isis/src/base/apps/stats/tsts/default/Makefile +2 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,6 @@ commands: > /dev/null; $(APPNAME) from=$(INPUT)/isisTruth.cub \ | grep -v stats \ | grep -v "stats:" \ | grep -v Processed \ >& $(OUTPUT)/output.pvl;
isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp +254 −119 Original line number Diff line number Diff line Loading @@ -24,8 +24,10 @@ #include <QDomDocument> #include <QMap> #include <QRegularExpression> #include <QString> #include "Application.h" #include "FileName.h" #include "IException.h" #include "Projection.h" Loading @@ -43,6 +45,9 @@ namespace Isis { * */ ProcessExportPds4::ProcessExportPds4() { m_lid = ""; qSetGlobalQHashSeed(1031); // hash seed to force consistent output m_domDoc = new QDomDocument(""); Loading Loading @@ -104,12 +109,19 @@ namespace Isis { /** * Create a standard PDS label for type IMAGE. The image label will be * Creates a PDS4 label. The image label will be * stored internally in the class. * * This method has a similar function to * ProcessExportPds::CreateImageLabel. However, it will create * images of object type Array_3D_Image, Array_2D_Image, or * Array_3D_Spectrum. */ void ProcessExportPds4::CreateImageLabel() { try { // <Product_Observational> // <Identification_Area> identificationArea(); } catch (IException &e) { Loading @@ -117,6 +129,8 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> standardInstrument(); } catch (IException &e) { Loading @@ -124,25 +138,34 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // <disp:Display_Settings> displaySettings(); } catch (IException &e) { QString msg = "Unable to translate and export display settings."; throw IException(e, IException::Programmer, msg, _FILEINFO_); } // Temporarily removed spectral processing because it needs further work. // // try { // standardBandBin(); // } // catch (IException &e) { // QString msg = "Unable to translate and export spectral information."; // throw IException(e, IException::Programmer, msg, _FILEINFO_); // } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // <sp:Spectral_Characteristics> OR <img:Imaging> standardBandBin(); } catch (IException &e) { QString msg = "Unable to translate and export spectral information."; throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // <Product_Observational> // <Observation_Area> // <Discipline_Area> // display settings, and cartography handled in this method: // <card:Cartography> StandardAllMapping(); } catch (IException &e) { Loading @@ -150,8 +173,9 @@ namespace Isis { throw IException(e, IException::Programmer, msg, _FILEINFO_); } try { // file observation area StandardImageImage(); // <Product_Observational> // <File_Area_Observational> fileAreaObservational(); } catch (IException &e) { QString msg = "Unable to translate and export standard image information."; Loading @@ -166,11 +190,13 @@ namespace Isis { */ void ProcessExportPds4::standardInstrument() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; FileName translationFileName; if (inputLabel->findObject("IsisCube").hasGroup("Instrument")) { // Translate the Instrument group transfile = "$base/translations/pds4ExportInstrument.trn"; PvlToXmlTranslationManager instXlator(*inputLabel, transfile.expanded()); translationFileName = "$base/translations/pds4ExportInstrument.trn"; PvlToXmlTranslationManager instXlator(*inputLabel, translationFileName.expanded()); instXlator.Auto(*m_domDoc); // If instrument and spacecraft values were translated, create the combined name Loading Loading @@ -232,24 +258,68 @@ namespace Isis { } // Translate the Target name try { transfile = "$base/translations/pds4ExportTargetFromInstrument.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, transfile.expanded()); translationFileName = "$base/translations/pds4ExportTargetFromInstrument.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, translationFileName.expanded()); targXlator.Auto(*m_domDoc); // move target to just below Observing_System. QDomElement targetIdNode = obsAreaNode.firstChildElement("Target_Identification"); obsAreaNode.insertAfter(targetIdNode, obsAreaNode.firstChildElement("Observing_System")); } catch (IException &e1) { try { transfile = "$base/translations/pds4ExportTargetFromMapping.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, transfile.expanded()); else if (inputLabel->findObject("IsisCube").hasGroup("Mapping")) { translationFileName = "$base/translations/pds4ExportTargetFromMapping.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, translationFileName.expanded()); targXlator.Auto(*m_domDoc); } else { throw IException(IException::Unknown, "Unable to find a target in input cube.", _FILEINFO_); } catch (IException &e2) { IException finalError(IException::Unknown, "Unable to find a target in input cube.", _FILEINFO_); finalError.append(e1); finalError.append(e2); throw finalError; } /** * Allows mission specific programs to set logical_identifier * required for PDS4 labels. This value is added to the xml file * by the identificationArea() method. * * The input string should be colon separated string with 6 * identifiers: * * <ol> * <li> urn </li> * <li> space_agency (ususally nasa) </li> * <li> archiving_organization (usually pds) </li> * <li> bundle_id </li> * <li> collection_id </li> * <li> product_id </li> * </ol> * * Example: * urn:esa:psa:em16_tgo_frd:data_raw:frd_raw_sc_d_20150625T133700-20150625T135700 * * @author 2018-05-21 Jeannie Backer * * @param lid The logical identifier value required for PDS4 * compliant labels. */ void ProcessExportPds4::setLogicalId(QString lid) { m_lid = lid; } /** * Allows mission specific programs to use specified * versions of dictionaries. * * @author 2018-05-21 Jeannie Backer * * @param schema The string of schema to be set. */ void ProcessExportPds4::setSchemaLocation(QString schema) { m_schemaLocation = schema; } Loading @@ -259,10 +329,46 @@ namespace Isis { */ void ProcessExportPds4::identificationArea() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; transfile = "$base/translations/pds4ExportIdentificationArea.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); FileName translationFileName; translationFileName = "$base/translations/pds4ExportIdentificationArea.trn"; PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); if (m_lid.isEmpty()) { m_lid = "urn:nasa:pds:TBD:TBD:TBD"; } QDomElement identificationElement; QStringList identificationPath; identificationPath.append("Product_Observational"); identificationPath.append("Identification_Area"); try { identificationElement = getElement(identificationPath); if( identificationElement.isNull() ) { throw IException(IException::Unknown, "", _FILEINFO_); } } catch(IException &e) { QString msg = "Could not find Identification_Area element " "to add modification history under."; throw IException(IException::Programmer, msg, _FILEINFO_); } QDomElement lidElement = identificationElement.firstChildElement("logical_identifier"); PvlToXmlTranslationManager::resetElementValue(lidElement, m_lid); // Get export history and add <Modification_History> element. // These regular expressions match the pipe followed by the date from // the Application::Version() return value. QRegularExpression versionRegex(" \\| \\d{4}\\-\\d{2}\\-\\d{2}"); QString historyDescription = "Created PDS4 output product from ISIS cube with the " + FileName(Application::Name()).baseName() + " application from ISIS version " + Application::Version().remove(versionRegex) + "."; // This regular expression matches the time from the Application::DateTime return value. QRegularExpression dateRegex("T\\d{2}:\\d{2}:\\d{2}"); QString historyDate = Application::DateTime().remove(dateRegex); addHistory(historyDescription, historyDate); } Loading @@ -273,9 +379,9 @@ namespace Isis { void ProcessExportPds4::displaySettings() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; transfile = "$base/translations/pds4ExportDisplaySettings.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); FileName translationFileName; translationFileName = "$base/translations/pds4ExportDisplaySettings.trn"; PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); // Add header info Loading @@ -294,14 +400,9 @@ namespace Isis { // Spectra // Get the input Isis cube label and find the BandBin group if it has one Pvl *inputLabel = InputCubes[0]->label(); if(inputLabel->hasObject("IsisCube") && !(inputLabel->findObject("IsisCube").hasGroup("BandBin"))) return; FileName transfile; transfile = "$base/translations/pds4ExportBandBin.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); xlator.Auto(*m_domDoc); QString imageObject = imageObjectType(*inputLabel); if (imageObject.compare("Array_3D_Spectrum") == 0) { // Add header info addSchema("PDS4_SP_1100.sch", "PDS4_SP_1100.xsd", Loading @@ -309,17 +410,32 @@ namespace Isis { "http://pds.nasa.gov/pds4/sp/v1"); } QString translationFile = "$base/translations/pds4ExportBandBin"; translationFile += imageObject.remove(0,9); // remove first 9 characters: Array_2D_ or Array_3D_ translationFile += ".trn"; FileName translationFileName(translationFile); PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); } /** * Create and internalize a standard image output label from the input image. * @todo determine whether to treat single band as 2d array * Create and internalize an image output label from the input * image. This method has a similar function to * ProcessExportPds::StandardImageImage. */ void ProcessExportPds4::StandardImageImage() { void ProcessExportPds4::fileAreaObservational() { Pvl *inputLabel = InputCubes[0]->label(); FileName transfile; QString imageObject = imageObjectType(*inputLabel); transfile = "$base/translations/pds4ExportArray3DImage.trn"; PvlToXmlTranslationManager xlator(*inputLabel, transfile.expanded()); QString translationFile = "$base/translations/pds4Export"; translationFile += QString(imageObject).remove('_'); translationFile += ".trn"; FileName translationFileName(translationFile); PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded()); xlator.Auto(*m_domDoc); QDomElement rootElement = m_domDoc->documentElement(); Loading Loading @@ -350,15 +466,14 @@ namespace Isis { } if (!fileAreaObservationalElement.isNull()) { QDomElement array3DImageElement = fileAreaObservationalElement.firstChildElement("Array_3D_Image"); if (!array3DImageElement.isNull()) { QDomElement arrayImageElement = fileAreaObservationalElement.firstChildElement(imageObject); if (!arrayImageElement.isNull()) { // reorder axis elements. // Translation order: elements, axis_name, sequence_number // Correct order: axis_name, elements, sequence_number QDomElement axisArrayElement = array3DImageElement.firstChildElement("Axis_Array"); QDomElement axisArrayElement = arrayImageElement.firstChildElement("Axis_Array"); while( !axisArrayElement.isNull() ) { QDomElement axisNameElement = axisArrayElement.firstChildElement("axis_name"); axisArrayElement.insertBefore(axisNameElement, Loading @@ -367,8 +482,8 @@ namespace Isis { } QDomElement elementArrayElement = m_domDoc->createElement("Element_Array"); array3DImageElement.insertBefore(elementArrayElement, array3DImageElement.firstChildElement("Axis_Array")); arrayImageElement.insertBefore(elementArrayElement, arrayImageElement.firstChildElement("Axis_Array")); QDomElement dataTypeElement = m_domDoc->createElement("data_type"); PvlToXmlTranslationManager::setElementValue(dataTypeElement, Loading @@ -389,6 +504,26 @@ namespace Isis { } QString ProcessExportPds4::imageObjectType(Pvl &inputLabel) { // not sure how to easily determine whether an isis3 cube should be // exported as spectral. for now, we will only export image arrays #if 0 if (inputLabel.findObject("IsisCube").hasGroup("BandBin")) { return "Array_3D_Spectrum"; } #endif int bands = (int) inputLabel.findObject("IsisCube") .findObject("Core") .findGroup("Dimensions") .findKeyword("Bands"); if (bands > 1) { return "Array_3D_Image"; } return "Array_2D_Image"; } /** * Adds necessary information to the xml header for a pds4 class. * Loading
isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h +9 −3 Original line number Diff line number Diff line Loading @@ -98,22 +98,28 @@ namespace Isis { void WritePds4(QString outFile); QDomElement getElement(QStringList xmlPath, QDomElement parent=QDomElement()); void addHistory(QString description, QString date = "tbd", QString version = "1.0"); void setLogicalId(QString lid); void setSchemaLocation(QString schema); static void translateUnits(QDomDocument &label, QString transMapFile = "$base/translations/pds4ExportUnits.pvl"); protected: void addSchema(QString sch, QString xsd, QString xmlns, QString xmlnsURI) ; protected: // void addSchema(QString sch, QString xsd, QString xmlns, QString xmlnsURI) ; void identificationArea(); void standardInstrument(); void standardBandBin(); void displaySettings(); void fileAreaObservational(); QString imageObjectType(Pvl &inputLabel); QString PDS4PixelType(PixelType pixelType, ByteOrder endianType); static QMap<QString, QString> createUnitMap(Pvl configPvl); static void translateChildUnits(QDomElement parent, QMap<QString, QString> transMap); QDomDocument *m_domDoc; //!< XML label QString m_schemaLocation; //!< QString with all schema locations required QDomDocument *m_domDoc; //!< XML label. QString m_schemaLocation; //!< QString with all schema locations required. QString m_lid; //!< QString with specified logical identifier. }; } Loading