Isis 3.0 Programmer Reference
Back | Home
BundleResults.cpp
1 #include "BundleResults.h"
2 
3 #include <QDataStream>
4 #include <QDebug>
5 #include <QString>
6 #include <QtGlobal> // qMax()
7 #include <QUuid>
8 #include <QXmlStreamWriter>
9 
10 #include <boost/lexical_cast.hpp>
11 #include <boost/numeric/ublas/io.hpp>
12 #include <boost/numeric/ublas/matrix_sparse.hpp>
13 #include <boost/numeric/ublas/vector_proxy.hpp>
14 
15 #include <H5Cpp.h>
16 #include <hdf5_hl.h>
17 #include <hdf5.h>
18 
19 #include "Camera.h"
20 #include "ControlMeasure.h"
21 #include "ControlPoint.h"
22 #include "CorrelationMatrix.h"
23 #include "Distance.h"
24 #include "FileName.h"
25 #include "IString.h"
27 #include "Project.h"
28 #include "PvlKeyword.h"
29 #include "PvlObject.h"
30 #include "SerialNumberList.h"
31 #include "StatCumProbDistDynCalc.h"
32 #include "Statistics.h"
33 #include "XmlStackedHandlerReader.h"
34 
35 using namespace boost::numeric::ublas;
36 
37 namespace Isis {
38 
44  BundleResults::BundleResults(QObject *parent) : QObject(parent) {
45 
46  initialize();
47 
48  m_id = new QUuid(QUuid::createUuid());
52 
53  // residual prob distribution is calculated even if there is no maximum likelihood estimation.
54  // so set up the solver to have a node at every percent of the distribution
56 
57  }
58 
59 
69  QObject *parent) : QObject(parent) {
70  // TODO: does xml stuff need project???
71 
72  initialize();
73 
74  xmlReader->pushContentHandler(new XmlHandler(this, project));
75  xmlReader->setErrorHandler(new XmlHandler(this, project));
76 
77  }
78 
79 
88  BundleResults::BundleResults(H5::CommonFG &locationObject, QString locationName) {
89  openH5Group(locationObject, locationName);
90  }
91 
92 
100  : m_id(new QUuid(src.m_id->toString())),
101  m_correlationMatrix(new CorrelationMatrix(*src.m_correlationMatrix)),
102  m_numberFixedPoints(src.m_numberFixedPoints),
103  m_numberIgnoredPoints(src.m_numberIgnoredPoints),
104  m_numberHeldImages(src.m_numberHeldImages),
105  m_rmsXResiduals(src.m_rmsXResiduals),
106  m_rmsYResiduals(src.m_rmsYResiduals),
107  m_rmsXYResiduals(src.m_rmsXYResiduals),
108  m_rejectionLimit(src.m_rejectionLimit),
109  m_numberObservations(src.m_numberObservations),
110  m_numberRejectedObservations(src.m_numberRejectedObservations),
111  m_numberUnknownParameters(src.m_numberUnknownParameters),
112  m_numberImageParameters(src.m_numberImageParameters),
113  m_numberConstrainedImageParameters(src.m_numberConstrainedImageParameters),
114  m_numberConstrainedPointParameters(src.m_numberConstrainedPointParameters),
115  m_numberConstrainedTargetParameters(src.m_numberConstrainedTargetParameters),
116  m_degreesOfFreedom(src.m_degreesOfFreedom),
117  m_sigma0(src.m_sigma0),
118  m_elapsedTime(src.m_elapsedTime),
119  m_elapsedTimeErrorProp(src.m_elapsedTimeErrorProp),
120  m_radiansToMeters(src.m_radiansToMeters),
121  m_converged(src.m_converged),
122  m_bundleControlPoints(src.m_bundleControlPoints),
123  m_outNet(src.m_outNet),
124  m_iterations(src.m_iterations),
125  m_observations(src.m_observations),
126  m_rmsImageSampleResiduals(src.m_rmsImageSampleResiduals),
127  m_rmsImageLineResiduals(src.m_rmsImageLineResiduals),
128  m_rmsImageResiduals(src.m_rmsImageResiduals),
129  m_rmsImageXSigmas(src.m_rmsImageXSigmas),
130  m_rmsImageYSigmas(src.m_rmsImageYSigmas),
131  m_rmsImageZSigmas(src.m_rmsImageZSigmas),
132  m_rmsImageRASigmas(src.m_rmsImageRASigmas),
133  m_rmsImageDECSigmas(src.m_rmsImageDECSigmas),
134  m_rmsImageTWISTSigmas(src.m_rmsImageTWISTSigmas),
135  m_minSigmaLatitudeDistance(src.m_minSigmaLatitudeDistance),
136  m_maxSigmaLatitudeDistance(src.m_maxSigmaLatitudeDistance),
137  m_minSigmaLongitudeDistance(src.m_minSigmaLongitudeDistance),
138  m_maxSigmaLongitudeDistance(src.m_maxSigmaLongitudeDistance),
139  m_minSigmaRadiusDistance(src.m_minSigmaRadiusDistance),
140  m_maxSigmaRadiusDistance(src.m_maxSigmaRadiusDistance),
141  m_minSigmaLatitudePointId(src.m_minSigmaLatitudePointId),
142  m_maxSigmaLatitudePointId(src.m_maxSigmaLatitudePointId),
143  m_minSigmaLongitudePointId(src.m_minSigmaLongitudePointId),
144  m_maxSigmaLongitudePointId(src.m_maxSigmaLongitudePointId),
145  m_minSigmaRadiusPointId(src.m_minSigmaRadiusPointId),
146  m_maxSigmaRadiusPointId(src.m_maxSigmaRadiusPointId),
147  m_rmsSigmaLatitudeStats(src.m_rmsSigmaLatitudeStats),
148  m_rmsSigmaLongitudeStats(src.m_rmsSigmaLongitudeStats),
149  m_rmsSigmaRadiusStats(src.m_rmsSigmaRadiusStats),
150  m_maximumLikelihoodFunctions(src.m_maximumLikelihoodFunctions),
151  m_maximumLikelihoodIndex(src.m_maximumLikelihoodIndex),
152  m_cumPro(new StatCumProbDistDynCalc(*src.m_cumPro)),
153  m_cumProRes(new StatCumProbDistDynCalc(*src.m_cumProRes)),
154  m_maximumLikelihoodMedianR2Residuals(src.m_maximumLikelihoodMedianR2Residuals) {
155 
156  }
157 
158 
163 
164  delete m_id;
165  m_id = NULL;
166 
167  delete m_correlationMatrix;
168  m_correlationMatrix = NULL;
169 
170  delete m_cumPro;
171  m_cumPro = NULL;
172 
173  delete m_cumProRes;
174  m_cumProRes = NULL;
175 
176  }
177 
178 
186 
187  if (&src != this) {
188  delete m_id;
189  m_id = NULL;
190  m_id = new QUuid(src.m_id->toString());
191 
192  delete m_correlationMatrix;
193  m_correlationMatrix = NULL;
194  m_correlationMatrix = new CorrelationMatrix(*src.m_correlationMatrix);
195 
211  m_sigma0 = src.m_sigma0;
215  m_converged = src.m_converged;
217  m_outNet = src.m_outNet;
223  m_rmsImageXSigmas = src.m_rmsImageXSigmas;
246 
247  delete m_cumPro;
248  m_cumPro = NULL;
250 
251  delete m_cumProRes;
252  m_cumProRes = NULL;
254 
256  }
257  return *this;
258  }
259 
260 
267  m_id = NULL;
268  m_correlationMatrix = NULL;
269 
270  m_numberFixedPoints = 0; // set in BA constructor->init->fillPointIndexMap
271  m_numberIgnoredPoints = 0; // set in BA constructor->init->fillPointIndexMap
272 
273 
274  // set in BundleAdjust init()
275  m_numberHeldImages = 0;
276 
277  // members set while computing bundle stats
279  m_rmsImageLineResiduals.clear();
280  m_rmsImageResiduals.clear();
281  m_rmsImageXSigmas.clear();
282  m_rmsImageYSigmas.clear();
283  m_rmsImageZSigmas.clear();
284  m_rmsImageRASigmas.clear();
285  m_rmsImageDECSigmas.clear();
286  m_rmsImageTWISTSigmas.clear();
287 
288  // initialize lat/lon/rad boundaries
301 
304  m_rmsSigmaRadiusStats = 0.0;
305 
306 
307  // set by compute residuals
308  m_rmsXResiduals = 0.0;
309  m_rmsYResiduals = 0.0;
310  m_rmsXYResiduals = 0.0;
311 
312  // set by compute rejection limit
313  m_rejectionLimit = 0.0;
314 
315  // set by flag outliers
317 
318  // set by formNormalEquations_CHOLMOD, formNormalEquations_SPECIALK, or solve
321 
322 // ??? unused variable ??? m_numberHeldPoints = 0;
323 
324  // set by formNormalEquations_CHOLMOD, formNormalEquations_SPECIALK, or
325  // setParameterWeights (i.e. solve)
329 
330  // set by initialize, formNormalEquations_CHOLMOD, formNormalEquations_SPECIALK, or solve
332 
333  // solve and solve cholesky
334  m_degreesOfFreedom = -1;
335  m_iterations = 0;
336  m_sigma0 = 0.0;
337  m_elapsedTime = 0.0;
339  m_converged = false; // or initialze method
340 
341  m_cumPro = NULL;
345  m_cumProRes = NULL;
346 
347  m_radiansToMeters = 0;
348  m_observations.clear();
349  m_outNet.clear();
350 
351  }
352 
353 
360  m_rmsImageXSigmas.resize(numberImages);
361  m_rmsImageYSigmas.resize(numberImages);
362  m_rmsImageZSigmas.resize(numberImages);
363  m_rmsImageRASigmas.resize(numberImages);
364  m_rmsImageDECSigmas.resize(numberImages);
365  m_rmsImageTWISTSigmas.resize(numberImages);
366  }
367 
368 
369 #if 0
371  QVector<Statistics> rmsImageSampleResiduals,
372  QVector<Statistics> rmsImageResiduals) {
373  // QList??? jigsaw apptest gives - ASSERT failure in QList<T>::operator[]: "index out of range",
374  m_rmsImageLineResiduals = rmsImageLineResiduals.toList();
375  m_rmsImageSampleResiduals = rmsImageSampleResiduals.toList();
376  m_rmsImageResiduals = rmsImageResiduals.toList();
377  }
378 #endif
379 
380 
389  QList<Statistics> rmsImageSampleResiduals,
390  QList<Statistics> rmsImageResiduals) {
394  }
395 
396 
406  QString minLatPointId, QString maxLatPointId) {
407  m_minSigmaLatitudeDistance = minLatDist;
408  m_maxSigmaLatitudeDistance = maxLatDist;
409  m_minSigmaLatitudePointId = minLatPointId;
410  m_maxSigmaLatitudePointId = maxLatPointId;
411  }
412 
413 
423  QString minLonPointId, QString maxLonPointId) {
424  m_minSigmaLongitudeDistance = minLonDist;
425  m_maxSigmaLongitudeDistance = maxLonDist;
426  m_minSigmaLongitudePointId = minLonPointId;
427  m_maxSigmaLongitudePointId = maxLonPointId;
428  }
429 
430 
440  QString minRadPointId, QString maxRadPointId) {
441  m_minSigmaRadiusDistance = minRadDist;
442  m_maxSigmaRadiusDistance = maxRadDist;
443  m_minSigmaRadiusPointId = minRadPointId;
444  m_maxSigmaRadiusPointId = maxRadPointId;
445  }
446 
447 
456  void BundleResults::setRmsFromSigmaStatistics(double rmsFromSigmaLatStats,
457  double rmsFromSigmaLonStats,
458  double rmsFromSigmaRadStats) {
459  m_rmsSigmaLatitudeStats = rmsFromSigmaLatStats;
460  m_rmsSigmaLongitudeStats = rmsFromSigmaLonStats;
461  m_rmsSigmaRadiusStats = rmsFromSigmaRadStats;
462  }
463 
464 
474 
475 
476  // reinitialize variables if this setup has already been called
479 
480  // residual prob distribution is calculated even if there is no maximum likelihood estimation.
481  // set up the solver to have a node at every percent of the distribution
482  m_cumProRes = NULL;
485 
486  // if numberMaximumLikelihoodModels > 0, then MaximumLikeliHood Estimation is being used.
487  for (int i = 0; i < modelsWithQuantiles.size(); i++) {
488 
489  // if maximum likelihood is being used, the cum prob calculator is initialized.
490  if (i == 0) {
491  m_cumPro = NULL;
493  // set up the solver to have a node at every percent of the distribution
495  }
496 
497  // set up the w functions for the maximum likelihood estimation
499  qMakePair(MaximumLikelihoodWFunctions(modelsWithQuantiles[i].first),
500  modelsWithQuantiles[i].second));
501 
502  }
503 
504 
505  //maximum likelihood estimation tiered solutions requiring multiple convergeances are supported,
506  // this index keeps track of which tier the solution is in
508  }
509 
510 
515  printf("Maximum Likelihood Tier: %d\n", m_maximumLikelihoodIndex);
517  // if maximum likelihood estimation is being used
518  // at the end of every iteration
519  // reset the tweaking contant to the desired quantile of the |residual| distribution
520  double quantile = m_maximumLikelihoodFunctions[m_maximumLikelihoodIndex].second;
521  double tc = m_cumPro->value(quantile);
522  m_maximumLikelihoodFunctions[m_maximumLikelihoodIndex].first.setTweakingConstant(tc);
523  // print meadians of residuals
525  printf("Median of R^2 residuals: %lf\n", m_maximumLikelihoodMedianR2Residuals);
526 
527  //restart the dynamic calculation of the cumulative probility distribution of |R^2 residuals|
528  // so it will be up to date for the next iteration
530  }
531  }
532 
533 
540  m_cumPro->setQuantiles(nodes);
541  }
542 
543 
550  m_cumProRes->setQuantiles(nodes);
551  }
552 
553 
561  m_cumPro->addObs(observationValue);
562  }
563 
564 
572  m_cumProRes->addObs(observationValue);
573  }
574 
575 
582  }
583 
584 
590  }
591 
592 
599  return m_numberFixedPoints;
600  }
601 
602 
608  }
609 
610 
617  return m_numberHeldImages;
618  }
619 
620 
626  }
627 
628 
635  return m_numberIgnoredPoints;
636  }
637 
638 
646  void BundleResults::setRmsXYResiduals(double rx, double ry, double rxy) {
647  m_rmsXResiduals = rx;
648  m_rmsYResiduals = ry;
649  m_rmsXYResiduals = rxy;
650  }
651 
652 
658  void BundleResults::setRejectionLimit(double rejectionLimit) {
660  }
661 
662 
668  void BundleResults::setNumberRejectedObservations(int numberRejectedObservations) {
670  }
671 
672 
678  void BundleResults::setNumberObservations(int numberObservations) {
680  }
681 
682 
688  void BundleResults::setNumberImageParameters(int numberParameters) {
689  m_numberImageParameters = numberParameters;
690  }
691 
692 
698  }
699 
700 
707  m_numberConstrainedPointParameters += incrementAmount;
708  }
709 
710 
716  }
717 
718 
725  m_numberConstrainedImageParameters += incrementAmount;
726  }
727 
728 
734  }
735 
736 
743  m_numberConstrainedTargetParameters += incrementAmount;
744  }
745 
746 
752  void BundleResults::setNumberUnknownParameters(int numberParameters) {
753  m_numberUnknownParameters = numberParameters;
754  }
755 
756 
766  }
767 
768 
782 
783  if (m_degreesOfFreedom > 0) {
784  m_sigma0 = dvtpv / m_degreesOfFreedom;
785  }
786  else if (m_degreesOfFreedom == 0 && criteria == BundleSettings::ParameterCorrections) {
787  m_sigma0 = dvtpv;
788  }
789  else {
790  QString msg = "Computed degrees of freedom [" + toString(m_degreesOfFreedom)
791  + "] is invalid.";
792  throw IException(IException::Io, msg, _FILEINFO_);
793  }
794 
795  m_sigma0 = sqrt(m_sigma0);
796  }
797 
798 
804  void BundleResults::setDegreesOfFreedom(double degreesOfFreedom) { // old sparse
806  }
807 
808 
814  void BundleResults::setSigma0(double sigma0) { // old sparse
815  m_sigma0 = sigma0;
816  }
817 
818 
824  void BundleResults::setElapsedTime(double time) {
825  m_elapsedTime = time;
826  }
827 
828 
835  m_elapsedTimeErrorProp = time;
836  }
837 
838 
845  m_radiansToMeters = rtm;
846  }
847 
848 
854  void BundleResults::setConverged(bool converged) {
855  m_converged = converged;
856  }
857 
858 
865  m_bundleControlPoints = controlPoints;
866  }
867 
868 
875  m_outNet = outNet;
876  }
877 
878 
884  void BundleResults::setIterations(int iterations) {
886  }
887 
888 
896  }
897 
898 
899 
900  //************************* Accessors **********************************************************//
901 
909  }
910 
911 
919  }
920 
921 
928  return m_rmsImageResiduals;
929  }
930 
931 
938  return m_rmsImageXSigmas;
939  }
940 
941 
948  return m_rmsImageYSigmas;
949  }
950 
951 
958  return m_rmsImageZSigmas;
959  }
960 
961 
968  return m_rmsImageRASigmas;
969  }
970 
971 
978  return m_rmsImageDECSigmas;
979  }
980 
981 
988  return m_rmsImageTWISTSigmas;
989  }
990 
991 
999  }
1000 
1001 
1009  }
1010 
1011 
1019  }
1020 
1021 
1029  }
1030 
1031 
1038  return m_minSigmaRadiusDistance;
1039  }
1040 
1041 
1048  return m_maxSigmaRadiusDistance;
1049  }
1050 
1051 
1059  }
1060 
1061 
1069  }
1070 
1071 
1079  }
1080 
1081 
1089  }
1090 
1091 
1098  return m_minSigmaRadiusPointId;
1099  }
1100 
1101 
1108  return m_maxSigmaRadiusPointId;
1109  }
1110 
1111 
1118  return m_rmsSigmaLatitudeStats;
1119  }
1120 
1121 
1128  return m_rmsSigmaLongitudeStats;
1129  }
1130 
1131 
1138  return m_rmsSigmaRadiusStats;
1139  }
1140 
1141 
1147  double BundleResults::rmsRx() const {
1148  return m_rmsXResiduals;
1149  }
1150 
1151 
1157  double BundleResults::rmsRy() const {
1158  return m_rmsYResiduals;
1159  }
1160 
1161 
1167  double BundleResults::rmsRxy() const {
1168  return m_rmsXYResiduals;
1169  }
1170 
1171 
1178  return m_rejectionLimit;
1179  }
1180 
1181 
1188  return m_radiansToMeters;
1189  }
1190 
1191 
1199  }
1200 
1201 
1208  return m_numberObservations;
1209  }
1210 
1211 
1218  return m_numberImageParameters;
1219  }
1220 
1221 
1229  }
1230 
1231 
1239  }
1240 
1241 
1249  }
1250 
1251 
1259  }
1260 
1261 
1268  return m_degreesOfFreedom;
1269  }
1270 
1271 
1277  double BundleResults::sigma0() const {
1278  return m_sigma0;
1279  }
1280 
1281 
1288  return m_elapsedTime;
1289  }
1290 
1291 
1298  return m_elapsedTimeErrorProp;
1299  }
1300 
1301 
1308  return m_converged;
1309  }
1310 
1311 
1318  return m_bundleControlPoints;
1319  }
1320 
1321 
1330  if (!m_outNet) {
1332  "Output Control Network has not been set.",
1333  _FILEINFO_);
1334  }
1335  return m_outNet;
1336  }
1337 
1338 
1345  return m_iterations;
1346  }
1347 
1348 
1355  return m_observations;
1356  }
1357 
1358 
1365  return m_maximumLikelihoodFunctions.size();
1366  }
1367 
1368 
1375  return m_maximumLikelihoodIndex;
1376  }
1377 
1378 
1386  return *m_cumPro;
1387  }
1388 
1389 
1396  return *m_cumProRes;
1397  }
1398 
1399 
1407  }
1408 
1409 
1418  return m_maximumLikelihoodFunctions[modelIndex].first;
1419  }
1420 
1421 
1429  double BundleResults::maximumLikelihoodModelQuantile(int modelIndex) const {
1430  return m_maximumLikelihoodFunctions[modelIndex].second;
1431  }
1432 
1433 
1434 // QList< QPair< MaximumLikelihoodWFunctions, double > >
1435 // BundleResults::maximumLikelihoodModels() const {
1436 // return m_maximumLikelihoodFunctions;
1437 // }
1438 
1439 
1447  PvlObject BundleResults::pvlObject(QString name) const {
1448 
1449  PvlObject pvl(name);
1450 
1451  pvl += PvlKeyword("NumberFixedPoints", toString(numberFixedPoints()));
1452  pvl += PvlKeyword("NumberIgnoredPoints", toString(numberIgnoredPoints()));
1453  pvl += PvlKeyword("NumberHeldImages", toString(numberHeldImages()));
1454  pvl += PvlKeyword("RMSResidualX", toString(rmsRx()));
1455  pvl += PvlKeyword("RMSResidualY", toString(rmsRy()));
1456  pvl += PvlKeyword("RMSResidualXY", toString(rmsRxy()));
1457  pvl += PvlKeyword("RejectionLimit", toString(rejectionLimit()));
1458  pvl += PvlKeyword("RadiansToMeters", toString(radiansToMeters()));
1459  pvl += PvlKeyword("NumberRejectedObservations", toString(numberRejectedObservations()));
1460  pvl += PvlKeyword("NumberObservations", toString(numberObservations()));
1461  pvl += PvlKeyword("NumberImageParameters", toString(numberImageParameters()));
1462  pvl += PvlKeyword("NumberConstrainedPointParameters",
1464  pvl += PvlKeyword("NumberConstrainedImageParameters",
1466  pvl += PvlKeyword("NumberConstrainedTargetParameters",
1468  pvl += PvlKeyword("NumberUnknownParameters", toString(numberUnknownParameters()));
1469  pvl += PvlKeyword("DegreesOfFreedom", toString(degreesOfFreedom()));
1470  pvl += PvlKeyword("Sigma0", toString(sigma0()));
1471  pvl += PvlKeyword("ElapsedTime", toString(elapsedTime()));
1472  pvl += PvlKeyword("ElapsedTimeErrorProp", toString(elapsedTimeErrorProp()));
1473  pvl += PvlKeyword("Iterations", toString(iterations()));
1474  pvl += PvlKeyword("Converged", toString(converged()));
1475 #if 0
1476  // loop through these ??? what value to store???
1477  pvl += PvlKeyword("RmsImageSampleResidualsSize", toString(m_rmsImageSampleResiduals.size());
1478  pvl += PvlKeyword("RmsImageLineResidualsSize", toString(m_rmsImageLineResiduals.size());
1479  pvl += PvlKeyword("RmsImageResidualsSize", toString(m_rmsImageResiduals.size());
1480  pvl += PvlKeyword("RmsImageXSigmasSize", toString(m_rmsImageXSigmas.size());
1481  pvl += PvlKeyword("RmsImageYSigmasSize", toString(m_rmsImageYSigmas.size());
1482  pvl += PvlKeyword("RmsImageZSigmasSize", toString(m_rmsImageZSigmas.size());
1483  pvl += PvlKeyword("RmsImageRASigmasSize", toString(m_rmsImageRASigmas.size());
1484  pvl += PvlKeyword("RmsImageDECSigmasSize", toString(m_rmsImageDECSigmas.size());
1485  pvl += PvlKeyword("RmsImageTWISTSigmasSize", toString(m_rmsImageTWISTSigmas.size());
1486 #endif
1487  pvl += PvlKeyword("MinSigmaLatitude", toString(minSigmaLatitudeDistance().meters()));
1488  pvl += PvlKeyword("MinSigmaLatitudePointId", minSigmaLatitudePointId());
1489  pvl += PvlKeyword("MaxSigmaLatitude", toString(maxSigmaLatitudeDistance().meters()));
1490  pvl += PvlKeyword("MaxSigmaLatitudePointId", maxSigmaLatitudePointId());
1491  pvl += PvlKeyword("MinSigmaLongitude", toString(minSigmaLongitudeDistance().meters()));
1492  pvl += PvlKeyword("MinSigmaLongitudePointId", minSigmaLongitudePointId());
1493  pvl += PvlKeyword("MaxSigmaLongitude", toString(maxSigmaLongitudeDistance().meters()));
1494  pvl += PvlKeyword("MaxSigmaLongitudePointId", maxSigmaLongitudePointId());
1495  pvl += PvlKeyword("MinSigmaRadius", toString(minSigmaRadiusDistance().meters()));
1496  pvl += PvlKeyword("MinSigmaRadiusPointId", minSigmaRadiusPointId());
1497  pvl += PvlKeyword("MaxSigmaRadius", toString(maxSigmaRadiusDistance().meters()));
1498  pvl += PvlKeyword("MaxSigmaRadiusPointId", maxSigmaRadiusPointId());
1499  pvl += PvlKeyword("RmsSigmaLat", toString(sigmaLatitudeStatisticsRms()));
1500  pvl += PvlKeyword("RmsSigmaLon", toString(sigmaLongitudeStatisticsRms()));
1501  pvl += PvlKeyword("RmsSigmaRad", toString(sigmaRadiusStatisticsRms()));
1502  pvl += PvlKeyword("NumberMaximumLikelihoodModels", toString(numberMaximumLikelihoodModels()));
1503  if (numberMaximumLikelihoodModels() > 0) {
1504 
1505  PvlKeyword models("MaximumLikelihoodModels");
1506  PvlKeyword quantiles("MaximumLikelihoodQuantiles");
1507 
1508  for (int i = 0; i < m_maximumLikelihoodFunctions.size(); i++) {
1510  m_maximumLikelihoodFunctions[i].first.model()));
1511  quantiles.addValue(toString(m_maximumLikelihoodFunctions[i].second));
1512  }
1513  pvl += models;
1514  pvl += quantiles;
1515  pvl += PvlKeyword("MaximumLikelihoodMedianR2Residuals",
1517  }
1518 
1519  if (m_correlationMatrix) {
1520  pvl += correlationMatrix().pvlObject();
1521  }
1522  else {
1523  pvl += PvlKeyword("CorrelationMatrix", "None");
1524  }
1525 
1526  return pvl;
1527  }
1528 
1529 
1538  if (m_correlationMatrix) {
1539  return *m_correlationMatrix;
1540  }
1541  else {
1543  "Correlation matrix for this bundle is NULL.",
1544  _FILEINFO_);
1545  }
1546  }
1547 
1548 
1555  correlationMatrix();// throw error if null
1557  }
1558 
1559 
1566  correlationMatrix();// throw error if null
1568  }
1569 
1570 
1577  void BundleResults::save(QXmlStreamWriter &stream, const Project *project) const {
1578  // TODO: does xml stuff need project???
1579 
1580  stream.writeStartElement("bundleResults");
1581  stream.writeTextElement("id", m_id->toString());
1582 
1583 // stream.writeTextElement("instrumentId", m_instrumentId);
1584 
1585  stream.writeStartElement("correlationMatrix");
1586  stream.writeAttribute("correlationFileName",
1587  correlationMatrix().correlationFileName().expanded());
1588  stream.writeAttribute("covarianceFileName",
1589  correlationMatrix().covarianceFileName().expanded());
1590  stream.writeStartElement("imagesAndParameters");
1591  QMapIterator<QString, QStringList> imgParamIt(*correlationMatrix().imagesAndParameters());
1592  while (imgParamIt.hasNext()) {
1593  imgParamIt.next();
1594  stream.writeStartElement("image");
1595  stream.writeAttribute("id", imgParamIt.key());
1596  QStringList parameters = imgParamIt.value();
1597  for (int i = 0; i < parameters.size(); i++) {
1598  stream.writeTextElement("parameter", parameters[i]);
1599  }
1600  stream.writeEndElement(); // end image
1601 
1602  }
1603  stream.writeEndElement(); // end images and parameters
1604  stream.writeEndElement(); // end correlationMatrix
1605 
1606  stream.writeStartElement("generalStatisticsValues");
1607  stream.writeTextElement("numberFixedPoints", toString(numberFixedPoints()));
1608  stream.writeTextElement("numberIgnoredPoints", toString(numberIgnoredPoints()));
1609  stream.writeTextElement("numberHeldImages", toString(numberHeldImages()));
1610  stream.writeTextElement("rejectionLimit", toString(rejectionLimit()));
1611  stream.writeTextElement("numberRejectedObservations", toString(numberRejectedObservations()));
1612  stream.writeTextElement("numberObservations", toString(numberObservations()));
1613  stream.writeTextElement("numberImageParameters", toString(numberImageParameters()));
1614  stream.writeTextElement("numberConstrainedPointParameters",
1616  stream.writeTextElement("numberConstrainedImageParameters",
1618  stream.writeTextElement("numberConstrainedTargetParameters",
1620  stream.writeTextElement("numberUnknownParameters", toString(numberUnknownParameters()));
1621  stream.writeTextElement("degreesOfFreedom", toString(degreesOfFreedom()));
1622  stream.writeTextElement("sigma0", toString(sigma0()));
1623  stream.writeTextElement("converged", toString(converged()));
1624  stream.writeEndElement(); // end generalStatisticsValues
1625 
1626  stream.writeStartElement("rms");
1627  stream.writeStartElement("residuals");
1628  stream.writeAttribute("x", toString(rmsRx()));
1629  stream.writeAttribute("y", toString(rmsRy()));
1630  stream.writeAttribute("xy", toString(rmsRxy()));
1631  stream.writeEndElement(); // end residuals element
1632  stream.writeStartElement("sigmas");
1633  stream.writeAttribute("lat", toString(sigmaLatitudeStatisticsRms()));
1634  stream.writeAttribute("lon", toString(sigmaLongitudeStatisticsRms()));
1635  stream.writeAttribute("rad", toString(sigmaRadiusStatisticsRms()));
1636  stream.writeEndElement(); // end sigmas element
1637 
1638  stream.writeStartElement("imageResidualsLists");
1639  stream.writeStartElement("residualsList");
1640  stream.writeAttribute("listSize", toString(rmsImageResiduals().size()));
1641  for (int i = 0; i < m_rmsImageResiduals.size(); i++) {
1642  stream.writeStartElement("statisticsItem");
1643  m_rmsImageResiduals[i].save(stream, project);
1644  stream.writeEndElement(); // end statistics item
1645  }
1646  stream.writeEndElement(); // end residuals list
1647  stream.writeStartElement("sampleList");
1648  stream.writeAttribute("listSize", toString(rmsImageSampleResiduals().size()));
1649  for (int i = 0; i < m_rmsImageSampleResiduals.size(); i++) {
1650  stream.writeStartElement("statisticsItem");
1651  m_rmsImageSampleResiduals[i].save(stream, project);
1652  stream.writeEndElement(); // end statistics item
1653  }
1654  stream.writeEndElement(); // end sample residuals list
1655 
1656  stream.writeStartElement("lineList");
1657  stream.writeAttribute("listSize", toString(rmsImageLineResiduals().size()));
1658  for (int i = 0; i < m_rmsImageLineResiduals.size(); i++) {
1659  stream.writeStartElement("statisticsItem");
1660  m_rmsImageLineResiduals[i].save(stream, project);
1661  stream.writeEndElement(); // end statistics item
1662  }
1663  stream.writeEndElement(); // end line residuals list
1664  stream.writeEndElement(); // end image residuals lists
1665 
1666  stream.writeStartElement("imageSigmasLists");
1667  stream.writeStartElement("xSigmas");
1668  stream.writeAttribute("listSize", toString(rmsImageXSigmas().size()));
1669  for (int i = 0; i < m_rmsImageXSigmas.size(); i++) {
1670  stream.writeStartElement("statisticsItem");
1671  m_rmsImageXSigmas[i].save(stream, project);
1672  stream.writeEndElement(); // end statistics item
1673  }
1674 
1675  stream.writeEndElement(); // end x sigma list
1676 
1677  stream.writeStartElement("ySigmas");
1678  stream.writeAttribute("listSize", toString(rmsImageYSigmas().size()));
1679  for (int i = 0; i < m_rmsImageYSigmas.size(); i++) {
1680  stream.writeStartElement("statisticsItem");
1681  m_rmsImageYSigmas[i].save(stream, project);
1682  stream.writeEndElement(); // end statistics item
1683  }
1684  stream.writeEndElement(); // end y sigma list
1685 
1686  stream.writeStartElement("zSigmas");
1687  stream.writeAttribute("listSize", toString(rmsImageZSigmas().size()));
1688  for (int i = 0; i < m_rmsImageZSigmas.size(); i++) {
1689  stream.writeStartElement("statisticsItem");
1690  m_rmsImageZSigmas[i].save(stream, project);
1691  stream.writeEndElement(); // end statistics item
1692  }
1693  stream.writeEndElement(); // end z sigma list
1694 
1695  stream.writeStartElement("raSigmas");
1696  stream.writeAttribute("listSize", toString(rmsImageRASigmas().size()));
1697  for (int i = 0; i < m_rmsImageRASigmas.size(); i++) {
1698  stream.writeStartElement("statisticsItem");
1699  m_rmsImageRASigmas[i].save(stream, project);
1700  stream.writeEndElement(); // end statistics item
1701  }
1702  stream.writeEndElement(); // end ra sigma list
1703 
1704  stream.writeStartElement("decSigmas");
1705  stream.writeAttribute("listSize", toString(rmsImageDECSigmas().size()));
1706  for (int i = 0; i < m_rmsImageDECSigmas.size(); i++) {
1707  stream.writeStartElement("statisticsItem");
1708  m_rmsImageDECSigmas[i].save(stream, project);
1709  stream.writeEndElement(); // end statistics item
1710  }
1711  stream.writeEndElement(); // end dec sigma list
1712 
1713  stream.writeStartElement("twistSigmas");
1714  stream.writeAttribute("listSize", toString(rmsImageTWISTSigmas().size()));
1715  for (int i = 0; i < m_rmsImageTWISTSigmas.size(); i++) {
1716  stream.writeStartElement("statisticsItem");
1717  m_rmsImageTWISTSigmas[i].save(stream, project);
1718  stream.writeEndElement(); // end statistics item
1719  }
1720  stream.writeEndElement(); // end twist sigma list
1721  stream.writeEndElement(); // end sigmas lists
1722  stream.writeEndElement(); // end rms
1723 
1724  stream.writeStartElement("elapsedTime");
1725  stream.writeAttribute("time", toString(elapsedTime()));
1726  stream.writeAttribute("errorProp", toString(elapsedTimeErrorProp()));
1727  stream.writeEndElement(); // end elapsed time
1728 
1729  stream.writeStartElement("minMaxSigmas");
1730  stream.writeStartElement("minLat");
1731  stream.writeAttribute("value", toString(minSigmaLatitudeDistance().meters()));
1732  stream.writeAttribute("pointId", minSigmaLatitudePointId());
1733  stream.writeEndElement();
1734  stream.writeStartElement("maxLat");
1735  stream.writeAttribute("value", toString(maxSigmaLatitudeDistance().meters()));
1736  stream.writeAttribute("pointId", maxSigmaLatitudePointId());
1737  stream.writeEndElement();
1738  stream.writeStartElement("minLon");
1739  stream.writeAttribute("value", toString(minSigmaLongitudeDistance().meters()));
1740  stream.writeAttribute("pointId", minSigmaLongitudePointId());
1741  stream.writeEndElement();
1742  stream.writeStartElement("maxLon");
1743  stream.writeAttribute("value", toString(maxSigmaLongitudeDistance().meters()));
1744  stream.writeAttribute("pointId", maxSigmaLongitudePointId());
1745  stream.writeEndElement();
1746  stream.writeStartElement("minRad");
1747  stream.writeAttribute("value", toString(minSigmaRadiusDistance().meters()));
1748  stream.writeAttribute("pointId", minSigmaRadiusPointId());
1749  stream.writeEndElement();
1750  stream.writeStartElement("maxRad");
1751  stream.writeAttribute("value", toString(maxSigmaRadiusDistance().meters()));
1752  stream.writeAttribute("pointId", maxSigmaRadiusPointId());
1753  stream.writeEndElement();
1754  stream.writeEndElement(); // end minMaxSigmas
1755 
1756  // call max likelihood setup from startElement to fill the rest of these values...
1757  stream.writeStartElement("maximumLikelihoodEstimation");
1758  stream.writeAttribute("numberModels", toString(numberMaximumLikelihoodModels()));
1759  stream.writeAttribute("maximumLikelihoodIndex", toString(maximumLikelihoodModelIndex()));
1760  stream.writeAttribute("maximumLikelihoodMedianR2Residuals",
1762 
1763  stream.writeStartElement("cumulativeProbabilityCalculator");
1764  cumulativeProbabilityDistribution().save(stream, project);
1765  stream.writeEndElement(); // end cumulativeProbabilityCalculator
1766 
1767  stream.writeStartElement("residualsCumulativeProbabilityCalculator");
1768  residualsCumulativeProbabilityDistribution().save(stream, project);
1769  stream.writeEndElement(); // end residualsCumulativeProbabilityCalculator
1770 
1771  for (int i = 0; i < numberMaximumLikelihoodModels(); i++) {
1772  stream.writeStartElement("model");
1773  stream.writeAttribute("modelNumber", toString(i+1));
1774  stream.writeAttribute("modelSelection",
1776  stream.writeAttribute("tweakingConstant",
1777  toString(m_maximumLikelihoodFunctions[i].first.tweakingConstant()));
1778  stream.writeAttribute("quantile", toString(m_maximumLikelihoodFunctions[i].second));
1779  stream.writeEndElement(); // end this model
1780  }
1781  stream.writeEndElement(); // end maximumLikelihoodEstimation
1782  stream.writeEndElement(); // end bundleResults
1783  }
1784 
1785 
1793  // TODO: does xml stuff need project???
1794  m_xmlHandlerBundleResults = NULL;
1795  m_xmlHandlerProject = NULL;
1796 
1797  m_xmlHandlerBundleResults = statistics;
1798  m_xmlHandlerProject = project; // TODO: does xml stuff need project???
1799  m_xmlHandlerCharacters = "";
1800 
1801  m_xmlHandlerResidualsListSize = 0;
1802  m_xmlHandlerSampleResidualsListSize = 0;
1803  m_xmlHandlerLineResidualsListSize = 0;
1804  m_xmlHandlerXSigmasListSize = 0;
1805  m_xmlHandlerYSigmasListSize = 0;
1806  m_xmlHandlerZSigmasListSize = 0;
1807  m_xmlHandlerRASigmasListSize = 0;
1808  m_xmlHandlerDECSigmasListSize = 0;
1809  m_xmlHandlerTWISTSigmasListSize = 0;
1810  m_xmlHandlerStatisticsList.clear();
1811 
1812  }
1813 
1814 
1819  // do not delete this pointer... we don't own it, do we???
1820  // passed into StatCumProbDistDynCalc constructor as pointer
1821  // delete m_xmlHandlerProject; // TODO: does xml stuff need project???
1822  m_xmlHandlerProject = NULL;
1823 
1824  // delete m_xmlHandlerBundleResults;
1825  // m_xmlHandlerBundleResults = NULL;
1826 
1827  }
1828 
1829 
1840  bool BundleResults::XmlHandler::startElement(const QString &namespaceURI,
1841  const QString &localName,
1842  const QString &qName,
1843  const QXmlAttributes &atts) {
1844  m_xmlHandlerCharacters = "";
1845 
1846  if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
1847 
1848  if (qName == "correlationMatrix") {
1849 
1850  m_xmlHandlerBundleResults->m_correlationMatrix = NULL;
1851  m_xmlHandlerBundleResults->m_correlationMatrix = new CorrelationMatrix();
1852 
1853  QString correlationFileName = atts.value("correlationFileName");
1854  if (!correlationFileName.isEmpty()) {
1855  FileName correlationFile(correlationFileName);
1856  m_xmlHandlerBundleResults->m_correlationMatrix->setCorrelationFileName(correlationFile);
1857  }
1858 
1859  QString covarianceFileName = atts.value("covarianceFileName");
1860  if (!covarianceFileName.isEmpty()) {
1861  FileName covarianceFile(covarianceFileName);
1862  m_xmlHandlerBundleResults->m_correlationMatrix->setCovarianceFileName(covarianceFile);
1863  }
1864 
1865  }
1866  else if (qName == "image") {
1867  QString correlationMatrixImageId = atts.value("id");
1868  if (!correlationMatrixImageId.isEmpty()) {
1869  m_xmlHandlerCorrelationImageId = correlationMatrixImageId;
1870  }
1871  }
1872  else if (qName == "residuals") {
1873 
1874  QString rx = atts.value("x");
1875  if (!rx.isEmpty()) {
1876  m_xmlHandlerBundleResults->m_rmsXResiduals = toDouble(rx);
1877  }
1878 
1879  QString ry = atts.value("y");
1880  if (!ry.isEmpty()) {
1881  m_xmlHandlerBundleResults->m_rmsYResiduals = toDouble(ry);
1882  }
1883 
1884  QString rxy = atts.value("xy");
1885  if (!rxy.isEmpty()) {
1886  m_xmlHandlerBundleResults->m_rmsXYResiduals = toDouble(rxy);
1887  }
1888 
1889  }
1890  else if (qName == "sigmas") {
1891 
1892  QString lat = atts.value("lat");
1893  if (!lat.isEmpty()) {
1894  m_xmlHandlerBundleResults->m_rmsSigmaLatitudeStats = toDouble(lat);
1895  }
1896 
1897  QString lon = atts.value("lon");
1898  if (!lon.isEmpty()) {
1899  m_xmlHandlerBundleResults->m_rmsSigmaLongitudeStats = toDouble(lon);
1900  }
1901 
1902  QString rad = atts.value("rad");
1903  if (!rad.isEmpty()) {
1904  m_xmlHandlerBundleResults->m_rmsSigmaRadiusStats = toDouble(rad);
1905  }
1906 
1907  }
1908  else if (qName == "residualsList") {
1909 
1910  QString listSizeStr = atts.value("listSize");
1911  if (!listSizeStr.isEmpty()) {
1912  m_xmlHandlerResidualsListSize = toInt(listSizeStr);
1913  }
1914 
1915  }
1916  else if (qName == "sampleList") {
1917 
1918  QString listSizeStr = atts.value("listSize");
1919  if (!listSizeStr.isEmpty()) {
1920  m_xmlHandlerSampleResidualsListSize = toInt(listSizeStr);
1921  }
1922 
1923  }
1924  else if (qName == "lineList") {
1925 
1926  QString listSizeStr = atts.value("listSize");
1927  if (!listSizeStr.isEmpty()) {
1928  m_xmlHandlerLineResidualsListSize = toInt(listSizeStr);
1929  }
1930 
1931  }
1932  else if (qName == "xSigmas") {
1933 
1934  QString listSizeStr = atts.value("listSize");
1935  if (!listSizeStr.isEmpty()) {
1936  m_xmlHandlerXSigmasListSize = toInt(listSizeStr);
1937  }
1938 
1939  }
1940  else if (qName == "ySigmas") {
1941 
1942  QString listSizeStr = atts.value("listSize");
1943  if (!listSizeStr.isEmpty()) {
1944  m_xmlHandlerYSigmasListSize = toInt(listSizeStr);
1945  }
1946 
1947  }
1948  else if (qName == "zSigmas") {
1949 
1950  QString listSizeStr = atts.value("listSize");
1951  if (!listSizeStr.isEmpty()) {
1952  m_xmlHandlerZSigmasListSize = toInt(listSizeStr);
1953  }
1954 
1955  }
1956  else if (qName == "raSigmas") {
1957 
1958  QString listSizeStr = atts.value("listSize");
1959  if (!listSizeStr.isEmpty()) {
1960  m_xmlHandlerRASigmasListSize = toInt(listSizeStr);
1961  }
1962 
1963  }
1964  else if (qName == "decSigmas") {
1965 
1966  QString listSizeStr = atts.value("listSize");
1967  if (!listSizeStr.isEmpty()) {
1968  m_xmlHandlerDECSigmasListSize = toInt(listSizeStr);
1969  }
1970 
1971  }
1972  else if (qName == "twistSigmas") {
1973 
1974  QString listSizeStr = atts.value("listSize");
1975  if (!listSizeStr.isEmpty()) {
1976  m_xmlHandlerTWISTSigmasListSize = toInt(listSizeStr);
1977  }
1978 
1979  }
1980  else if (qName == "statisticsItem") {
1981  // add statistics object to the xml handler's current statistics list.
1982  m_xmlHandlerStatisticsList.append(
1983  new Statistics(m_xmlHandlerProject, reader()));
1984  }
1985  else if (qName == "elapsedTime") {
1986 
1987  QString time = atts.value("time");
1988  if (!time.isEmpty()) {
1989  m_xmlHandlerBundleResults->m_elapsedTime = toDouble(time);
1990  }
1991 
1992  QString errorProp = atts.value("errorProp");
1993  if (!errorProp.isEmpty()) {
1994  m_xmlHandlerBundleResults->m_elapsedTimeErrorProp = toDouble(errorProp);
1995  }
1996 
1997  }
1998 // ??? else if (qName == "minMaxSigmaDistances") {
1999 // ??? QString units = atts.value("units");
2000 // ??? if (!QString::compare(units, "meters", Qt::CaseInsensitive)) {
2001 // ??? QString msg = "Unable to read BundleResults xml. Sigma distances must be "
2002 // ??? "provided in meters.";
2003 // ??? throw IException(IException::Io, msg, _FILEINFO_);
2004 // ??? }
2005 // ??? }
2006  else if (qName == "minLat") {
2007 
2008  QString minLat = atts.value("value");
2009  if (!minLat.isEmpty()) {
2010  m_xmlHandlerBundleResults->m_minSigmaLatitudeDistance.setMeters(toDouble(minLat));
2011  }
2012 
2013  QString minLatPointId = atts.value("pointId");
2014  if (!minLatPointId.isEmpty()) {
2015  m_xmlHandlerBundleResults->m_minSigmaLatitudePointId = minLatPointId;
2016  }
2017 
2018  }
2019  else if (qName == "maxLat") {
2020 
2021  QString maxLat = atts.value("value");
2022  if (!maxLat.isEmpty()) {
2023  m_xmlHandlerBundleResults->m_maxSigmaLatitudeDistance.setMeters(toDouble(maxLat));
2024  }
2025 
2026  QString maxLatPointId = atts.value("pointId");
2027  if (!maxLatPointId.isEmpty()) {
2028  m_xmlHandlerBundleResults->m_maxSigmaLatitudePointId = maxLatPointId;
2029  }
2030 
2031  }
2032  else if (qName == "minLon") {
2033 
2034  QString minLon = atts.value("value");
2035  if (!minLon.isEmpty()) {
2036  m_xmlHandlerBundleResults->m_minSigmaLongitudeDistance.setMeters(toDouble(minLon));
2037  }
2038 
2039  QString minLonPointId = atts.value("pointId");
2040  if (!minLonPointId.isEmpty()) {
2041  m_xmlHandlerBundleResults->m_minSigmaLongitudePointId = minLonPointId;
2042  }
2043 
2044  }
2045  else if (qName == "maxLon") {
2046 
2047  QString maxLon = atts.value("value");
2048  if (!maxLon.isEmpty()) {
2049  m_xmlHandlerBundleResults->m_maxSigmaLongitudeDistance.setMeters(toDouble(maxLon));
2050  }
2051 
2052  QString maxLonPointId = atts.value("pointId");
2053  if (!maxLonPointId.isEmpty()) {
2054  m_xmlHandlerBundleResults->m_maxSigmaLongitudePointId = maxLonPointId;
2055  }
2056 
2057  }
2058  else if (qName == "minRad") {
2059 
2060  QString minRad = atts.value("value");
2061  if (!minRad.isEmpty()) {
2062  m_xmlHandlerBundleResults->m_minSigmaRadiusDistance.setMeters(toDouble(minRad));
2063  }
2064 
2065  QString minRadPointId = atts.value("pointId");
2066  if (!minRadPointId.isEmpty()) {
2067  m_xmlHandlerBundleResults->m_minSigmaRadiusPointId = minRadPointId;
2068  }
2069 
2070  }
2071  else if (qName == "maxRad") {
2072 
2073  QString maxRad = atts.value("value");
2074  if (!maxRad.isEmpty()) {
2075  m_xmlHandlerBundleResults->m_maxSigmaRadiusDistance.setMeters(toDouble(maxRad));
2076  }
2077 
2078  QString maxRadPointId = atts.value("pointId");
2079  if (!maxRadPointId.isEmpty()) {
2080  m_xmlHandlerBundleResults->m_maxSigmaRadiusPointId = maxRadPointId;
2081  }
2082 
2083  }
2084  else if (qName == "maximumLikelihoodEstimation") {
2085 
2086  QString maximumLikelihoodIndex = atts.value("maximumLikelihoodIndex");
2087  if (!maximumLikelihoodIndex.isEmpty()) {
2088  m_xmlHandlerBundleResults->m_maximumLikelihoodIndex = toInt(maximumLikelihoodIndex);
2089  }
2090 
2092  atts.value("maximumLikelihoodMedianR2Residuals");
2093  if (!maximumLikelihoodMedianR2Residuals.isEmpty()) {
2094  m_xmlHandlerBundleResults->m_maximumLikelihoodMedianR2Residuals =
2095  toDouble(maximumLikelihoodMedianR2Residuals);
2096  }
2097 
2098  }
2099  else if (qName == "model") {
2100  QString model = atts.value("modelSelection");
2101  QString tweakingConstant = atts.value("tweakingConstant");
2102  QString quantile = atts.value("quantile");
2103  bool validModel = true;
2104  if (model.isEmpty()) validModel = false;
2105  if (tweakingConstant.isEmpty()) validModel = false;
2106  if (quantile.isEmpty()) validModel = false;
2107  if (validModel) {
2108  m_xmlHandlerBundleResults->m_maximumLikelihoodFunctions.append(
2109  qMakePair(MaximumLikelihoodWFunctions(
2110  MaximumLikelihoodWFunctions::stringToModel(model),
2111  toDouble(tweakingConstant)),
2112  toDouble(quantile)));
2113  }
2114  }
2115  else if (qName == "cumulativeProbabilityCalculator") {
2116  m_xmlHandlerBundleResults->m_cumPro = NULL;
2117  m_xmlHandlerBundleResults->m_cumPro =
2118  new StatCumProbDistDynCalc(m_xmlHandlerProject, reader());
2119  }
2120  else if (qName == "residualsCumulativeProbabilityCalculator") {
2121  m_xmlHandlerBundleResults->m_cumProRes = NULL;
2122  m_xmlHandlerBundleResults->m_cumProRes = new StatCumProbDistDynCalc(m_xmlHandlerProject,
2123  reader());
2124  }
2125  }
2126  return true;
2127  }
2128 
2129 
2137  bool BundleResults::XmlHandler::characters(const QString &ch) {
2138  m_xmlHandlerCharacters += ch;
2139  return XmlStackedHandler::characters(ch);
2140  }
2141 
2142 
2152  bool BundleResults::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
2153  const QString &qName) {
2154 
2155  if (!m_xmlHandlerCharacters.isEmpty()) {
2156  if (qName == "id") {
2157  m_xmlHandlerBundleResults->m_id = NULL;
2158  m_xmlHandlerBundleResults->m_id = new QUuid(m_xmlHandlerCharacters);
2159  }
2160 // else if (qName == "instrumentId") {
2161 // m_xmlHandlerBundleResults->m_instrumentId = m_xmlHandlerCharacters;
2162 // }
2163  if (qName == "parameter") {
2164  // add the parameter to the current list
2165  m_xmlHandlerCorrelationParameterList.append(m_xmlHandlerCharacters);
2166  }
2167  if (qName == "image") {
2168  // add this image and its parameters to the map
2169  if (m_xmlHandlerCorrelationImageId != "") {
2170  m_xmlHandlerCorrelationMap.insert(m_xmlHandlerCorrelationImageId,
2171  m_xmlHandlerCorrelationParameterList);
2172  }
2173  m_xmlHandlerCorrelationImageId = "";
2174  m_xmlHandlerCorrelationParameterList.clear();
2175 
2176  }
2177  if (qName == "imagesAndParameters") {
2178  // set the map after all images and parameters have been added
2179  if (!m_xmlHandlerCorrelationMap.isEmpty()) {
2180  m_xmlHandlerBundleResults->setCorrMatImgsAndParams(m_xmlHandlerCorrelationMap);
2181  }
2182  }
2183  else if (qName == "numberFixedPoints") {
2184  m_xmlHandlerBundleResults->m_numberFixedPoints = toInt(m_xmlHandlerCharacters);
2185  }
2186  else if (qName == "numberIgnoredPoints") {
2187  m_xmlHandlerBundleResults->m_numberIgnoredPoints = toInt(m_xmlHandlerCharacters);
2188  }
2189  else if (qName == "numberHeldImages") {
2190  m_xmlHandlerBundleResults->m_numberHeldImages = toInt(m_xmlHandlerCharacters);
2191  }
2192  else if (qName == "rejectionLimit") {
2193  m_xmlHandlerBundleResults->m_rejectionLimit = toDouble(m_xmlHandlerCharacters);
2194  }
2195  else if (qName == "numberRejectedObservations") {
2196  m_xmlHandlerBundleResults->m_numberRejectedObservations = toInt(m_xmlHandlerCharacters);
2197  }
2198  else if (qName == "numberObservations") {
2199  m_xmlHandlerBundleResults->m_numberObservations = toInt(m_xmlHandlerCharacters);
2200  }
2201  else if (qName == "numberImageParameters") {
2202  m_xmlHandlerBundleResults->m_numberImageParameters = toInt(m_xmlHandlerCharacters);
2203  }
2204  else if (qName == "numberConstrainedPointParameters") {
2205  m_xmlHandlerBundleResults->m_numberConstrainedPointParameters =
2206  toInt(m_xmlHandlerCharacters);
2207  }
2208  else if (qName == "numberConstrainedImageParameters") {
2209  m_xmlHandlerBundleResults->m_numberConstrainedImageParameters =
2210  toInt(m_xmlHandlerCharacters);
2211  }
2212  else if (qName == "numberConstrainedTargetParameters") {
2213  m_xmlHandlerBundleResults->m_numberConstrainedTargetParameters =
2214  toInt(m_xmlHandlerCharacters);
2215  }
2216  else if (qName == "numberUnknownParameters") {
2217  m_xmlHandlerBundleResults->m_numberUnknownParameters = toInt(m_xmlHandlerCharacters);
2218  }
2219  else if (qName == "degreesOfFreedom") {
2220  m_xmlHandlerBundleResults->m_degreesOfFreedom = toInt(m_xmlHandlerCharacters);
2221  }
2222  else if (qName == "sigma0") {
2223  m_xmlHandlerBundleResults->m_sigma0 = toDouble(m_xmlHandlerCharacters);
2224  }
2225  else if (qName == "converged") {
2226  m_xmlHandlerBundleResults->m_converged = toBool(m_xmlHandlerCharacters);
2227  }
2228  // copy the xml handler's statistics list to the appropriate bundle statistics list
2229  else if (qName == "residualsList") {
2230  // do this check or assume the xml is valid???
2231  // ??? if (m_xmlHandlerResidualsListSize != m_xmlHandlerStatisticsList.size()) {
2232  // ??? throw IException(IException::Unknown,
2233  // ??? "Unable to read xml file. Invalid residualsList", _FILEINFO_);
2234  // ??? }
2235  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2236  m_xmlHandlerBundleResults->m_rmsImageResiduals.append(m_xmlHandlerStatisticsList[i]);
2237  }
2238  m_xmlHandlerStatisticsList.clear();
2239  }
2240  else if (qName == "sampleList") {
2241  // ??? if (m_xmlHandlerSampleResidualsListSize != m_xmlHandlerStatisticsList.size()) {
2242  // ??? throw IException(IException::Unknown,
2243  // ??? "Unable to read xml file. Invalid sampleList", _FILEINFO_);
2244  // ??? }
2245  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2246  m_xmlHandlerBundleResults->m_rmsImageSampleResiduals.append(
2247  m_xmlHandlerStatisticsList[i]);
2248  }
2249  m_xmlHandlerStatisticsList.clear();
2250  }
2251  else if (qName == "lineList") {
2252  // ??? if (m_xmlHandlerLineResidualsListSize != m_xmlHandlerStatisticsList.size()) {
2253  // ??? throw IException(IException::Unknown,
2254  // ??? "Unable to read xml file. Invalid lineList", _FILEINFO_);
2255  // ??? }
2256  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2257  m_xmlHandlerBundleResults->m_rmsImageLineResiduals.append(m_xmlHandlerStatisticsList[i]);
2258  }
2259  m_xmlHandlerStatisticsList.clear();
2260  }
2261  else if (qName == "xSigmas") {
2262  // ??? if (m_xmlHandlerXSigmasListSize != m_xmlHandlerStatisticsList.size()) {
2263  // ??? throw IException(IException::Unknown,
2264  // ??? "Unable to read xml file. Invalid xSigmas", _FILEINFO_); ???
2265  // }
2266  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2267  m_xmlHandlerBundleResults->m_rmsImageXSigmas.append(m_xmlHandlerStatisticsList[i]);
2268  }
2269  m_xmlHandlerStatisticsList.clear();
2270  }
2271  else if (qName == "ySigmas") {
2272  // ??? if (m_xmlHandlerYSigmasListSize != m_xmlHandlerStatisticsList.size()) {
2273  // ??? throw IException(IException::Unknown,
2274  // ??? "Unable to read xml file. Invalid ySigmas", _FILEINFO_);
2275  // ??? }
2276  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2277  m_xmlHandlerBundleResults->m_rmsImageYSigmas.append(m_xmlHandlerStatisticsList[i]);
2278  }
2279  m_xmlHandlerStatisticsList.clear();
2280  }
2281  else if (qName == "zSigmas") {
2282  // ??? if (m_xmlHandlerZSigmasListSize != m_xmlHandlerStatisticsList.size()) {
2283  // ??? throw IException(IException::Unknown,
2284  // ??? "Unable to read xml file. Invalid zSigmas", _FILEINFO_);
2285  // ??? }
2286  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2287  m_xmlHandlerBundleResults->m_rmsImageZSigmas.append(m_xmlHandlerStatisticsList[i]);
2288  }
2289  m_xmlHandlerStatisticsList.clear();
2290  }
2291  else if (qName == "raSigmas") {
2292  // ??? if (m_xmlHandlerRASigmasListSize != m_xmlHandlerStatisticsList.size()) {
2293  // ??? throw IException(IException::Unknown,
2294  // ??? "Unable to read xml file. Invalid raSigmas", _FILEINFO_);
2295  // ??? }
2296  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2297  m_xmlHandlerBundleResults->m_rmsImageRASigmas.append(m_xmlHandlerStatisticsList[i]);
2298  }
2299  m_xmlHandlerStatisticsList.clear();
2300  }
2301  else if (qName == "decSigmas") {
2302  // ??? if (m_xmlHandlerDECSigmasListSize != m_xmlHandlerStatisticsList.size()) {
2303  // ??? throw IException(IException::Unknown,
2304  // ??? "Unable to read xml file. Invalid decSigmas", _FILEINFO_);
2305  // ??? }
2306  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2307  m_xmlHandlerBundleResults->m_rmsImageDECSigmas.append(m_xmlHandlerStatisticsList[i]);
2308  }
2309  m_xmlHandlerStatisticsList.clear();
2310  }
2311  else if (qName == "twistSigmas") {
2312  // ??? if (m_xmlHandlerTWISTSigmasListSize != m_xmlHandlerStatisticsList.size()) {
2313  // ??? throw IException(IException::Unknown,
2314  // ??? "Unable to read xml file. Invalid twistSigmas", _FILEINFO_);
2315  // ??? }
2316  for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) {
2317  m_xmlHandlerBundleResults->m_rmsImageTWISTSigmas.append(m_xmlHandlerStatisticsList[i]);
2318  }
2319  m_xmlHandlerStatisticsList.clear();
2320  }
2321  }
2322  m_xmlHandlerCharacters = "";
2323  return XmlStackedHandler::endElement(namespaceURI, localName, qName);
2324  }
2325 
2326 
2335  QDataStream &BundleResults::write(QDataStream &stream) const {
2336  stream << m_id->toString()
2338  << (qint32)m_numberFixedPoints
2339  << (qint32)m_numberIgnoredPoints
2340  << (qint32)m_numberHeldImages
2342  << m_rejectionLimit
2343  << (qint32)m_numberObservations
2344  << (qint32)m_numberRejectedObservations
2345  << (qint32)m_numberUnknownParameters
2346  << (qint32)m_numberImageParameters
2350  << (qint32)m_degreesOfFreedom
2351  << m_sigma0
2353  << m_converged
2356  << m_rmsImageXSigmas << m_rmsImageYSigmas << m_rmsImageZSigmas
2372  << (qint32)m_maximumLikelihoodIndex << *m_cumPro << *m_cumProRes
2374  return stream;
2375  }
2376 
2377 
2385  QDataStream &BundleResults::read(QDataStream &stream) {
2386  QString id;
2391  numberUnknownParameters, degreesOfFreedom, maximumLikelihoodIndex;
2394  StatCumProbDistDynCalc cumPro;
2395  StatCumProbDistDynCalc cumProRes;
2396 
2397  stream >> id;
2398  stream >> correlationMatrix;
2399  stream >> numberFixedPoints;
2400  stream >> numberIgnoredPoints;
2401  stream >> numberHeldImages;
2403  stream >> m_rejectionLimit;
2404  stream >> numberObservations;
2405  stream >> numberRejectedObservations;
2406  stream >> numberUnknownParameters;
2407  stream >> numberImageParameters;
2411  stream >> degreesOfFreedom;
2412  stream >> m_sigma0;
2414  stream >> m_converged;
2416  stream >> m_rmsImageResiduals;
2417  stream >> m_rmsImageXSigmas >> m_rmsImageYSigmas >> m_rmsImageZSigmas;
2419  stream >> minSigmaLatitudeDistance;
2420  stream >> maxSigmaLatitudeDistance;
2421  stream >> minSigmaLongitudeDistance;
2422  stream >> maxSigmaLongitudeDistance;
2423  stream >> minSigmaRadiusDistance;
2424  stream >> maxSigmaRadiusDistance;
2425  stream >> m_minSigmaLatitudePointId;
2426  stream >> m_maxSigmaLatitudePointId;
2427  stream >> m_minSigmaLongitudePointId;
2428  stream >> m_maxSigmaLongitudePointId;
2429  stream >> m_minSigmaRadiusPointId;
2430  stream >> m_maxSigmaRadiusPointId;
2432  stream >> m_maximumLikelihoodFunctions;
2433  stream >> maximumLikelihoodIndex;
2434  stream >> cumPro >> cumProRes;
2436 
2437  m_id = NULL;
2438  m_id = new QUuid(id);
2439 
2440  m_correlationMatrix = NULL;
2441  m_correlationMatrix = new CorrelationMatrix(correlationMatrix);
2442 
2443  m_numberFixedPoints = (int)numberFixedPoints;
2444  m_numberIgnoredPoints = (int)numberIgnoredPoints;
2445  m_numberHeldImages = (int)numberHeldImages;
2446  m_numberRejectedObservations = (int)numberRejectedObservations;
2447  m_numberObservations = (int)numberObservations;
2448  m_numberImageParameters = (int)numberImageParameters;
2449  m_numberConstrainedPointParameters = (int)numberConstrainedPointParameters;
2450  m_numberConstrainedImageParameters = (int)numberConstrainedImageParameters;
2451  m_numberConstrainedTargetParameters = (int)numberConstrainedTargetParameters;
2452  m_numberUnknownParameters = (int)numberUnknownParameters;
2453  m_degreesOfFreedom = (int)degreesOfFreedom;
2454  m_maximumLikelihoodIndex = (int)maximumLikelihoodIndex;
2455 
2456  m_minSigmaLatitudeDistance.setMeters(minSigmaLatitudeDistance);
2457  m_maxSigmaLatitudeDistance.setMeters(maxSigmaLatitudeDistance);
2458  m_minSigmaLongitudeDistance.setMeters(minSigmaLongitudeDistance);
2459  m_maxSigmaLongitudeDistance.setMeters(maxSigmaLongitudeDistance);
2460  m_minSigmaRadiusDistance.setMeters(minSigmaRadiusDistance);
2461  m_maxSigmaRadiusDistance.setMeters(maxSigmaRadiusDistance);
2462 
2463  m_cumPro = NULL;
2464  m_cumPro = new StatCumProbDistDynCalc(cumPro);
2465 
2466  m_cumProRes = NULL;
2467  m_cumProRes = new StatCumProbDistDynCalc(cumProRes);
2468 
2469  return stream;
2470  }
2471 
2472 
2483  QDataStream &operator<<(QDataStream &stream, const BundleResults &bundleResults) {
2484  return bundleResults.write(stream);
2485  }
2486 
2487 
2498  QDataStream &operator>>(QDataStream &stream, BundleResults &bundleResults) {
2499  return bundleResults.read(stream);
2500  }
2501 
2502 
2513  void BundleResults::createH5Group(H5::CommonFG &locationObject, QString locationName) const {
2514  try {
2515  // Try block to detect exceptions raised by any of the calls inside it
2516  try {
2517  /*
2518  * Turn off the auto-printing when failure occurs so that we can
2519  * handle the errors appropriately
2520  */
2521  // H5::Exception::dontPrint();
2522 
2523  // create a results group to add to the given H5 object
2524  QString resultsGroupName = locationName + "/BundleResults";
2525  H5::Group resultsGroup = locationObject.createGroup(resultsGroupName.toLatin1());
2526 
2527  // use H5S_SCALAR data space type for single valued spaces
2528  H5::DataSpace spc(H5S_SCALAR);
2529  Attribute att;
2530 
2531  /*
2532  * Add string attributes as predefined data type H5::PredType::C_S1 (string)
2533  */
2534  H5::StrType strDataType;
2535  int stringSize = 0;
2536 
2537  //TODO: finish Correlation Matrix
2538  //Create a dataset with compression
2539  // m_correlationMatrix->createH5Group(resultsGroup, resultsGroupName);
2540  QString correlationFileName = correlationMatrix().correlationFileName().expanded();
2541  stringSize = qMax(correlationFileName.length(), 1);
2542  strDataType = H5::StrType(H5::PredType::C_S1, stringSize);
2543  att = resultsGroup.createAttribute("correlationFileName", strDataType, spc);
2544  att.write(strDataType, correlationFileName.toStdString());
2545 
2546  QString covarianceFileName = correlationMatrix().covarianceFileName().expanded();
2547  stringSize = qMax(covarianceFileName.length(), 1);
2548  strDataType = H5::StrType(H5::PredType::C_S1, stringSize);
2549  att = resultsGroup.createAttribute("covarianceFileName", strDataType, spc);
2550  att.write(strDataType, covarianceFileName.toStdString());
2551  // TODO: table???
2552  // correlationMatrix().imagesAndParameters()???
2553  // QMapIterator<QString, QStringList> a list of images with their
2554  // corresponding parameters...
2555 
2556 
2557  /*
2558  * Add integer attributes as predefined data type H5::PredType::NATIVE_INT
2559  */
2560  att = resultsGroup.createAttribute("numberFixedPoints",
2561  H5::PredType::NATIVE_INT,
2562  spc);
2563  att.write(H5::PredType::NATIVE_INT, &m_numberFixedPoints);
2564 
2565  att = resultsGroup.createAttribute("numberIgnoredPoints",
2566  H5::PredType::NATIVE_INT,
2567  spc);
2568  att.write(H5::PredType::NATIVE_INT, &m_numberIgnoredPoints);
2569 
2570  att = resultsGroup.createAttribute("numberHeldImages",
2571  H5::PredType::NATIVE_INT,
2572  spc);
2573  att.write(H5::PredType::NATIVE_INT, &m_numberHeldImages);
2574 
2575  att = resultsGroup.createAttribute("numberObservations",
2576  H5::PredType::NATIVE_INT,
2577  spc);
2578  att.write(H5::PredType::NATIVE_INT, &m_numberObservations);
2579 
2580 
2581  att = resultsGroup.createAttribute("numberRejectedObservations",
2582  H5::PredType::NATIVE_INT,
2583  spc);
2584  att.write(H5::PredType::NATIVE_INT, &m_numberRejectedObservations);
2585 
2586  att = resultsGroup.createAttribute("numberImageParameters",
2587  H5::PredType::NATIVE_INT,
2588  spc);
2589  att.write(H5::PredType::NATIVE_INT, &m_numberImageParameters);
2590 
2591  att = resultsGroup.createAttribute("numberConstrainedPointParameters",
2592  H5::PredType::NATIVE_INT,
2593  spc);
2594  att.write(H5::PredType::NATIVE_INT, &m_numberConstrainedPointParameters);
2595 
2596  att = resultsGroup.createAttribute("numberConstrainedImageParameters",
2597  H5::PredType::NATIVE_INT,
2598  spc);
2599  att.write(H5::PredType::NATIVE_INT, &m_numberConstrainedImageParameters);
2600 
2601  att = resultsGroup.createAttribute("numberUnknownParameters",
2602  H5::PredType::NATIVE_INT,
2603  spc);
2604  att.write(H5::PredType::NATIVE_INT, &m_numberUnknownParameters);
2605 
2606  att = resultsGroup.createAttribute("degreesOfFreedom",
2607  H5::PredType::NATIVE_INT,
2608  spc);
2609  att.write(H5::PredType::NATIVE_INT, &m_degreesOfFreedom);
2610 
2611  /*
2612  * Add double attributes as predefined data type H5::PredType::NATIVE_DOUBLE
2613  */
2614  att = resultsGroup.createAttribute("rejectionLimit",
2615  H5::PredType::NATIVE_DOUBLE,
2616  spc);
2617  att.write(H5::PredType::NATIVE_DOUBLE, &m_rejectionLimit);
2618 
2619  att = resultsGroup.createAttribute("sigma0",
2620  H5::PredType::NATIVE_DOUBLE,
2621  spc);
2622  att.write(H5::PredType::NATIVE_DOUBLE, &m_sigma0);
2623 
2624  att = resultsGroup.createAttribute("elapsedTime",
2625  H5::PredType::NATIVE_DOUBLE,
2626  spc);
2627  att.write(H5::PredType::NATIVE_DOUBLE, &m_elapsedTime);
2628 
2629  att = resultsGroup.createAttribute("elapsedTimeErrorProp",
2630  H5::PredType::NATIVE_DOUBLE,
2631  spc);
2632  att.write(H5::PredType::NATIVE_DOUBLE, &m_elapsedTimeErrorProp);
2633 
2634  // todo: put rms in their own table/dataset/group???
2635  att = resultsGroup.createAttribute("rmsXResiduals",
2636  H5::PredType::NATIVE_DOUBLE,
2637  spc);
2638  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsXResiduals);
2639 
2640  att = resultsGroup.createAttribute("rmsYResiduals",
2641  H5::PredType::NATIVE_DOUBLE,
2642  spc);
2643  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsYResiduals);
2644 
2645  att = resultsGroup.createAttribute("rmsXYResiduals",
2646  H5::PredType::NATIVE_DOUBLE,
2647  spc);
2648  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsXYResiduals);
2649 
2650  att = resultsGroup.createAttribute("rmsSigmaLatitudeStats",
2651  H5::PredType::NATIVE_DOUBLE,
2652  spc);
2653  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaLatitudeStats);
2654 
2655  att = resultsGroup.createAttribute("rmsSigmaLongitudeStats",
2656  H5::PredType::NATIVE_DOUBLE,
2657  spc);
2658  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaLongitudeStats);
2659 
2660  att = resultsGroup.createAttribute("rmsSigmaRadiusStats",
2661  H5::PredType::NATIVE_DOUBLE,
2662  spc);
2663  att.write(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaRadiusStats);
2664 
2665  /*
2666  * Add bool attributes as predefined data type H5::PredType::NATIVE_HBOOL
2667  */
2668  att = resultsGroup.createAttribute("converged",
2669  H5::PredType::NATIVE_HBOOL,
2670  spc);
2671  int converged = (int)m_converged;
2672  att.write(H5::PredType::NATIVE_HBOOL, &converged);
2673  /*
2674  * Add Statistics lists as data sets
2675  */
2676  QString dataSetName;
2677  H5::DataSet dataSet;
2678  hsize_t dims[1];
2679  H5::CompType compoundDataType = Statistics::compoundH5DataType();
2680 
2681 
2682  // IMAGE LINE RESIDUALS LIST
2683  {
2684  int listLength = 1;
2685  if (!m_rmsImageLineResiduals.isEmpty()) {
2686  listLength = m_rmsImageLineResiduals.size();
2687  }
2688 
2689  // Set the data space dimension to be the number of Statistics elements in this data set
2690  dims[0] = (hsize_t)listLength;
2691  H5::DataSpace dataSetSpace(1, dims);
2692 
2693  dataSetName = resultsGroupName + "/RmsImageLineResidualsStatistics";
2694  dataSet = resultsGroup.createDataSet(dataSetName.toLatin1(),
2695  compoundDataType,
2696  dataSetSpace);
2697 
2698  QByteArray byteArray;
2699  QDataStream stream(&byteArray, QIODevice::WriteOnly);
2700  stream.setByteOrder(QDataStream::LittleEndian);
2701  for (int i = 0; i < listLength; i++) {
2702  stream << m_rmsImageLineResiduals[i];
2703  }
2704  char *buf = byteArray.data();
2705  dataSet.write(buf, compoundDataType);
2706  dataSet.close();
2707  }
2708 
2709  // IMAGE SAMPLE RESIDUALS LIST
2710  {
2711  int listLength = 1;
2712  if (!m_rmsImageSampleResiduals.isEmpty()) {
2713  listLength = m_rmsImageSampleResiduals.size();
2714  }
2715 
2716  // Set the data space dimension to be the number of Statistics elements in this data set
2717  dims[0] = (hsize_t)listLength;
2718  H5::DataSpace dataSetSpace(1, dims);
2719 
2720  dataSetName = resultsGroupName + "/RmsImageSampleResidualsStatistics";
2721  dataSet = resultsGroup.createDataSet(dataSetName.toLatin1(),
2722  compoundDataType,
2723  dataSetSpace);
2724 
2725  QByteArray byteArray;
2726  QDataStream stream(&byteArray, QIODevice::WriteOnly);
2727  stream.setByteOrder(QDataStream::LittleEndian);
2728  for (int i = 0; i < listLength; i++) {
2729  stream << m_rmsImageSampleResiduals[i];
2730  }
2731  char *buf = byteArray.data();
2732  dataSet.write(buf, compoundDataType);
2733  dataSet.close();
2734  }
2735 
2736  // IMAGE RESIDUALS LIST
2737  {
2738  int listLength = 1;
2739  if (!m_rmsImageResiduals.isEmpty()) {
2740  listLength = m_rmsImageResiduals.size();
2741  }
2742 
2743  // Set the data space dimension to be the number of Statistics elements in this data set
2744  dims[0] = (hsize_t)listLength;
2745  H5::DataSpace dataSetSpace(1, dims);
2746 
2747  dataSetName = resultsGroupName + "/RmsImageResidualsStatistics";
2748  dataSet = resultsGroup.createDataSet(dataSetName.toLatin1(),
2749  compoundDataType,
2750  dataSetSpace);
2751 
2752  QByteArray byteArray;
2753  QDataStream stream(&byteArray, QIODevice::WriteOnly);
2754  stream.setByteOrder(QDataStream::LittleEndian);
2755  for (int i = 0; i < listLength; i++) {
2756  stream << m_rmsImageResiduals[i];
2757  }
2758  char *buf = byteArray.data();
2759  dataSet.write(buf, compoundDataType);
2760  dataSet.close();
2761  }
2762 
2763  } // end of try block
2764  // catch failure caused by the Attribute operations
2765  catch ( H5::AttributeIException error ) {
2766  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2767  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2768  msg = "H5 ATTRIBUTE exception handler has detected an error when invoking the function "
2769  + QString::fromStdString(error.getFuncName()) + ".";
2770  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2771  }
2772  // catch failure caused by the DataSet operations
2773  catch ( H5::DataSetIException error ) {
2774  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2775  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2776  msg = "H5 DATA SET exception handler has detected an error when invoking the function "
2777  + QString::fromStdString(error.getFuncName()) + ".";
2778  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2779  }
2780  // catch failure caused by the DataSpace operations
2781  catch ( H5::DataSpaceIException error ) {
2782  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2783  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2784  msg = "H5 DATA SPACE exception handler has detected an error when invoking the function "
2785  + QString::fromStdString(error.getFuncName()) + ".";
2786  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2787  }
2788  // catch failure caused by the DataType operations
2789  catch ( H5::DataTypeIException error ) {
2790  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2791  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2792  msg = "H5 DATA TYPE exception handler has detected an error when invoking the function "
2793  + QString::fromStdString(error.getFuncName()) + ".";
2794  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2795  }
2796  // catch failure caused by the H5File operations
2797  catch ( H5::FileIException error ) {
2798  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2799  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2800  msg = "H5 FILE exception handler has detected an error when invoking the function "
2801  + QString::fromStdString(error.getFuncName()) + ".";
2802  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2803  }
2804  // catch failure caused by the Group operations
2805  catch ( H5::GroupIException error ) {
2806  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2807  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2808  msg = "H5 GROUP exception handler has detected an error when invoking the function "
2809  + QString::fromStdString(error.getFuncName()) + ".";
2810  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2811  }
2812  //??? how to improve printed msg using major/minor error codes?
2813  catch ( H5::Exception error ) {
2814  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
2815  IException hpfError(IException::Unknown, msg, _FILEINFO_);
2816  msg = "H5 GENERAL exception handler has detected an error when invoking the function "
2817  + QString::fromStdString(error.getFuncName()) + ".";
2818  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
2819  }
2820  }
2821  catch (IException &e) {
2822  throw IException(e,
2824  "Unable to save bundle results information to an HDF5 group.",
2825  _FILEINFO_);
2826  }
2827 
2828  }
2829 
2830 
2841  void BundleResults::openH5Group(H5::CommonFG &locationObject, QString locationName) {
2842  try {
2843  // Try block to detect exceptions raised by any of the calls inside it
2844  try {
2845  /*
2846  * Turn off the auto-printing when failure occurs so that we can
2847  * handle the errors appropriately
2848  */
2849  // H5::Exception::dontPrint();
2850 
2851  // create a results group to add to the given H5 object
2852  QString resultsGroupName = locationName + "/BundleResults";
2853  H5::Group resultsGroup = locationObject.openGroup(resultsGroupName.toLatin1());
2854 
2855  Attribute att;
2856 
2857  //TODO: finish Correlation Matrix
2858  //Create a dataset with compression
2859  // m_correlationMatrix->openH5Group(resultsGroup, resultsGroupName);
2860 
2861  /*
2862  * read string atts as predefined data type H5::PredType::C_S1 (string)
2863  */
2864  H5::StrType strDataType;
2865  H5std_string strAttValue;
2866 
2867  att = resultsGroup.openAttribute("correlationFileName");
2868  strDataType = H5::StrType(H5::PredType::C_S1, att.getStorageSize());
2869  att.read(strDataType, strAttValue);
2870  m_correlationMatrix->setCorrelationFileName(QString::fromStdString(strAttValue));
2871 
2872  att = resultsGroup.openAttribute("covarianceFileName");
2873  strDataType = H5::StrType(H5::PredType::C_S1, att.getStorageSize());
2874  att.read(strDataType, strAttValue);
2875  m_correlationMatrix->setCovarianceFileName(QString::fromStdString(strAttValue));
2876 
2877  // TODO: table??? data set???
2878  // correlationMatrix().imagesAndParameters()???
2879  // QMapIterator<QString, QStringList> a list of images with their
2880  // corresponding parameters...
2881 
2882 
2883  /*
2884  * read int attributes as predefined data type H5::PredType::NATIVE_INT
2885  */
2886  att = resultsGroup.openAttribute("numberFixedPoints");
2887  att.read(H5::PredType::NATIVE_INT, &m_numberFixedPoints);
2888 
2889  att = resultsGroup.openAttribute("numberIgnoredPoints");
2890  att.read(H5::PredType::NATIVE_INT, &m_numberIgnoredPoints);
2891 
2892  att = resultsGroup.openAttribute("numberHeldImages");
2893  att.read(H5::PredType::NATIVE_INT, &m_numberHeldImages);
2894 
2895  att = resultsGroup.openAttribute("numberObservations");
2896  att.read(H5::PredType::NATIVE_INT, &m_numberObservations);
2897 
2898  att = resultsGroup.openAttribute("numberRejectedObservations");
2899  att.read(H5::PredType::NATIVE_INT, &m_numberRejectedObservations);
2900 
2901  att = resultsGroup.openAttribute("numberImageParameters");
2902  att.read(H5::PredType::NATIVE_INT, &m_numberImageParameters);
2903 
2904  att = resultsGroup.openAttribute("numberConstrainedImageParameters");
2905  att.read(H5::PredType::NATIVE_INT, &m_numberConstrainedImageParameters);
2906 
2907  att = resultsGroup.openAttribute("numberConstrainedPointParameters");
2908  att.read(H5::PredType::NATIVE_INT, &m_numberConstrainedPointParameters);
2909 
2910  att = resultsGroup.openAttribute("numberUnknownParameters");
2911  att.read(H5::PredType::NATIVE_INT, &m_numberUnknownParameters);
2912 
2913  att = resultsGroup.openAttribute("degreesOfFreedom");
2914  att.read(H5::PredType::NATIVE_INT, &m_degreesOfFreedom);
2915 
2916  /*
2917  * read double attributes as predefined data type H5::PredType::NATIVE_DOUBLE
2918  */
2919  att = resultsGroup.openAttribute("rejectionLimit");
2920  att.read(H5::PredType::NATIVE_DOUBLE, &m_rejectionLimit);
2921 
2922  att = resultsGroup.openAttribute("sigma0");
2923  att.read(H5::PredType::NATIVE_DOUBLE, &m_sigma0);
2924 
2925  att = resultsGroup.openAttribute("elapsedTime");
2926  att.read(H5::PredType::NATIVE_DOUBLE, &m_elapsedTime);
2927 
2928  att = resultsGroup.openAttribute("elapsedTimeErrorProp");
2929  att.read(H5::PredType::NATIVE_DOUBLE, &m_elapsedTimeErrorProp);
2930 
2931  // todo: put rms in their own table/dataset/group???
2932  att = resultsGroup.openAttribute("rmsXResiduals");
2933  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsXResiduals);
2934 
2935  att = resultsGroup.openAttribute("rmsYResiduals");
2936  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsYResiduals);
2937 
2938  att = resultsGroup.openAttribute("rmsXYResiduals");
2939  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsXYResiduals);
2940 
2941  att = resultsGroup.openAttribute("rmsSigmaLatitudeStats");
2942  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaLatitudeStats);
2943 
2944  att = resultsGroup.openAttribute("rmsSigmaLongitudeStats");
2945  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaLongitudeStats);
2946 
2947  att = resultsGroup.openAttribute("rmsSigmaRadiusStats");
2948  att.read(H5::PredType::NATIVE_DOUBLE, &m_rmsSigmaRadiusStats);
2949 
2950  /*
2951  * read bool attributes as predefined data type H5::PredType::NATIVE_HBOOL
2952  */
2953  int boolAttValue = 0;
2954  att = resultsGroup.openAttribute("converged");
2955  att.read(H5::PredType::NATIVE_HBOOL, &boolAttValue);
2956  m_converged = (bool)boolAttValue;
2957 
2958  /*
2959  * read data sets of Statistics objects
2960  */
2961  QString dataSetName = "";
2962  H5::DataSet dataSet;
2963  H5::CompType compoundDataType = Statistics::compoundH5DataType();
2964 
2965  // IMAGE LINE RESIDUALS LIST
2966  {
2967  dataSetName = resultsGroupName + "/RmsImageLineResidualsStatistics";
2968  herr_t status = H5Gget_objinfo(resultsGroup.getId(), dataSetName.toLatin1(), 0, NULL);
2969  if (status != 0) {
2970  // group DNE...
2971  qDebug() << "didn't find or couldn't read stats list.";//???
2972  }
2973  try {
2974 
2975  // if this doesn't throw an error, then the group exists???
2976  H5G_stat_t info;
2977  resultsGroup.getObjinfo(dataSetName.toLatin1(), info);
2978 
2979  dataSet = resultsGroup.openDataSet(dataSetName.toLatin1());
2980  H5::DataSpace dataSetSpace = dataSet.getSpace();
2981 
2982  char statsList[dataSet.getStorageSize()];
2983  dataSet.read(statsList, compoundDataType);
2984 
2985  int listLength = dataSetSpace.getSimpleExtentNpoints();
2986  int statsSize = compoundDataType.getSize();
2987  for (int i = 0; i < listLength; i++) {
2988  QByteArray byteArray(&(statsList[i*statsSize]), statsSize);
2989  QDataStream stream(&byteArray, QIODevice::ReadOnly);
2990  stream.setByteOrder(QDataStream::LittleEndian);
2991 
2992  Statistics tempStats;
2993  stream >> tempStats;
2994  m_rmsImageLineResiduals.append(tempStats);
2995  }
2996 
2997  }
2998  catch (H5::GroupIException groupError) {
2999  // don't do anything???
3000  }
3001  }
3002 
3003  // IMAGE SAMPLE RESIDUALS LIST
3004  {
3005  dataSetName = resultsGroupName + "/RmsImageSampleResidualsStatistics";
3006  herr_t status = H5Gget_objinfo(resultsGroup.getId(), dataSetName.toLatin1(), 0, NULL);
3007  if (status != 0) {
3008  // group DNE...
3009  qDebug() << "didn't find or couldn't read stats list.";
3010  }
3011  try {
3012 
3013  // if this doesn't throw an error, then the group exists???
3014  H5G_stat_t info;
3015  resultsGroup.getObjinfo(dataSetName.toLatin1(), info);
3016 
3017  dataSet = resultsGroup.openDataSet(dataSetName.toLatin1());
3018  H5::DataSpace dataSetSpace = dataSet.getSpace();
3019 
3020  char statsList[dataSet.getStorageSize()];
3021  dataSet.read(statsList, compoundDataType);
3022 
3023  int listLength = dataSetSpace.getSimpleExtentNpoints();
3024  int statsSize = compoundDataType.getSize();
3025  for (int i = 0; i < listLength; i++) {
3026  QByteArray byteArray(&(statsList[i*statsSize]), statsSize);
3027  QDataStream stream(&byteArray, QIODevice::ReadOnly);
3028  stream.setByteOrder(QDataStream::LittleEndian);
3029 
3030  Statistics tempStats;
3031  stream >> tempStats;
3032  m_rmsImageLineResiduals.append(tempStats);
3033  }
3034 
3035  }
3036  catch (H5::GroupIException groupError) {
3037  // don't do anything???
3038  }
3039  }
3040  // IMAGE RESIDUALS LIST
3041  {
3042  dataSetName = resultsGroupName + "/RmsImageResidualsStatistics";
3043  herr_t status = H5Gget_objinfo(resultsGroup.getId(), dataSetName.toLatin1(), 0, NULL);
3044  if (status != 0) {
3045  // group DNE...
3046  qDebug() << "didn't find or couldn't read stats list.";//???
3047  }
3048  try {
3049 
3050  // if this doesn't throw an error, then the group exists???
3051  H5G_stat_t info;
3052  resultsGroup.getObjinfo(dataSetName.toLatin1(), info);
3053 
3054  dataSet = resultsGroup.openDataSet(dataSetName.toLatin1());
3055  H5::DataSpace dataSetSpace = dataSet.getSpace();
3056 
3057  char statsList[dataSet.getStorageSize()];
3058  dataSet.read(statsList, compoundDataType);
3059 
3060  int listLength = dataSetSpace.getSimpleExtentNpoints();
3061  int statsSize = compoundDataType.getSize();
3062  for (int i = 0; i < listLength; i++) {
3063  QByteArray byteArray(&(statsList[i*statsSize]), statsSize);
3064  QDataStream stream(&byteArray, QIODevice::ReadOnly);
3065  stream.setByteOrder(QDataStream::LittleEndian);
3066 
3067  Statistics tempStats;
3068  stream >> tempStats;
3069  m_rmsImageLineResiduals.append(tempStats);
3070  }
3071 
3072  }
3073  catch (H5::GroupIException groupError) {
3074  // don't do anything???
3075  }
3076  }
3077  }
3078  catch (H5::Exception error) { //??? how to improve printed msg using major/minor error codes?
3079  QString msg = "H5 Exception Message: " + QString::fromStdString(error.getDetailMsg());
3080  IException hpfError(IException::Unknown, msg, _FILEINFO_);
3081  msg = "H5 GENERAL exception handler has detected an error when invoking the function "
3082  + QString::fromStdString(error.getFuncName()) + ".";
3083  throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
3084  }
3085  }
3086  catch (IException &e) {
3087  throw IException(e,
3089  "Unable to read bundle results information to an HDF5 group.",
3090  _FILEINFO_);
3091  }
3092  }
3093 }
QDataStream & read(QDataStream &stream)
Reads the data from a QDataStream into the BundleResults object.
void save(QXmlStreamWriter &stream, const Project *project) const
Saves the BundleResults object to an XML file.
void setObservations(BundleObservationVector observations)
Sets the vector of BundleObservations.
double sigmaLongitudeStatisticsRms() const
Returns the RMS of the adjusted longitude sigmas.
This class is a container class for BundleObservations.
double rmsRy() const
Returns the RMS of the y residuals.
int numberHeldImages() const
Returns the number of &#39;held&#39; images.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Writes a starting XML element.
virtual bool characters(const QString &ch)
Adds a QString to the XmlHandler&#39;s internal character data.
BundleObservationVector m_observations
The vector of BundleObservations from BundleAdjust.
QString minSigmaRadiusPointId() const
Returns the minimum sigma radius point id.
void incrementFixedPoints()
Increase the number of &#39;fixed&#39; (ground) points.
Distance m_minSigmaLongitudeDistance
The minimum sigma longitude distance.
The main project for cnetsuite.
Definition: Project.h:105
void setElapsedTime(double time)
Sets the elapsed time for the bundle adjustment.
QVector< Statistics > m_rmsImageYSigmas
&lt; The root mean square image y sigmas.
void setNumberImageParameters(int numberParameters)
Sets the number of image parameters.
int iterations() const
Returns the number of iterations taken by the BundleAdjust.
void setRmsFromSigmaStatistics(double rmsFromSigmaLatStats, double rmsFromSigmaLonStats, double rmsFromSigmaRadStats)
Sets the root mean square values of the adjusted latitiude sigmas, adjusted longitude sigmas...
StatCumProbDistDynCalc * m_cumProRes
This class keeps track of the cumulative probability distribution of residuals (in unweighted pixels)...
QString m_maxSigmaLongitudePointId
The maximum sigma longitude point id.
void setCorrMatCovFileName(FileName name)
Set the covariance file name for the matrix used to calculate the correlation matrix.
This is a container for the correlation matrix that comes from a bundle adjust.
static H5::CompType compoundH5DataType()
H5 compound data type uses the offesets from the QDataStream returned by the write(QDataStream &amp;strea...
Definition: Statistics.cpp:952
FileName covarianceFileName()
Public access for the covariance matrix file name.
File name manipulation and expansion.
Definition: FileName.h:111
void resetNumberConstrainedPointParameters()
Resets the number of contrained point parameters to 0.
QString minSigmaLongitudePointId() const
Returns the minimum sigma longitude point id.
Distance m_minSigmaRadiusDistance
The minimum sigma radius distance.
QSharedPointer< ControlNet > ControlNetQsp
This typedef is for future implementation of target body.
Definition: ControlNet.h:446
const BundleObservationVector & observations() const
Returns a reference to the observations used by the BundleAdjust.
QString maxSigmaRadiusPointId() const
Returns the maximum sigma radius point id.
void printMaximumLikelihoodTierInformation()
Prints out information about which tier the solution is in and the status of the residuals.
void setCorrelationFileName(FileName correlationFileName)
Set the qmap of images and parameters.
QString m_minSigmaLongitudePointId
The minimum sigma longitude point id.
XmlHandler(BundleResults *statistics, Project *project)
Constructs an XmlHandler used to save a BundleResults object.
Distance m_maxSigmaLatitudeDistance
The maximum sigma latitude distance.
void incrementNumberConstrainedImageParameters(int incrementAmount)
Increase the number of constrained image parameters.
FileName correlationFileName()
Public access for the correlation matrix file name.
ControlNetQsp m_outNet
The output control net from BundleAdjust.
QString maxSigmaLongitudePointId() const
Returns the maximum sigma longitude point id.
double value(double cumProb)
Provides the value of the variable that has the given cumulative probility (according the current est...
int numberConstrainedTargetParameters() const
Return the number of constrained target parameters.
double m_rmsSigmaRadiusStats
rms of adjusted Radius sigmas
QVector< Statistics > rmsImageDECSigmas() const
Returns the list of RMS image declination sigma statistics.
int m_numberHeldImages
number of &#39;held&#39; images (define)
void setRmsImageResidualLists(QList< Statistics > rmsImageLineResiduals, QList< Statistics > rmsImageSampleResiduals, QList< Statistics > rmsImageResiduals)
Sets the root mean square image residual Statistics lists.
QString m_maxSigmaLatitudePointId
The maximum sigma latitude point id.
int m_numberConstrainedImageParameters
number of constrained image parameters
double m_radiansToMeters
radian to meters conversion factor for the body
CorrelationMatrix correlationMatrix() const
Returns the Correlation Matrix.
Distance minSigmaLatitudeDistance() const
Returns the minimum sigma latitude distance.
QList< Statistics > m_rmsImageSampleResiduals
List of RMS image sample residual statistics for each image in the bundle.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
void addProbabilityDistributionObservation(double obsValue)
Adds an observation to the cumulative probability distribution of |R^2 residuals|.
void setImagesAndParameters(QMap< QString, QStringList > imagesAndParameters)
Set the qmap of images and parameters.
QString m_maxSigmaRadiusPointId
The maximum sigma radius point id.
QVector< BundleControlPointQsp > m_bundleControlPoints
The vector of BundleControlPoints from BundleAdjust.
QVector< Statistics > m_rmsImageRASigmas
&lt; The root mean square image right ascension sigmas.
void setSigmaLongitudeRange(Distance minLonDist, Distance maxLonDist, QString minLonPointId, QString maxLonPointId)
Sets the min and max sigma longitude distances and point ids.
double sigma0() const
Returns the Sigma0 of the bundle adjustment.
double m_rmsYResiduals
rms of y residuals
int numberImageParameters() const
Returns the total number of image parameters.
void resetNumberConstrainedImageParameters()
Resets the number of constrained image parameters to 0.
int numberIgnoredPoints() const
Returns the number of ignored points.
void maximumLikelihoodSetUp(QList< QPair< MaximumLikelihoodWFunctions::Model, double > > modelsWithQuantiles)
This method steps up the maximum likelihood estimation solution.
QString m_minSigmaRadiusPointId
The minimum sigma radius point id.
double sigmaLatitudeStatisticsRms() const
Returns the RMS of the adjusted latitude sigmas.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
void setOutputControlNet(ControlNetQsp outNet)
Sets the output ControlNet.
void setNumberUnknownParameters(int numberParameters)
Sets the total number of parameters to solve for.
void setElapsedTimeErrorProp(double time)
Sets the elapsed time for error propegation.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
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
Distance measurement, usually in meters.
Definition: Distance.h:47
BundleResults & operator=(const BundleResults &src)
Assignment operator for BundleResults.
double m_rejectionLimit
current rejection limit
double rejectionLimit() const
Returns the rejection limit.
ControlNetQsp outputControlNet() const
Returns a shared pointer to the output control network.
void computeDegreesOfFreedom()
Computes the degrees of freedom of the bundle adjustment and stores it internally.
QVector< Statistics > rmsImageXSigmas() const
Returns the list of RMS image x sigma statistics.
double elapsedTimeErrorProp() const
Returns the elapsed time for error propagation.
QVector< Statistics > m_rmsImageDECSigmas
&lt; The root mean square image declination sigmas.
QVector< BundleControlPointQsp > & bundleControlPoints()
Returns a reference to the BundleControlPoint vector.
double m_rmsXYResiduals
rms of all x and y residuals
StatCumProbDistDynCalc * m_cumPro
This class will be used to calculate the cumulative probability distribution of |R^2 residuals|...
int degreesOfFreedom() const
Returns the degrees of freedom.
StatCumProbDistDynCalc cumulativeProbabilityDistribution() const
Returns the cumulative probability distribution of the |R^2 residuals|.
PvlObject pvlObject()
This method creates a Pvl group with the information necessary to recreate this correlation matrix...
QVector< Statistics > rmsImageTWISTSigmas() const
Returns the list of RMS image twist sigma statistics.
void setMeters(double distanceInMeters)
Set the distance in meters.
Definition: Distance.cpp:108
void setRejectionLimit(double rejectionLimit)
Sets the rejection limit.
int m_numberIgnoredPoints
number of ignored points
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:109
double m_elapsedTime
elapsed time for bundle
This class is used to approximate cumulative probibility distributions of a stream of observations wi...
double meters() const
Get the distance in meters.
Definition: Distance.cpp:97
int numberRejectedObservations() const
Returns the number of observation that were rejected.
int m_numberObservations
number of image coordinate observations
int maximumLikelihoodModelIndex() const
Returns which step the bundle adjustment is on.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Writes an ending XML element.
void setBundleControlPoints(QVector< BundleControlPointQsp > controlPoints)
Sets the bundle control point vector.
StatCumProbDistDynCalc residualsCumulativeProbabilityDistribution() const
Returns the cumulative probability distribution of the residuals used for reporting.
All parameter corrections will be used to determine that the bundle adjustment has converged...
QVector< Statistics > rmsImageYSigmas() const
Returns the list of RMS image y sigma statistics.
int numberFixedPoints() const
Returns the number of &#39;fixed&#39; (ground) points.
int m_numberConstrainedTargetParameters
number of constrained target parameters
void incrementIgnoredPoints()
Increase the number of ignored points.
double m_rmsXResiduals
rms of x residuals
This class is an XmlHandler used to read and write BundleResults objects from and to XML files...
double maximumLikelihoodMedianR2Residuals() const
Returns the median of the |R^2 residuals|.
void incrementNumberConstrainedPointParameters(int incrementAmount)
Increase the number of contrained point parameters.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
double m_elapsedTimeErrorProp
elapsed time for error propagation
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
int m_numberConstrainedPointParameters
number of constrained point parameters
QList< Statistics > rmsImageResiduals() const
Returns the list of RMS image residuals statistics.
A single keyword-value pair.
Definition: PvlKeyword.h:98
double m_maximumLikelihoodMedianR2Residuals
Median of R^2 residuals.
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:126
QVector< Statistics > rmsImageZSigmas() const
Returns the list of RMS image z sigma statistics.
QString maxSigmaLatitudePointId() const
Returns the maximum sigma latitude point id.
void addResidualsProbabilityDistributionObservation(double obsValue)
Adds an observation to the cumulative probability distribution of residuals used for reporting...
int m_numberRejectedObservations
number of rejected image coordinate observations
Distance m_minSigmaLatitudeDistance
The minimum sigma latitude distance.
void resizeSigmaStatisticsVectors(int numberImages)
Resizes all image sigma vectors.
double sigmaRadiusStatisticsRms() const
Returns the RMS of the adjusted raidus sigmas.
void computeSigma0(double dvtpv, BundleSettings::ConvergenceCriteria criteria)
Computes the sigma0 and stores it internally.
Class provides maximum likelihood estimation functions for robust parameter estimation, e.g.
void setNumberRejectedObservations(int numberObservations)
Sets the number of rejected observations.
Distance m_maxSigmaRadiusDistance
The maximum sigma radius distance.
BundleResults(QObject *parent=0)
Constructs a BundleSettings object.
Distance minSigmaRadiusDistance() const
Returns the minimum sigma redius distance.
QList< QPair< MaximumLikelihoodWFunctions, double > > m_maximumLikelihoodFunctions
&lt; The maximum likelihood models and their quantiles.
void initializeResidualsProbabilityDistribution(unsigned int nodes=20)
Initializes or resets the cumulative probability distribution of residuals used for reporting...
int m_iterations
The number of iterations taken by BundleAdjust.
int m_numberUnknownParameters
total number of parameters to solve for
void openH5Group(H5::CommonFG &locationObject, QString locationName)
Reads from an hdf5 group.
void setCorrMatImgsAndParams(QMap< QString, QStringList > imgsAndParams)
Set the images and their associated parameters of the correlation matrix.
QDataStream & write(QDataStream &stream) const
Writes the BundleResults object to a QDataStream.
QString minSigmaLatitudePointId() const
Returns the minimum sigma latitude point id.
CorrelationMatrix * m_correlationMatrix
The correlation matrix from the BundleAdjust.
void initializeProbabilityDistribution(unsigned int nodes=20)
Initializes or resets the cumulative probability distribution of |R^2 residuals|. ...
int m_numberFixedPoints
number of &#39;fixed&#39; (ground) points (define)
bool converged() const
Returns whether or not the bundle adjustment converged.
int numberObservations() const
Returns the number of observations.
void setCovarianceFileName(FileName covarianceFileName)
Set the qmap of images and parameters.
Distance maxSigmaLongitudeDistance() const
Returns the maximum sigma longitude distance.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
int numberConstrainedImageParameters() const
Returns the number of constrained image parameters.
QVector< Statistics > rmsImageRASigmas() const
Returns the list of RMS image right ascension sigma statistics.
void setNumberObservations(int numberObservations)
Sets the number of observations.
int m_maximumLikelihoodIndex
This count keeps track of which stage of the maximum likelihood adjustment the bundle is currently on...
QString m_minSigmaLatitudePointId
The minimum sigma latitude point id.
QVector< Statistics > m_rmsImageZSigmas
&lt; The root mean square image z sigmas.
Distance maxSigmaLatitudeDistance() const
Returns the maximum sigma latitude distance.
int m_degreesOfFreedom
degrees of freedom
void setSigmaLatitudeRange(Distance minLatDist, Distance maxLatDist, QString minLatPointId, QString maxLatPointId)
Sets the min and max sigma latitude distances and point ids.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition: IString.cpp:53
void setRadiansToMeters(double rtm)
Sets the radians to meters conversion constant for the target body.
QList< Statistics > m_rmsImageLineResiduals
List of RMS image line residual statistics for each image in the bundle.
int numberUnknownParameters() const
Returns the number of unknown parameters.
~XmlHandler()
Destroys an XmlHandler.
QList< Statistics > rmsImageSampleResiduals() const
Returns the list of RMS image sample residuals statistics.
void addObs(double obs)
Values for the estimated quantile positions are update as observations are added. ...
void setRmsXYResiduals(double rx, double ry, double rxy)
Sets the root mean square of the x and y residuals.
Isis exception class.
Definition: IException.h:99
void initialize()
Initializes the BundleResults to a default state where all numeric members are set to 0 or another de...
void incrementMaximumLikelihoodModelIndex()
Increases the value that indicates which stage the maximum likelihood adjustment is currently on...
double m_rmsSigmaLatitudeStats
rms of adjusted Latitude sigmas
~BundleResults()
Destroys this BundleResults object.
void incrementHeldImages()
Increases the number of &#39;held&#39; images.
A container class for statistical results from a BundleAdjust solution.
Definition: BundleResults.h:90
Distance maxSigmaRadiusDistance() const
Returns the maximum sigma redius distance.
void resetNumberConstrainedTargetParameters()
Resets the number of constrained target parameters to 0.
PvlObject pvlObject(QString name="BundleResults") const
Saves the BundleResults object as a PvlObject.
double elapsedTime() const
Returns the elapsed time for the bundle adjustment.
QList< Statistics > rmsImageLineResiduals() const
Returns the list of RMS image line residuals statistics.
void setSigmaRadiusRange(Distance minRadDist, Distance maxRadDist, QString minRadPointId, QString maxRadPointId)
Sets the min and max sigma radius distances and point ids.
double rmsRx() const
Returns the RMS of the x residuals.
void setSigma0(double sigma0)
Sets the sigma0.
double m_rmsSigmaLongitudeStats
rms of adjusted Longitude sigmas
static QString modelToString(Model model)
Static method to return a string represtentation for a given MaximumLikelihoodWFunctions::Model enum...
Distance minSigmaLongitudeDistance() const
Returns the minimum sigma longitude distance.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
int m_numberImageParameters
number of image parameters
void incrementNumberConstrainedTargetParameters(int incrementAmount)
Increases the number of constrained target parameters.
void setConverged(bool converged)
Sets if the bundle adjustment converged.
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
void setIterations(int iterations)
Sets the number of iterations taken by the BundleAdjust.
int numberConstrainedPointParameters() const
Returns the number of constrained point parameters.
double radiansToMeters() const
Returns the radians to meters conversion factor for the target body.
Distance m_maxSigmaLongitudeDistance
The maximum sigma longitude distance.
double m_sigma0
std deviation of unit weight
his enables stack-based XML parsing of XML files.
QList< Statistics > m_rmsImageResiduals
RMS image sample and line residual statistics for each image in the bundle.
double rmsRxy() const
Returns the RMS of the x and y residuals.
MaximumLikelihoodWFunctions maximumLikelihoodModelWFunc(int modelIndex) const
Returns the maximum likelihood model at the given index.
QUuid * m_id
A unique ID for this object (useful for others to reference this object when saving to disk)...
ConvergenceCriteria
This enum defines the options for the bundle adjustment&#39;s convergence.
void setDegreesOfFreedom(double degreesOfFreedom)
Sets the degrees of freedom.
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:268
QVector< Statistics > m_rmsImageTWISTSigmas
&lt; The root mean square image twist sigmas.
int numberMaximumLikelihoodModels() const
Returns how many maximum likelihood models were used in the bundle adjustment.
double maximumLikelihoodModelQuantile(int modelIndex) const
Returns the quantile of the maximum likelihood model at the given index.

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:11