Isis 3.0 Programmer Reference
Back | Home
BundleSettings.cpp
1 #include "BundleSettings.h"
2 
3 #include <QDataStream>
4 #include <QDebug>
5 //#include <QFile> currently only used in commented code
6 #include <QList>
7 #include <QString>
8 #include <QtGlobal> // qMax()
9 #include <QUuid>
10 #include <QXmlStreamWriter>
11 #include <QXmlInputSource>
12 
13 #include <H5Cpp.h>
14 #include <hdf5_hl.h>
15 #include <hdf5.h>
16 
18 //#include "FileName.h"currently only used in commented code
19 #include "IException.h"
20 #include "IString.h"
21 #include "Project.h" // currently used for xml handler
22 #include "PvlKeyword.h"
23 #include "PvlObject.h"
24 #include "SpecialPixel.h"
25 #include "XmlStackedHandlerReader.h"
26 
27 namespace Isis {
28 
38  m_id = NULL;
39  m_id = new QUuid(QUuid::createUuid());
40 
41  m_validateNetwork = true;
42 
43  m_solveObservationMode = false;
44  m_solveRadius = false;
45  m_updateCubeLabel = false;
46  m_errorPropagation = false;
47  m_createInverseMatrix = true;
48 
49  m_outlierRejection = false;
51 
52  // Parameter Uncertainties (Weighting)
56 
57  BundleObservationSolveSettings defaultSolveSettings;
58  m_observationSolveSettings.append(defaultSolveSettings);
59 
60  // Convergence Criteria
64 
65  // Maximum Likelihood Estimation Options no default in the constructor - must be set.
66  m_maximumLikelihood.clear();
67 
68  // Self Calibration ??? (from cnetsuite only)
69 
70  // Target Body
71  m_solveTargetBody = false;
72 // m_solveTargetBodyPolePosition = false;
73 // m_solveTargetBodyZeroMeridian = false;
74 // m_solveTargetBodyRotationRate = false;
75 // m_solveTargetBodyRadiusMethod = None;
76 
77  // Output Options
78  m_outputFilePrefix = "";
79  }
80 
81 
99  XmlStackedHandlerReader *xmlReader) {
100  m_id = NULL;
101  // what about the rest of the member data ??? should we set defaults ??? CREATE INITIALIZE METHOD
102 
103  xmlReader->pushContentHandler(new XmlHandler(this, project));
104  xmlReader->setErrorHandler(new XmlHandler(this, project));
105 
106  }
107 
108 
109 #if 0
110 
120  Project *project,
121  XmlStackedHandlerReader *xmlReader) {
122 
123 
124  m_id = NULL;
125  // what about the rest of the member data ??? should we set defaults ???
126 
127  QString xmlPath = xmlFile.expanded();
128  QFile qXmlFile(xmlPath);
129  if (!qXmlFile.open(QFile::ReadOnly) ) {
131  QString("Unable to open xml file, [%1], with read access").arg(xmlPath),
132  _FILEINFO_);
133  }
134 
135  QXmlInputSource xmlInputSource(&qXmlFile);
136 
137  xmlReader->pushContentHandler(new XmlHandler(this, project));
138  xmlReader->setErrorHandler(new XmlHandler(this, project));
139  bool success = xmlReader->parse(xmlInputSource);
140  if (!success) {
142  QString("Failed to parse xml file, [%1]").arg(xmlPath),
143  _FILEINFO_);
144  }
145  }
146 
147 
153  m_id = NULL;
154  xmlReader->pushContentHandler(new XmlHandler(this));
155  xmlReader->setErrorHandler(new XmlHandler(this));
156  }
157 
161  BundleSettings::BundleSettings(H5::CommonFG &locationObject, QString locationName) {
162  openH5Group(locationObject, locationName);
163  }
164 #endif
165 
166 
174  : m_id(new QUuid(other.m_id->toString())),
175  m_validateNetwork(other.m_validateNetwork),
176  m_solveObservationMode(other.m_solveObservationMode),
177  m_solveRadius(other.m_solveRadius),
178  m_updateCubeLabel(other.m_updateCubeLabel),
179  m_errorPropagation(other.m_errorPropagation),
180  m_createInverseMatrix(other.m_createInverseMatrix),
181  m_outlierRejection(other.m_outlierRejection),
182  m_outlierRejectionMultiplier(other.m_outlierRejectionMultiplier),
183  m_globalLatitudeAprioriSigma(other.m_globalLatitudeAprioriSigma),
184  m_globalLongitudeAprioriSigma(other.m_globalLongitudeAprioriSigma),
185  m_globalRadiusAprioriSigma(other.m_globalRadiusAprioriSigma),
186  m_observationSolveSettings(other.m_observationSolveSettings),
187  m_convergenceCriteria(other.m_convergenceCriteria),
188  m_convergenceCriteriaThreshold(other.m_convergenceCriteriaThreshold),
189  m_convergenceCriteriaMaximumIterations(other.m_convergenceCriteriaMaximumIterations),
190  m_maximumLikelihood(other.m_maximumLikelihood),
191  m_solveTargetBody(other.m_solveTargetBody),
192  m_bundleTargetBody(other.m_bundleTargetBody),
193  m_outputFilePrefix(other.m_outputFilePrefix){
194  }
195 
196 
201  delete m_id;
202  m_id = NULL;
203  }
204 
205 
215  if (&other != this) {
216  delete m_id;
217  m_id = NULL;
218  m_id = new QUuid(other.m_id->toString());
219 
231  m_observationSolveSettings = other.m_observationSolveSettings;
239  }
240  return *this;
241  }
242 
243 
256  }
257 
258 
270  return m_validateNetwork;
271  }
272 
273 
274  // =============================================================================================//
275  // ======================== Solve Options ======================================================//
276  // =============================================================================================//
277 
293  void BundleSettings::setSolveOptions(bool solveObservationMode,
294  bool updateCubeLabel,
295  bool errorPropagation,
296  bool solveRadius,
297  double globalLatitudeAprioriSigma,
298  double globalLongitudeAprioriSigma,
299  double globalRadiusAprioriSigma) {
304 
305  if (globalLatitudeAprioriSigma > 0.0) { // otherwise, we leave as default Isis::Null
307  }
308  else {
310  }
311 
312  if (globalLongitudeAprioriSigma > 0.0) {
314  }
315  else {
317  }
318 
319  if (m_solveRadius && globalRadiusAprioriSigma > 0.0) {
321  }
322  else {
324  }
325  }
326 
327 
335  void BundleSettings::setOutlierRejection(bool outlierRejection, double multiplier) {
337  if (m_outlierRejection) {
338  m_outlierRejectionMultiplier = multiplier;
339  }
340  else {
342  }
343  }
344 
345 
354  QList<BundleObservationSolveSettings> obsSolveSettingsList) {
355  m_observationSolveSettings = obsSolveSettingsList;
356  }
357 
358 
372  }
373 
374 
383  return m_outlierRejection;
384  }
385 
386 
394  return m_solveObservationMode;
395  }
396 
397 
405  return m_solveRadius;
406  }
407 
408 
417  return m_updateCubeLabel;
418  }
419 
420 
428  return m_errorPropagation;
429  }
430 
431 
445  void BundleSettings::setCreateInverseMatrix(bool createMatrixFile) {
446  m_createInverseMatrix = createMatrixFile;
447  }
448 
449 
457  }
458 
459 
468  }
469 
470 
479  }
480 
481 
490  }
491 
492 
500  return m_observationSolveSettings.size();
501  }
502 
503 
518  BundleSettings::observationSolveSettings(QString observationNumber) const {
519 
520  for (int i = 0; i < numberSolveSettings(); i++) {
521  if (m_observationSolveSettings[i].observationNumbers().contains(observationNumber)) {
522  return m_observationSolveSettings[i];
523  }
524  }
525  QString msg = "Unable to find BundleObservationSolveSettings for observation number ["
526  + observationNumber + "].";
528  }
529 
530 
544 
545  if (n >= 0 && n < numberSolveSettings()) {
546  return m_observationSolveSettings[n];
547  }
548  QString msg = "Unable to find BundleObservationSolveSettings with index = ["
549  + toString(n) + "].";
551  }
552 
553 
554  // =============================================================================================//
555  // ======================== Convergence Criteria ===============================================//
556  // =============================================================================================//
557 
575  if (criteria.compare("SIGMA0", Qt::CaseInsensitive) == 0) {
576  return BundleSettings::Sigma0;
577  }
578  else if (criteria.compare("PARAMETERCORRECTIONS", Qt::CaseInsensitive) == 0) {
580  }
582  "Unknown bundle convergence criteria [" + criteria + "].",
583  _FILEINFO_);
584  }
585 
586 
600  if (criteria == Sigma0) return "Sigma0";
601  else if (criteria == ParameterCorrections) return "ParameterCorrections";
603  "Unknown convergence criteria enum [" + toString(criteria) + "].",
604  _FILEINFO_);
605  }
606 
607 
619  double threshold,
620  int maximumIterations) {
621  m_convergenceCriteria = criteria;
622  m_convergenceCriteriaThreshold = threshold;
623  m_convergenceCriteriaMaximumIterations = maximumIterations;
624  }
625 
626 
634  return m_convergenceCriteria;
635  }
636 
637 
646  }
647 
648 
659  }
660 
661 
662 
663  // =============================================================================================//
664  // ======================== Parameter Uncertainties (Weighting) ================================//
665  // =============================================================================================//
666 // void BundleSettings::setGlobalLatitudeAprioriSigma(double sigma) {
667 // m_globalLatitudeAprioriSigma = sigma;
668 // }
669 //
670 //
671 //
672 // void BundleSettings::setGlobalLongitudeAprioriSigma(double sigma) {
673 // m_globalLongitudeAprioriSigma = sigma;
674 // }
675 //
676 //
677 //
678 // void BundleSettings::setGlobalRadiiAprioriSigma(double sigma) {
679 // m_globalRadiusAprioriSigma = sigma;
680 // }
681 
682 
683  // =============================================================================================//
684  // ======================== Maximum Likelihood Estimation Options ==============================//
685  // =============================================================================================//
686 
687 
701  double maxModelCQuantile) {
702 
704  QString msg = "For bundle adjustments with multiple maximum likelihood estimators, the first "
705  "model must be of type HUBER or HUBER_MODIFIED.";
707  }
708 
709  m_maximumLikelihood.append(qMakePair(model, maxModelCQuantile));
710  }
711 
712 
723  return m_maximumLikelihood;
724  }
725 
726 
727  // =============================================================================================//
728  // ======================== Self Calibration ??? (from cnetsuite only) =========================//
729  // =============================================================================================//
730 
731  // =============================================================================================//
732  // ======================== Target Body ??? (from cnetsuite only) ==============================//
733  // =============================================================================================//
734 
743  }
744 
745 
753  return m_bundleTargetBody;
754  }
755 
756 
763 // bool BundleSettings::solveTargetBodyPolePosition() const {
764 // return m_solveTargetBodyPolePosition;
765 // }
766 
767 
775  if (!m_bundleTargetBody)
776  return 0;
777 
778  return m_bundleTargetBody->numberParameters();
779  }
780 
781 
789  if (!m_bundleTargetBody) {
790  return false;
791  }
792  else {
793  return (m_bundleTargetBody->numberParameters() > 0);
794  }
795  }
796 
797 
807  if (!m_bundleTargetBody) {
808  return false;
809  }
810  return m_bundleTargetBody->solvePoleRA();
811  }
812 
813 
823  if (!m_bundleTargetBody) {
824  return false;
825  }
826  return m_bundleTargetBody->solvePoleRAVelocity();
827  }
828 
829 
839  if (!m_bundleTargetBody) {
840  return false;
841  }
842  return m_bundleTargetBody->solvePoleDec();
843  }
844 
845 
855  if (!m_bundleTargetBody) {
856  return false;
857  }
858  return m_bundleTargetBody->solvePoleDecVelocity();
859  }
860 
861 
870  bool BundleSettings::solvePM() const {
871  if (!m_bundleTargetBody) {
872  return false;
873  }
874  return m_bundleTargetBody->solvePM();
875  }
876 
877 
887  if (!m_bundleTargetBody) {
888  return false;
889  }
890  return m_bundleTargetBody->solvePMVelocity();
891  }
892 
893 
903  if (!m_bundleTargetBody) {
904  return false;
905  }
906  return m_bundleTargetBody->solvePMAcceleration();
907  }
908 
909 
919  if (!m_bundleTargetBody) {
920  return false;
921  }
922  return m_bundleTargetBody->solveTriaxialRadii();
923  }
924 
925 
935  if (!m_bundleTargetBody) {
936  return false;
937  }
938  return m_bundleTargetBody->solveMeanRadius();
939  }
940 
941 
942 // void BundleSettings::setTargetBodySolveOptions(bool solveTargetBodyPolePosition,
943 // double aprioriRaPole, double sigmaRaPole,
944 // double aprioriDecPole, double sigmaDecPole,
945 // bool solveTargetBodyZeroMeridian,
946 // double aprioriW0, double sigmaW0,
947 // bool solveTargetBodyRotationRate,
948 // double aprioriWDot, double sigmaWDot,
949 // TargetRadiiSolveMethod solveRadiiMethod,
950 // double aprioriRadiusA, double sigmaRadiusA,
951 // double aprioriRadiusB, double sigmaRadiusB,
952 // double aprioriRadiusC, double sigmaRadiusC,
953 // double aprioriMeanRadius, double sigmaMeanRadius) {
954 
955 
956 // m_solveTargetBody = true;
957 // m_solveTargetBodyPolePosition = solveTargetBodyPolePosition;
958 // m_aprioriRaPole = aprioriRaPole;
959 // m_sigmaRaPole = sigmaRaPole;
960 // m_aprioriDecPole = aprioriDecPole;
961 // m_sigmaDecPole = sigmaDecPole;
962 // m_solveTargetBodyZeroMeridian =solveTargetBodyZeroMeridian;
963 // m_aprioriW0 = aprioriW0;
964 // m_sigmaW0 = sigmaW0;
965 // m_solveTargetBodyRotationRate = solveTargetBodyRotationRate;
966 // m_aprioriWDot = aprioriWDot;
967 // m_sigmaWDot = sigmaWDot;
968 // m_solveTargetBodyRadiusMethod = solveRadiiMethod;
969 // m_aprioriRadiusA = aprioriRadiusA;
970 // m_sigmaRadiusA = sigmaRadiusA;
971 // m_aprioriRadiusB = aprioriRadiusB;
972 // m_sigmaRadiusB = sigmaRadiusB;
973 // m_aprioriRadiusC = aprioriRadiusC;
974 // m_sigmaRadiusC = sigmaRadiusC;
975 // m_aprioriMeanRadius = aprioriMeanRadius;
976 // m_sigmaMeanRadius = sigmaMeanRadius;
977 
978 // m_bundleTargetBody->setSolveSettings(solveTargetBodyPolePosition, aprioriRaPole, sigmaRaPole,
979 // aprioriDecPole, sigmaDecPole, solveTargetBodyZeroMeridian,
980 // aprioriW0, sigmaW0, solveTargetBodyRotationRate,
981 // aprioriWDot, sigmaWDot, solveRadiiMethod, aprioriRadiusA,
982 // sigmaRadiusA, aprioriRadiusB, sigmaRadiusB, aprioriRadiusC,
983 // sigmaRadiusC, aprioriMeanRadius, sigmaMeanRadius);
984 // }
985 
986 
987  // =============================================================================================//
988  // ========================= Output Options (from Jigsaw only) ================================//
989  // =============================================================================================//
995  void BundleSettings::setOutputFilePrefix(QString outputFilePrefix) {
997  }
998 
999 
1010  return m_outputFilePrefix;
1011  }
1012 
1013 
1023  PvlObject BundleSettings::pvlObject(QString name) const {
1024 
1025  PvlObject pvl(name);
1026 
1027  // General Solve Options
1028  pvl += PvlKeyword("NetworkValidated", toString(validateNetwork()));
1029  pvl += PvlKeyword("SolveObservationMode", toString(solveObservationMode()));
1030  pvl += PvlKeyword("SolveRadius", toString(solveRadius()));
1031  pvl += PvlKeyword("UpdateCubeLabel", toString(updateCubeLabel()));
1032  pvl += PvlKeyword("ErrorPropagation", toString(errorPropagation()));
1033  pvl += PvlKeyword("CreateInverseMatrix", toString(createInverseMatrix()));
1034  pvl += PvlKeyword("OutlierRejection", toString(outlierRejection()));
1035  if (m_outlierRejection) {
1036  pvl += PvlKeyword("OutlierMultiplier", toString(outlierRejectionMultiplier()));
1037  }
1039  pvl += PvlKeyword("GlobalLatitudeAprioriSigma", toString(globalLatitudeAprioriSigma()));
1040  }
1041  else {
1042  pvl += PvlKeyword("GlobalLatitudeAprioriSigma", "None");
1043  }
1045  pvl += PvlKeyword("GlobalLongitudeAprioriSigma", toString(globalLongitudeAprioriSigma()));
1046  }
1047  else {
1048  pvl += PvlKeyword("GlobalLongitudeAprioriSigma", "None");
1049  }
1050  if (m_solveRadius) {
1052  pvl += PvlKeyword("GlobalRadiiAprioriSigma", toString(globalRadiusAprioriSigma()));
1053  }
1054  else {
1055  pvl += PvlKeyword("GlobalRadiiAprioriSigma", "None");
1056  }
1057  }
1058 
1059  // Convergence Criteria
1060  pvl += PvlKeyword("ConvergenceCriteria", convergenceCriteriaToString(convergenceCriteria()));
1061  pvl += PvlKeyword("ConvergenceCriteriaThreshold", toString(convergenceCriteriaThreshold()));
1062  pvl += PvlKeyword("ConvergenceCriteriaMaximumIterations",
1064 
1065  // Target body
1066  pvl += PvlKeyword("SolveTargetBody", toString(solveTargetBody()));
1067  pvl += PvlKeyword("NumberTargetBodyParameters", toString(numberTargetBodyParameters()));
1068  pvl += PvlKeyword("SolvePoleRightAscension", toString(solvePoleRA()));
1069  pvl += PvlKeyword("SolvePoleRightAscensionVelocity", toString(solvePoleRAVelocity()));
1070  pvl += PvlKeyword("SolvePoleDeclination", toString(solvePoleDec()));
1071  pvl += PvlKeyword("SolvePoleDeclinationVelocity", toString(solvePoleDecVelocity()));
1072  pvl += PvlKeyword("SolvePolePrimeMeridian", toString(solvePM()));
1073  pvl += PvlKeyword("SolvePolePrimeMeridianVelocity", toString(solvePMVelocity()));
1074  pvl += PvlKeyword("SolvePolePrimeMeridianAcceleration", toString(solvePMAcceleration()));
1075  pvl += PvlKeyword("solveTriaxialRadii", toString(solveTriaxialRadii()));
1076  pvl += PvlKeyword("solveMeanRadius", toString(solveMeanRadius()));
1077 
1078  // Output Options
1079  pvl += PvlKeyword("FilePrefix", outputFilePrefix());
1080 
1081  // Maximum Likelihood Options
1082  PvlKeyword models("MaximumLikelihoodModels");
1083  if (m_maximumLikelihood.size() > 0) {
1084 
1086 
1087  PvlKeyword quantiles("MaximumLikelihoodQuantiles",
1088  toString(m_maximumLikelihood[0].second));
1089 
1090  for (int i = 1; i < m_maximumLikelihood.size(); i++) {
1092  quantiles.addValue(toString(m_maximumLikelihood[i].second));
1093  }
1094  pvl += models;
1095  pvl += quantiles;
1096  }
1097  else {
1098  models.addValue("None");
1099  }
1100 
1101  pvl += PvlKeyword("NumberObservationSolveSettings", toString(numberSolveSettings()));
1102 
1103  for (int i = 0; i < numberSolveSettings(); i++) {
1105  PvlObject bundleObsSolveSettingsPvl = boss.pvlObject();
1106  pvl += bundleObsSolveSettingsPvl;
1107  }
1108 
1109  return pvl;
1110  }
1111 
1112 
1120  void BundleSettings::save(QXmlStreamWriter &stream, const Project *project) const {
1121 //#if 0
1122  // option 2
1123  stream.writeStartElement("bundleSettings");
1124 
1125  stream.writeStartElement("globalSettings");
1126 
1127  stream.writeTextElement("id", m_id->toString());
1128  stream.writeTextElement("validateNetwork", toString(validateNetwork()));
1129 
1130  stream.writeStartElement("solveOptions");
1131  stream.writeAttribute("solveObservationMode", toString(solveObservationMode()));
1132  stream.writeAttribute("solveRadius", toString(solveRadius()));
1133  stream.writeAttribute("updateCubeLabel", toString(updateCubeLabel()));
1134  stream.writeAttribute("errorPropagation", toString(errorPropagation()));
1135  stream.writeAttribute("createInverseMatrix", toString(createInverseMatrix()));
1136  stream.writeEndElement();
1137 
1138  stream.writeStartElement("aprioriSigmas");
1140  stream.writeAttribute("latitude", "N/A");
1141  }
1142  else {
1143  stream.writeAttribute("latitude", toString(globalLatitudeAprioriSigma()));
1144  }
1146  stream.writeAttribute("longitude", "N/A");
1147  }
1148  else {
1149  stream.writeAttribute("longitude", toString(globalLongitudeAprioriSigma()));
1150  }
1152  stream.writeAttribute("radius", "N/A");
1153  }
1154  else {
1155  stream.writeAttribute("radius", toString(globalRadiusAprioriSigma()));
1156  }
1157  stream.writeEndElement();
1158 
1159  stream.writeStartElement("outlierRejectionOptions");
1160  stream.writeAttribute("rejection", toString(outlierRejection()));
1161  if (outlierRejection()) {
1162  stream.writeAttribute("multiplier", toString(outlierRejectionMultiplier()));
1163  }
1164  else {
1165  stream.writeAttribute("multiplier", "N/A");
1166  }
1167  stream.writeEndElement();
1168 
1169  stream.writeStartElement("convergenceCriteriaOptions");
1170  stream.writeAttribute("convergenceCriteria",
1172  stream.writeAttribute("threshold",
1174  stream.writeAttribute("maximumIterations",
1176  stream.writeEndElement();
1177 
1178  stream.writeStartElement("maximumLikelihoodEstimation");
1179  for (int i = 0; i < m_maximumLikelihood.size(); i++) {
1180  stream.writeStartElement("model");
1181  stream.writeAttribute("type",
1183  stream.writeAttribute("quantile", toString(m_maximumLikelihood[i].second));
1184  stream.writeEndElement();
1185  }
1186  stream.writeEndElement();
1187 
1188  stream.writeStartElement("outputFileOptions");
1189  stream.writeAttribute("fileNamePrefix", outputFilePrefix());
1190  stream.writeEndElement();
1191 
1192  stream.writeEndElement(); // end global settings
1193 
1194  if (!m_observationSolveSettings.isEmpty()) {
1195  stream.writeStartElement("observationSolveSettingsList");
1196  for (int i = 0; i < m_observationSolveSettings.size(); i++) {
1197  m_observationSolveSettings[i].save(stream, project);
1198  }
1199  stream.writeEndElement();
1200  }
1201  else {
1202  // throw error??? should not write if no observation settings...
1203  }
1204 //#endif
1205 
1206 
1207 
1208 #if 0
1209  // option 3
1210  stream.writeStartDocument("1.0");
1211  //stream.writeStartDocument("BundleSettingsOption3");
1212  stream.writeStartElement("globalSettings");
1213 
1214  stream.writeTextElement("id", m_id->toString());
1215  stream.writeTextElement("validateNetwork", toString(validateNetwork()));
1216 
1217  stream.writeStartElement("solveOptions");
1218  stream.writeTextElement("solveObservationMode", toString(solveObservationMode()));
1219  stream.writeTextElement("solveRadius", toString(solveRadius()));
1220  stream.writeTextElement("updateCubeLabel", toString(updateCubeLabel()));
1221  stream.writeTextElement("errorPropagation", toString(errorPropagation()));
1222  stream.writeEndElement();
1223 
1224  stream.writeStartElement("aprioriSigmas");
1225  stream.writeTextElement("latitude", toString(globalLatitudeAprioriSigma()));
1226  stream.writeTextElement("longitude", toString(globalLongitudeAprioriSigma()));
1227  if (solveRadius()) {
1228  stream.writeTextElement("radius", toString(globalRadiusAprioriSigma()));
1229  }
1230  else {
1231  stream.writeTextElement("radius", "N/A");
1232  }
1233  stream.writeEndElement();
1234 
1235  stream.writeStartElement("outlierRejectionOptions");
1236  stream.writeTextElement("rejection", toString(outlierRejection()));
1237  if (outlierRejection()) {
1238  stream.writeTextElement("multiplier", toString(outlierRejectionMultiplier()));
1239  }
1240  else {
1241  stream.writeTextElement("multiplier", "N/A");
1242  }
1243  stream.writeEndElement();
1244 
1245  stream.writeStartElement("convergenceCriteriaOptions");
1246  stream.writeTextElement("convergenceCriteria", convergenceCriteriaToString(convergenceCriteria()));
1247  stream.writeTextElement("threshold", toString(convergenceCriteriaThreshold()));
1248  stream.writeTextElement("maximumIterations", toString(convergenceCriteriaMaximumIterations()));
1249  stream.writeEndElement();
1250 
1251  stream.writeStartElement("maximumLikelihoodEstimation");
1252  for (int i = 0; i < m_maximumLikelihood.size(); i++) {
1253  stream.writeStartElement("model");
1254  stream.writeAttribute("type",
1256  stream.writeAttribute("quantile", toString(m_maximumLikelihood[i].second));
1257  stream.writeEndElement();
1258  }
1259  stream.writeEndElement();
1260 
1261  stream.writeStartElement("outputFileOptions");
1262  stream.writeTextElement("fileNamePrefix", outputFilePrefix());
1263  stream.writeEndElement();
1264 
1265  stream.writeEndElement(); // end global settings
1266 
1267  stream.writeStartElement("observationSolveSettingsList");
1268  stream.writeAttribute("listSize", toString(numberSolveSettings()));
1269  for (int i = 0; i < m_observationSolveSettings.size(); i++) {
1270  stream.writeStartElement("observationSolveSettings");
1271  m_observationSolveSettings[i].save(stream, project);
1272  stream.writeEndElement();
1273  }
1274  stream.writeEndElement();
1275 #endif
1276  stream.writeEndElement();
1277  }
1278 
1279 
1289  m_xmlHandlerBundleSettings = bundleSettings;
1290  m_xmlHandlerProject = project;
1291  m_xmlHandlerCharacters = "";
1292  m_xmlHandlerObservationSettings.clear();
1293  }
1294 
1295 
1296 
1297 // /**
1298 // * Create an XML Handler (reader) that can populate the BundleSettings class data. See
1299 // * BundleSettings::save() for the expected format.
1300 // *
1301 // * @param bundleSettings The BundleSettings we're going to be initializing
1302 // * @param imageFolder The folder that contains the Cube
1303 // */
1304 // BundleSettings::XmlHandler::XmlHandler(BundleSettings *bundleSettings) {
1305 // m_xmlHandlerBundleSettings = bundleSettings;
1306 // m_xmlHandlerProject = NULL;
1307 // m_xmlHandlerCharacters = "";
1308 // m_xmlHandlerObservationSettings.clear();
1309 // }
1310 
1311 
1320  // do not delete these pointers...
1321  // we don't own them, do we??? project passed into StatCumProbDistDynCalc constructor as pointer and bundleSettings = this
1322  // delete m_xmlHandlerProject;
1323  m_xmlHandlerProject = NULL;
1324  }
1325 
1326 
1336  bool BundleSettings::XmlHandler::startElement(const QString &namespaceURI,
1337  const QString &localName,
1338  const QString &qName,
1339  const QXmlAttributes &attributes) {
1340  m_xmlHandlerCharacters = "";
1341 
1342  if (XmlStackedHandler::startElement(namespaceURI, localName, qName, attributes)) {
1343 
1344  if (localName == "solveOptions") {
1345 
1346  QString solveObservationModeStr = attributes.value("solveObservationMode");
1347  if (!solveObservationModeStr.isEmpty()) {
1348  m_xmlHandlerBundleSettings->m_solveObservationMode = toBool(solveObservationModeStr);
1349  }
1350 
1351  QString solveRadiusStr = attributes.value("solveRadius");
1352  if (!solveRadiusStr.isEmpty()) {
1353  m_xmlHandlerBundleSettings->m_solveRadius = toBool(solveRadiusStr);
1354  }
1355 
1356  QString updateCubeLabelStr = attributes.value("updateCubeLabel");
1357  if (!updateCubeLabelStr.isEmpty()) {
1358  m_xmlHandlerBundleSettings->m_updateCubeLabel = toBool(updateCubeLabelStr);
1359  }
1360 
1361  QString errorPropagationStr = attributes.value("errorPropagation");
1362  if (!errorPropagationStr.isEmpty()) {
1363  m_xmlHandlerBundleSettings->m_errorPropagation = toBool(errorPropagationStr);
1364  }
1365 
1366  QString createInverseMatrixStr = attributes.value("createInverseMatrix");
1367  if (!createInverseMatrixStr.isEmpty()) {
1368  m_xmlHandlerBundleSettings->m_createInverseMatrix = toBool(createInverseMatrixStr);
1369  }
1370  }
1371  else if (localName == "aprioriSigmas") {
1372 
1373  QString globalLatitudeAprioriSigmaStr = attributes.value("latitude");
1374  m_xmlHandlerBundleSettings->m_globalLatitudeAprioriSigma = Isis::Null;
1375  // TODO: why do I need to init this one and not other sigmas???
1376  if (!globalLatitudeAprioriSigmaStr.isEmpty()) {
1377  if (globalLatitudeAprioriSigmaStr == "N/A") {
1378  m_xmlHandlerBundleSettings->m_globalLatitudeAprioriSigma = Isis::Null;
1379  }
1380  else {
1381  m_xmlHandlerBundleSettings->m_globalLatitudeAprioriSigma
1382  = toDouble(globalLatitudeAprioriSigmaStr);
1383  }
1384  }
1385 
1386  QString globalLongitudeAprioriSigmaStr = attributes.value("longitude");
1387  if (!globalLongitudeAprioriSigmaStr.isEmpty()) {
1388  if (globalLongitudeAprioriSigmaStr == "N/A") {
1389  m_xmlHandlerBundleSettings->m_globalLongitudeAprioriSigma = Isis::Null;
1390  }
1391  else {
1392  m_xmlHandlerBundleSettings->m_globalLongitudeAprioriSigma
1393  = toDouble(globalLongitudeAprioriSigmaStr);
1394  }
1395  }
1396 
1397  QString globalRadiusAprioriSigmaStr = attributes.value("radius");
1398  if (!globalRadiusAprioriSigmaStr.isEmpty()) {
1399  if (globalRadiusAprioriSigmaStr == "N/A") {
1400  m_xmlHandlerBundleSettings->m_globalRadiusAprioriSigma = Isis::Null;
1401  }
1402  else {
1403  m_xmlHandlerBundleSettings->m_globalRadiusAprioriSigma
1404  = toDouble(globalRadiusAprioriSigmaStr);
1405  }
1406  }
1407  }
1408  else if (localName == "outlierRejectionOptions") {
1409  QString outlierRejectionStr = attributes.value("rejection");
1410  if (!outlierRejectionStr.isEmpty()) {
1411  m_xmlHandlerBundleSettings->m_outlierRejection = toBool(outlierRejectionStr);
1412  }
1413 
1414  QString outlierRejectionMultiplierStr = attributes.value("multiplier");
1415  if (!outlierRejectionMultiplierStr.isEmpty()) {
1416  if (outlierRejectionMultiplierStr != "N/A") {
1417  m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier
1418  = toDouble(outlierRejectionMultiplierStr);
1419  }
1420  else {
1421  m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier = 1.0;
1422  }
1423  }
1424  }
1425  else if (localName == "convergenceCriteriaOptions") {
1426 
1427  QString convergenceCriteriaStr = attributes.value("convergenceCriteria");
1428  if (!convergenceCriteriaStr.isEmpty()) {
1429  m_xmlHandlerBundleSettings->m_convergenceCriteria
1430  = stringToConvergenceCriteria(convergenceCriteriaStr);
1431  }
1432 
1433  QString convergenceCriteriaThresholdStr = attributes.value("threshold");
1434  if (!convergenceCriteriaThresholdStr.isEmpty()) {
1435  m_xmlHandlerBundleSettings->m_convergenceCriteriaThreshold
1436  = toDouble(convergenceCriteriaThresholdStr);
1437  }
1438 
1439  QString convergenceCriteriaMaximumIterationsStr = attributes.value("maximumIterations");
1440  if (!convergenceCriteriaMaximumIterationsStr.isEmpty()) {
1441  m_xmlHandlerBundleSettings->m_convergenceCriteriaMaximumIterations
1442  = toInt(convergenceCriteriaMaximumIterationsStr);
1443  }
1444  }
1445  else if (localName == "model") {
1446  QString type = attributes.value("type");
1447  QString quantile = attributes.value("quantile");
1448  if (!type.isEmpty() && !quantile.isEmpty()) {
1449  m_xmlHandlerBundleSettings->m_maximumLikelihood.append(
1450  qMakePair(MaximumLikelihoodWFunctions::stringToModel(type),
1451  toDouble(quantile)));
1452  }
1453  }
1454  else if (localName == "outputFileOptions") {
1455  QString outputFilePrefixStr = attributes.value("fileNamePrefix");
1456  if (!outputFilePrefixStr.isEmpty()) {
1457  m_xmlHandlerBundleSettings->m_outputFilePrefix = outputFilePrefixStr;
1458  }
1459  }
1460  else if (localName == "bundleObservationSolveSettings") {
1461  m_xmlHandlerObservationSettings.append(
1462  new BundleObservationSolveSettings(m_xmlHandlerProject, reader()));
1463  }
1464  }
1465  return true;
1466  }
1467 
1468 
1476  bool BundleSettings::XmlHandler::characters(const QString &ch) {
1477  m_xmlHandlerCharacters += ch;
1478  return XmlStackedHandler::characters(ch);
1479  }
1480 
1481 
1489  bool BundleSettings::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
1490  const QString &qName) {
1491  if (!m_xmlHandlerCharacters.isEmpty()) {
1492  if (localName == "id") {
1493  m_xmlHandlerBundleSettings->m_id = NULL;
1494  m_xmlHandlerBundleSettings->m_id = new QUuid(m_xmlHandlerCharacters);
1495  }
1496  else if (localName == "validateNetwork") {
1497  m_xmlHandlerBundleSettings->m_validateNetwork = toBool(m_xmlHandlerCharacters);
1498  }
1499  else if (localName == "observationSolveSettingsList") {
1500  for (int i = 0; i < m_xmlHandlerObservationSettings.size(); i++) {
1501  m_xmlHandlerBundleSettings->m_observationSolveSettings.append(
1502  *m_xmlHandlerObservationSettings[i]);
1503  }
1504  m_xmlHandlerObservationSettings.clear();
1505  }
1506 
1507  m_xmlHandlerCharacters = "";
1508  }
1509  return XmlStackedHandler::endElement(namespaceURI, localName, qName);
1510  }
1511 
1512 
1520  bool BundleSettings::XmlHandler::fatalError(const QXmlParseException &exception) {
1521  qDebug() << "Parse error at line " << exception.lineNumber()
1522  << ", " << "column " << exception.columnNumber() << ": "
1523  << qPrintable(exception.message());
1524  return false;
1525  }
1526 
1527 
1536  QDataStream &BundleSettings::write(QDataStream &stream) const {
1537 
1538  stream << m_id->toString()
1541  << m_solveRadius
1550  << m_observationSolveSettings
1551  << (qint32)m_convergenceCriteria
1555  << m_outputFilePrefix;
1556 
1557  return stream;
1558 
1559  }
1560 
1561 
1570  QDataStream &BundleSettings::read(QDataStream &stream) {
1571 
1572  QString id;
1574 
1575  stream >> id
1578  >> m_solveRadius
1587  >> m_observationSolveSettings
1588  >> convergenceCriteria
1590  >> convergenceCriteriaMaximumIterations
1592  >> m_outputFilePrefix;
1593 
1594  delete m_id;
1595  m_id = NULL;
1596  m_id = new QUuid(id);
1597 
1599  m_convergenceCriteriaMaximumIterations = (int)convergenceCriteriaMaximumIterations;
1600 
1601  return stream;
1602  }
1603 
1604 
1613  QDataStream &operator<<(QDataStream &stream, const BundleSettings &settings) {
1614  return settings.write(stream);
1615  }
1616 
1617 
1626  QDataStream &operator>>(QDataStream &stream, BundleSettings &settings) {
1627  return settings.read(stream);
1628  }
1629 
1630 
1649  void BundleSettings::createH5Group(H5::CommonFG &locationObject, QString locationName) const {
1650  try {
1651  // Try block to detect exceptions raised by any of the calls inside it
1652  try {
1653  /*
1654  * Turn off the auto-printing when failure occurs so that we can
1655  * handle the errors appropriately
1656  */
1657 // H5::Exception::dontPrint();
1658 
1659  // create a settings group to add to the given H5 object
1660  QString settingsGroupName = locationName + "/BundleSettings";
1661  H5::Group settingsGroup = locationObject.createGroup(settingsGroupName.toLatin1());
1662 
1663  // use H5S_SCALAR data space type for single valued spaces
1664  H5::DataSpace spc;
1665  Attribute att;
1666  #if 0
1667  hsize_t dims[1] = {2};
1668  H5::DataSpace simple1x2Space(1, dims);
1669  dims[0] = 1;
1670  H5::DataSpace simple1DSpace(1, dims);
1671 
1672  hsize_t dims2D[2] = {{2}, {2}};
1673  H5::DataSpace simple2x2Space(2, dims);
1674  dims2D[2] = {1, 1};
1675  H5::DataSpace simple2x1Space(2, dims);
1676  #endif
1677 
1678  /*
1679  * Add bool attributes as predefined data type PredType::NATIVE_HBOOL
1680  */
1681  int intFromBool = (int)m_validateNetwork;
1682  att = settingsGroup.createAttribute("validateNetwork", PredType::NATIVE_HBOOL, spc);
1683  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1684 
1685  intFromBool = (int)m_solveObservationMode;
1686  att = settingsGroup.createAttribute("solveObservationMode", PredType::NATIVE_HBOOL, spc);
1687  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1688 
1689  intFromBool = (int)m_solveRadius;
1690  att = settingsGroup.createAttribute("solveRadius", PredType::NATIVE_HBOOL, spc);
1691  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1692 
1693  intFromBool = (int)m_updateCubeLabel;
1694  att = settingsGroup.createAttribute("updateCubeLabel", PredType::NATIVE_HBOOL, spc);
1695  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1696 
1697  intFromBool = (int)m_errorPropagation;
1698  att = settingsGroup.createAttribute("errorPropagation", PredType::NATIVE_HBOOL, spc);
1699  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1700 
1701  intFromBool = (int)m_createInverseMatrix;
1702  att = settingsGroup.createAttribute("createInverseMatrix", PredType::NATIVE_HBOOL, spc);
1703  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1704 
1705  intFromBool = (int)m_outlierRejection;
1706  att = settingsGroup.createAttribute("outlierRejection", PredType::NATIVE_HBOOL, spc);
1707  att.write(PredType::NATIVE_HBOOL, &intFromBool);
1708 
1709  /*
1710  * Add enum attributes as predefined data type PredType::C_S1 (string)
1711  */
1712  QString enumToStringValue = "";
1713  int stringSize = 0;
1714  H5::StrType strDataType;
1715 
1717  stringSize = enumToStringValue.length();
1718  strDataType = H5::StrType(PredType::C_S1, stringSize);
1719  att = settingsGroup.createAttribute("convergenceCriteria", strDataType, spc);
1720  att.write(strDataType, enumToStringValue.toStdString());
1721 
1722  /*
1723  * Add string attributes as predefined data type PredType::C_S1 (string)
1724  */
1725  stringSize = qMax(m_outputFilePrefix.length(), 1); // if empty string, set size to 1
1726  strDataType = H5::StrType(PredType::C_S1, stringSize);
1727  att = settingsGroup.createAttribute("outputFilePrefix", strDataType, spc);
1728  att.write(strDataType, m_outputFilePrefix.toStdString());
1729 
1730  /*
1731  * Add double attributes as predefined data type PredType::NATIVE_DOUBLE
1732  */
1733  att = settingsGroup.createAttribute("outlierRejectionMultiplier",
1734  PredType::NATIVE_DOUBLE,
1735  spc);
1736  att.write(PredType::NATIVE_DOUBLE, &m_outlierRejectionMultiplier);
1737 
1738  att = settingsGroup.createAttribute("globalLatitudeAprioriSigma",
1739  PredType::NATIVE_DOUBLE,
1740  spc);
1741  att.write(PredType::NATIVE_DOUBLE, &m_globalLatitudeAprioriSigma);
1742 
1743  att = settingsGroup.createAttribute("globalLongitudeAprioriSigma",
1744  PredType::NATIVE_DOUBLE,
1745  spc);
1746  att.write(PredType::NATIVE_DOUBLE, &m_globalLongitudeAprioriSigma);
1747 
1748  att = settingsGroup.createAttribute("globalRadiusAprioriSigma",
1749  PredType::NATIVE_DOUBLE,
1750  spc);
1751  att.write(PredType::NATIVE_DOUBLE, &m_globalRadiusAprioriSigma);
1752 
1753  att = settingsGroup.createAttribute("convergenceCriteriaThreshold",
1754  PredType::NATIVE_DOUBLE,
1755  spc);
1756  att.write(PredType::NATIVE_DOUBLE, &m_convergenceCriteriaThreshold);
1757 
1758  /*
1759  * Add integer attributes as predefined data type PredType::NATIVE_INT
1760  */
1761  att = settingsGroup.createAttribute("convergenceCriteriaMaximumIterations",
1762  PredType::NATIVE_INT,
1763  spc);
1764  att.write(PredType::NATIVE_INT, &m_convergenceCriteriaMaximumIterations);
1765 
1766  // Data sets??? tables???
1767  // ??? QList<BundleObservationSolveSettings> m_observationSolveSettings; // TODO: pointer???
1768  // ??? QList< QPair< MaximumLikelihoodWFunctions::Model, double > > m_maximumLikelihood;
1769  // // TODO: pointer???
1770 // return locationObject;
1771  }
1772  // catch failure caused by the Attribute operations
1773  catch ( H5::AttributeIException error ) {
1774  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1775  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1776  msg = "H5 ATTRIBUTE exception handler has detected an error when invoking the function "
1777  + QString::fromStdString(error.getFuncName()) + ".";
1778  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1779  }
1780  // catch failure caused by the DataSet operations
1781  catch ( H5::DataSetIException error ) {
1782  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1783  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1784  msg = "H5 DATA SET exception handler has detected an error when invoking the function "
1785  + QString::fromStdString(error.getFuncName()) + ".";
1786  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1787  }
1788  // catch failure caused by the DataSpace operations
1789  catch ( H5::DataSpaceIException error ) {
1790  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1791  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1792  msg = "H5 DATA SPACE exception handler has detected an error when invoking the function "
1793  + QString::fromStdString(error.getFuncName()) + ".";
1794  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1795  }
1796  // catch failure caused by the DataType operations
1797  catch ( H5::DataTypeIException error ) {
1798  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1799  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1800  msg = "H5 DATA TYPE exception handler has detected an error when invoking the function "
1801  + QString::fromStdString(error.getFuncName()) + ".";
1802  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1803  }
1804  // catch failure caused by the H5File operations
1805  catch ( H5::FileIException error ) {
1806  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1807  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1808  msg = "H5 FILE exception handler has detected an error when invoking the function "
1809  + QString::fromStdString(error.getFuncName()) + ".";
1810  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1811  }
1812  // catch failure caused by the Group operations
1813  catch ( H5::GroupIException error ) {
1814  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1815  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1816  msg = "H5 GROUP exception handler has detected an error when invoking the function "
1817  + QString::fromStdString(error.getFuncName()) + ".";
1818  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1819  }
1820  catch (H5::Exception error) { //??? how to improve printed msg using major/minor error codes?
1821  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1822  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1823  msg = "H5 GENERAL exception handler has detected an error when invoking the function "
1824  + QString::fromStdString(error.getFuncName()) + ".";
1825  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1826  }
1827  }
1828  catch (IException &e) {
1829  throw IException(e,
1831  "Unable to save bundle settings information to an HDF5 group.",
1832  _FILEINFO_);
1833  }
1834  }
1835 
1836 
1855  void BundleSettings::openH5Group(H5::CommonFG &locationObject, QString locationName) {
1856  try {
1857  // Try block to detect exceptions raised by any of the calls inside it
1858  try {
1859  /*
1860  * Turn off the auto-printing when failure occurs so that we can
1861  * handle the errors appropriately
1862  */
1863 // H5::Exception::dontPrint();
1864 
1865  // create a settings group to add to the given H5 object
1866  QString settingsGroupName = locationName + "/BundleSettings";
1867  H5::Group settingsGroup = locationObject.openGroup(settingsGroupName.toLatin1());
1868 
1869  Attribute att;
1870 
1871  /*
1872  * read bool attributes as predefined data type PredType::NATIVE_HBOOL
1873  */
1874  int boolAttValue = 0;
1875  att = settingsGroup.openAttribute("validateNetwork");
1876  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1877  m_validateNetwork = (bool)boolAttValue;
1878 
1879  att = settingsGroup.openAttribute("solveObservationMode");
1880  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1881  m_solveObservationMode = (bool)boolAttValue;
1882 
1883  att = settingsGroup.openAttribute("solveRadius");
1884  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1885  m_solveRadius = (bool)boolAttValue;
1886 
1887  att = settingsGroup.openAttribute("updateCubeLabel");
1888  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1889  m_updateCubeLabel = (bool)boolAttValue;
1890 
1891  att = settingsGroup.openAttribute("errorPropagation");
1892  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1893  m_errorPropagation = (bool)boolAttValue;
1894 
1895  att = settingsGroup.openAttribute("createInverseMatrix");
1896  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1897  m_createInverseMatrix = (bool)boolAttValue;
1898 
1899  att = settingsGroup.openAttribute("outlierRejection");
1900  att.read(PredType::NATIVE_HBOOL, &boolAttValue);
1901  m_outlierRejection = (bool)boolAttValue;
1902 
1903  /*
1904  * read enum attributes as predefined data type PredType::C_S1 (string)
1905  */
1906  H5std_string strAttValue;
1907  H5::StrType strDataType;
1908 
1909  att = settingsGroup.openAttribute("convergenceCriteria");
1910  strDataType = H5::StrType(PredType::C_S1, att.getStorageSize());
1911  att.read(strDataType, strAttValue);
1912  m_convergenceCriteria = stringToConvergenceCriteria(QString::fromStdString(strAttValue));
1913 
1914  /*
1915  * read string attributes as predefined data type PredType::C_S1 (string)
1916  */
1917  att = settingsGroup.openAttribute("outputFilePrefix");
1918  strDataType = H5::StrType(PredType::C_S1, att.getStorageSize());
1919  att.read(strDataType, strAttValue);
1920  m_outputFilePrefix = QString::fromStdString(strAttValue);
1921 
1922  /*
1923  * read double attributes as predefined data type PredType::NATIVE_DOUBLE
1924  */
1925  att = settingsGroup.openAttribute("outlierRejectionMultiplier");
1926  att.read(PredType::NATIVE_DOUBLE, &m_outlierRejectionMultiplier);
1927 
1928  att = settingsGroup.openAttribute("globalLatitudeAprioriSigma");
1929  att.read(PredType::NATIVE_DOUBLE, &m_globalLatitudeAprioriSigma);
1930 
1931  att = settingsGroup.openAttribute("globalLongitudeAprioriSigma");
1932  att.read(PredType::NATIVE_DOUBLE, &m_globalLongitudeAprioriSigma);
1933 
1934  att = settingsGroup.openAttribute("globalRadiusAprioriSigma");
1935  att.read(PredType::NATIVE_DOUBLE, &m_globalRadiusAprioriSigma);
1936 
1937  att = settingsGroup.openAttribute("convergenceCriteriaThreshold");
1938  att.read(PredType::NATIVE_DOUBLE, &m_convergenceCriteriaThreshold);
1939 
1940  /*
1941  * read int attributes as predefined data type PredType::NATIVE_INT
1942  */
1943  att = settingsGroup.openAttribute("convergenceCriteriaMaximumIterations");
1944  att.read(PredType::NATIVE_INT, &m_convergenceCriteriaMaximumIterations);
1945 
1946  // Data sets??? tables???
1947  // ??? QList<BundleObservationSolveSettings> m_observationSolveSettings; // TODO: pointer???
1948  // ??? QList< QPair< MaximumLikelihoodWFunctions::Model, double > > m_maximumLikelihood;
1949  // // TODO: pointer???
1950  }
1951  // catch failure caused by the Attribute operations
1952  catch ( H5::AttributeIException error ) {
1953  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1954  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1955  msg = "H5 ATTRIBUTE exception handler has detected an error when invoking the function "
1956  + QString::fromStdString(error.getFuncName()) + ".";
1957  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1958  }
1959  // catch failure caused by the DataSet operations
1960  catch ( H5::DataSetIException error ) {
1961  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1962  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1963  msg = "H5 DATA SET exception handler has detected an error when invoking the function "
1964  + QString::fromStdString(error.getFuncName()) + ".";
1965  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1966  }
1967  // catch failure caused by the DataSpace operations
1968  catch ( H5::DataSpaceIException error ) {
1969  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1970  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1971  msg = "H5 DATA SPACE exception handler has detected an error when invoking the function "
1972  + QString::fromStdString(error.getFuncName()) + ".";
1973  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1974  }
1975  // catch failure caused by the DataType operations
1976  catch ( H5::DataTypeIException error ) {
1977  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1978  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1979  msg = "H5 DATA TYPE exception handler has detected an error when invoking the function "
1980  + QString::fromStdString(error.getFuncName()) + ".";
1981  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1982  }
1983  // catch failure caused by the H5File operations
1984  catch ( H5::FileIException error ) {
1985  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1986  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1987  msg = "H5 FILE exception handler has detected an error when invoking the function "
1988  + QString::fromStdString(error.getFuncName()) + ".";
1989  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1990  }
1991  // catch failure caused by the Group operations
1992  catch ( H5::GroupIException error ) {
1993  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
1994  IException hpfError(IException::Unknown, msg, _FILEINFO_);
1995  msg = "H5 GROUP exception handler has detected an error when invoking the function "
1996  + QString::fromStdString(error.getFuncName()) + ".";
1997  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
1998  }
1999  catch (H5::Exception error) { //??? how to improve printed msg using major/minor error codes?
2000  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2001  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2002  msg = "H5 GENERAL exception handler has detected an error when invoking the function "
2003  + QString::fromStdString(error.getFuncName()) + ".";
2004  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2005  }
2006  }
2007  catch (IException &e) {
2008  throw IException(e,
2010  "Unable to read bundle settings information from an HDF5 group.",
2011  _FILEINFO_);
2012  }
2013  }
2014 }
BundleTargetBodyQsp bundleTargetBody() const
Retrieves a pointer to target body information for the bundle adjustment.
double m_globalLongitudeAprioriSigma
The global a priori sigma for longitude.
bool m_createInverseMatrix
Indicates whether to create the inverse matrix file.
BundleTargetBodyQsp m_bundleTargetBody
A pointer to the target body settings and information.
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:109
ConvergenceCriteria convergenceCriteria() const
Retrieves the convergence criteria to be used to solve the bundle adjustment.
The value of sigma0 will be used to determine that the bundle adjustment has converged.
The main project for cnetsuite.
Definition: Project.h:105
bool solveMeanRadius() const
This method is used to determine whether the bundle adjustment will solve for target body mean radius...
void openH5Group(H5::CommonFG &locationObject, QString locationName)
HDF5 - TBD.
void setObservationSolveOptions(QList< BundleObservationSolveSettings > obsSolveSettingsList)
Add the list of solve options for each observation.
File name manipulation and expansion.
Definition: FileName.h:111
bool m_solveObservationMode
Indicates whether to solve for observation mode.
void setSolveOptions(bool solveObservationMode=false, bool updateCubeLabel=false, bool errorPropagation=false, bool solveRadius=false, double globalLatitudeAprioriSigma=Isis::Null, double globalLongitudeAprioriSigma=Isis::Null, double globalRadiusAprioriSigma=Isis::Null)
Set the solve options for the bundle adjustment.
int numberTargetBodyParameters() const
This method is used to determine whether the bundle adjustment will solve for target body pole positi...
static QString convergenceCriteriaToString(ConvergenceCriteria criteria)
Converts the given BundleSettings::ConvergenceCriteria enumeration to a string.
bool solveTargetBody() const
This method is used to determine whether the bundle adjustment will solve for target body...
void setOutputFilePrefix(QString outputFilePrefix)
Set the output file prefix for the bundle adjustment.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > maximumLikelihoodEstimatorModels() const
Retrieves the list of maximum likelihood estimator (MLE) models with their corresponding C-Quantiles...
ConvergenceCriteria m_convergenceCriteria
Enumeration used to indicate what criteria to use to determine bundle adjustment convergence.
void setConvergenceCriteria(ConvergenceCriteria criteria, double threshold, int maximumIterations)
Set the convergence criteria options for the bundle adjustment.
QSharedPointer< BundleTargetBody > BundleTargetBodyQsp
Definition for BundleTargetBodyQsp, a QSharedPointer to a BundleTargetBody.
double m_outlierRejectionMultiplier
The multiplier value for outlier rejection.
bool solvePMVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double globalLongitudeAprioriSigma() const
Retrieves the global a priori sigma longitude value for this bundle adjustment.
virtual bool characters(const QString &ch)
XML - TBD.
int numberSolveSettings() const
Retrieves the number of observation solve settings.
QString m_outputFilePrefix
The prefix for all output files.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
Model
The supported maximum likelihood estimation models.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:163
bool m_validateNetwork
Indicates whether the network should be validated.
bool solvePoleRA() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
bool fatalError(const QXmlParseException &exception)
XML - TBD.
void setCreateInverseMatrix(bool createMatrix)
Turn the creation of the inverse correlation matrix file on or off.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
XML - TBD.
A modification to Huber&#39;s method propsed by William J.J.
bool updateCubeLabel() const
This method is used to determine whether this bundle adjustment will update the cube labels...
~BundleSettings()
Destroys the BundleSettings object.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
BundleObservationSolveSettings observationSolveSettings(QString instrumentId) const
Retrieves solve settings for the observation corresponding to the given observation number...
double globalRadiusAprioriSigma() const
Retrieves the global a priori sigma radius value for this bundle adjustment.
QDataStream & read(QDataStream &stream)
Reads BundleSettings object from a binary data stream.
XmlHandler(BundleSettings *bundleSettings, Project *project)
Create an XML Handler (reader) that can populate the BundleSettings class data.
double outlierRejectionMultiplier() const
Retrieves the outlier rejection multiplier for the bundle adjustment.
void setBundleTargetBody(BundleTargetBodyQsp bundleTargetBody)
Sets the target body for the bundle adjustment.
void addMaximumLikelihoodEstimatorModel(MaximumLikelihoodWFunctions::Model model, double cQuantile)
Add a maximum likelihood estimator (MLE) model to the bundle adjustment.
bool m_updateCubeLabel
Indicates whether to update cubes.
bool solvePoleDecVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
BundleSettings()
Constructs a BundleSettings object.
int convergenceCriteriaMaximumIterations() const
Retrieves the maximum number of iterations allowed to solve the bundle adjustment.
QList< QPair< MaximumLikelihoodWFunctions::Model, double > > m_maximumLikelihood
Model and C-Quantile for each of the three maximum likelihood estimations.
All parameter corrections will be used to determine that the bundle adjustment has converged...
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
PvlObject pvlObject(QString name="") const
Serializes this BundleObservationSolveSettings into a PvlObject.
A single keyword-value pair.
Definition: PvlKeyword.h:98
Container class for BundleAdjustment settings.
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:126
QString outputFilePrefix() const
Retrieve the output file prefix.
void setValidateNetwork(bool validate)
Sets the internal flag to indicate whether to validate the network before the bundle adjustment...
bool solvePMAcceleration() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
BundleSettings & operator=(const BundleSettings &other)
Assignment operator to allow proper copying of the &#39;other&#39; BundleSettings object to this one...
This class is needed to read/write BundleSettings from/to an XML formateed file.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:199
double m_convergenceCriteriaThreshold
Tolerance value corresponding to the selected convergence criteria.
QDataStream & write(QDataStream &stream) const
Writes BundleSettings object to a binary data stream.
void save(QXmlStreamWriter &stream, const Project *project) const
This method is used to write a BundleSettings object to an XML format.
bool solvePoleDec() const
This method is used to determine whether the bundle adjustment will solve for target body pole declin...
bool outlierRejection() const
This method is used to determine whether outlier rejection will be performed on this bundle adjustmen...
bool solvePM() const
This method is used to determine whether the bundle adjustment will solve for target body prime merid...
This class is used to modify and manage solve settings for 1 to many BundleObservations.
bool solveObservationMode() const
This method is used to determine whether this bundle adjustment will solve for observation mode...
bool validate(const NaifVertex &v)
Verifies that the given NaifVector or NaifVertex is 3 dimensional.
Definition: NaifDskApi.cpp:54
double m_globalLatitudeAprioriSigma
The global a priori sigma for latitude.
double convergenceCriteriaThreshold() const
Retrieves the convergence threshold to be used to solve the bundle adjustment.
static ConvergenceCriteria stringToConvergenceCriteria(QString criteria)
Converts the given string value to a BundleSettings::ConvergenceCriteria enumeration.
bool m_outlierRejection
Indicates whether to perform automatic outlier detection/rejection.
~XmlHandler()
Create an XML Handler (reader) that can populate the BundleSettings class data.
bool m_solveRadius
Indicates whether to solve for point radii.
int m_convergenceCriteriaMaximumIterations
Maximum number of iterations before quitting the bundle adjustment if it has not yet converged to the...
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition: IString.cpp:53
Isis exception class.
Definition: IException.h:99
double m_globalRadiusAprioriSigma
The global a priori sigma for radius.
bool solveRadius() const
This method is used to determine whether this bundle adjustment will solve for radius.
bool m_solveTargetBody
Indicates whether to solve for target body.
bool solvePoleRAVelocity() const
This method is used to determine whether the bundle adjustment will solve for target body pole right ...
static QString modelToString(Model model)
Static method to return a string represtentation for a given MaximumLikelihoodWFunctions::Model enum...
PvlObject pvlObject(QString name="BundleSettings") const
Create PvlObject with the given name containing the BundleSettings information.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
void setOutlierRejection(bool outlierRejection, double multiplier=1.0)
Set the outlier rejection options for the bundle adjustment.
bool m_errorPropagation
Indicates whether to perform error propagation.
his enables stack-based XML parsing of XML files.
bool validateNetwork() const
This method is used to determine whether to validate the network before the bundle adjustment...
bool createInverseMatrix() const
Indicates if the settings will allow the inverse correlation matrix to be created.
double globalLatitudeAprioriSigma() const
Retrieves the global a priori sigma latitude value for this bundle adjustment.
QUuid * m_id
A unique ID for this BundleSettings object.
bool solveTriaxialRadii() const
This method is used to determine whether the bundle adjustment will solve for target body triaxial ra...
ConvergenceCriteria
This enum defines the options for the bundle adjustment&#39;s convergence.
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:268
bool errorPropagation() const
This method is used to determine whether this bundle adjustment will perform error propagation...

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:15:13