Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jigsaw camsolveall #4078

Merged
merged 15 commits into from
Oct 27, 2020
Merged
1 change: 1 addition & 0 deletions isis/src/base/objs/Spice/Spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ namespace Isis {
m_usingAle = true;
}
catch(...) {

// Backup to stadnard ISIS implementation
if (noTables) {
load(kernels["TargetPosition"], noTables);
Expand Down
8 changes: 8 additions & 0 deletions isis/src/control/apps/jigsaw/jigsaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ namespace Isis {
gp += PvlKeyword("Status", "Camera pointing NOT updated");
}
if (log) {
Pvl summary;
std::istringstream iss (bundleAdjustment->iterationSummaryGroup().toStdString());
iss >> summary;

for (auto grpIt = summary.beginGroup(); grpIt!= summary.endGroup(); grpIt++) {
log->addGroup(*grpIt);
}

log->addGroup(gp);
}
delete bundleSolution;
Expand Down
43 changes: 0 additions & 43 deletions isis/src/control/apps/jigsaw/tsts/camsolveAll/Makefile

This file was deleted.

11 changes: 9 additions & 2 deletions isis/src/control/objs/BundleAdjust/BundleAdjust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3062,9 +3062,13 @@ namespace Isis {
std::ostringstream ostr;
ostr << summaryGroup << std::endl;
m_iterationSummary += QString::fromStdString( ostr.str() );
if (m_printSummary) {

if (m_printSummary && iApp != NULL) {
Application::Log(summaryGroup);
}
else {
std::cout << summaryGroup << std::endl;
Kelvinrr marked this conversation as resolved.
Show resolved Hide resolved
}
}


Expand Down Expand Up @@ -3110,7 +3114,10 @@ namespace Isis {
* -Wformat-security warning during the build.
*/
void BundleAdjust::outputBundleStatus(QString status) {
if (QCoreApplication::applicationName() != "ipce") {
if (iApp == NULL) { // in a function call
printf("%s", status.toStdString().c_str());
}
else if (QCoreApplication::applicationName() != "ipce") {
printf("%s", status.toStdString().c_str());
Kelvinrr marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
49 changes: 47 additions & 2 deletions isis/tests/Fixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,53 @@ namespace Isis {
}


void ObservationPair::SetUp() {
FileName labelPathL = FileName("data/observationPair/observationImageL.pvl");
FileName labelPathR = FileName("data/observationPair/observationImageR.pvl");

isdPathL = new FileName("data/observationPair/observationImageL.isd");
isdPathR = new FileName("data/observationPair/observationImageR.isd");

cubeL = new Cube();
cubeR = new Cube();

cubeLPath = tempDir.path() + "/observationPairL.cub";
cubeRPath = tempDir.path() + "/observationPairR.cub";

cubeL->fromIsd(cubeLPath, labelPathL, *isdPathL, "rw");
cubeR->fromIsd(cubeRPath, labelPathR, *isdPathR, "rw");

cubeList = new FileList();
cubeList->append(cubeL->fileName());
cubeList->append(cubeR->fileName());

cubeListFile = tempDir.path() + "/cubes.lis";
cubeList->write(cubeListFile);

cnetPath = "data/observationPair/observationPair.net";
network = new ControlNet();
network->ReadControl(cnetPath);
}


void ObservationPair::TearDown() {
delete cubeList;
delete network;

if (cubeL) {
delete cubeL;
}

if (cubeR) {
delete cubeR;
}

delete isdPathL;
delete isdPathR;
Kelvinrr marked this conversation as resolved.
Show resolved Hide resolved

}


void MroCube::setInstrument(QString ikid, QString instrumentId, QString spacecraftName) {
PvlGroup &kernels = testCube->label()->findObject("IsisCube").findGroup("Kernels");
kernels.findKeyword("NaifFrameCode").setValue(ikid);
Expand Down Expand Up @@ -407,6 +454,4 @@ namespace Isis {
}
}



}
23 changes: 23 additions & 0 deletions isis/tests/Fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ namespace Isis {
void TearDown() override;
};


class ObservationPair : public TempTestingFiles {
protected:

Cube *cubeL;
Cube *cubeR;

QString cubeLPath;
QString cubeRPath;

FileName *isdPathL;
FileName *isdPathR;

FileList *cubeList;
QString cubeListFile;

ControlNet *network;
QString cnetPath;

void SetUp() override;
void TearDown() override;
};

class MroCube : public DefaultCube {
protected:
QString ckPath = "data/mroKernels/mroCK.bc";
Expand Down
146 changes: 146 additions & 0 deletions isis/tests/FunctionalTestsJigsaw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include "Fixtures.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "TestUtilities.h"
#include "ControlNet.h"
#include "Statistics.h"

#include "jigsaw.h"

#include "gtest/gtest.h"

using namespace Isis;

static QString APP_XML = FileName("$ISISROOT/bin/xml/jigsaw.xml").expanded();

TEST_F(ObservationPair, FunctionalTestJigsawCamSolveAll) {
// delete to remove old camera for when cam is updated
delete cubeL;
delete cubeR;

QTemporaryDir prefix;
QString outCnetFileName = prefix.path() + "/outTemp.net";
QVector<QString> args = {"fromlist="+cubeListFile, "cnet="+cnetPath, "onet="+outCnetFileName,
"observations=yes", "update=yes", "Cksolvedegree=3",
"Camsolve=all", "twist=no", "Spsolve=none", "Radius=no", "imagescsv=on", "file_prefix="+prefix.path()+"/"};

UserInterface options(APP_XML, args);

Pvl log;
try {
jigsaw(options, &log);
}
catch (IException &e) {
FAIL() << "Unable to bundle: " << e.what() << std::endl;
}

// images were updated
cubeL = new Cube(cubeLPath, "r");
cubeR = new Cube(cubeRPath, "r");
jessemapel marked this conversation as resolved.
Show resolved Hide resolved

ControlNet oNet;
oNet.ReadControl(outCnetFileName);

EXPECT_NEAR(oNet.AverageResidual(), 0.123132, 0.00001);
EXPECT_NEAR(oNet.GetMaximumResidual(), 0.379967, 0.00001);
ASSERT_EQ(oNet.GetNumIgnoredMeasures(), 0);
ASSERT_EQ(oNet.GetNumValidPoints(), 46);

QList<ControlPoint*> points = oNet.GetPoints();

Statistics xstats;
Statistics ystats;
Statistics zstats;

for (int i = 0; i < points.size(); i++) {
xstats.AddData(points.at(i)->GetAdjustedSurfacePoint().GetX().kilometers());
ystats.AddData(points.at(i)->GetAdjustedSurfacePoint().GetY().kilometers());
zstats.AddData(points.at(i)->GetAdjustedSurfacePoint().GetZ().kilometers());
}
Kelvinrr marked this conversation as resolved.
Show resolved Hide resolved

EXPECT_NEAR(xstats.Average(), 1556.64806314499741, 0.00001);
EXPECT_NEAR(xstats.StandardDeviation(), 10.663072757957551, 0.00001);
EXPECT_NEAR(xstats.Minimum(), 1540.43360835455860, 0.00001);
EXPECT_NEAR(xstats.Maximum(), 1574.6528854394717, 0.00001);

EXPECT_NEAR(ystats.Average(), 98.326253648503553, 0.00001);
EXPECT_NEAR(ystats.StandardDeviation(), 1.3218686492693708, 0.00001);
EXPECT_NEAR(ystats.Minimum(), 96.795117686735381, 0.00001);
EXPECT_NEAR(ystats.Maximum(), 100.04990583087032, 0.00001);

EXPECT_NEAR(zstats.Average(), 763.0309515939565, 0.00001);
EXPECT_NEAR(zstats.StandardDeviation(), 19.783664466904419, 0.00001);
EXPECT_NEAR(zstats.Minimum(), 728.82827218510067, 0.00001);
EXPECT_NEAR(zstats.Maximum(), 793.9672179283682, 0.00001);

Camera *cam = cubeL->camera();
SpiceRotation *rot = cam->instrumentRotation();
std::vector<double> a1;
std::vector<double> a2;
std::vector<double> a3;

rot->GetPolynomial(a1, a2, a3);

EXPECT_NEAR(a1.at(0), 2.16338, 0.0001);
EXPECT_NEAR(a1.at(1), -0.0264475, 0.0001);
EXPECT_NEAR(a1.at(2), 0.00469675, 0.0001);
EXPECT_NEAR(a1.at(3), 0.0210955, 0.0001);

EXPECT_NEAR(a2.at(0), 1.83011, 0.0001);
EXPECT_NEAR(a2.at(1), -0.0244244, 0.0001);
EXPECT_NEAR(a2.at(2), -0.00456569, 0.0001);
EXPECT_NEAR(a2.at(3), 0.00637157, 0.0001);

QFile file(prefix.path() + "/bundleout_images.csv");
if (!file.open(QIODevice::ReadOnly)) {
FAIL() << file.errorString().toStdString();
}

// skip the first two lines, we don't want to compare the header.
file.readLine();
file.readLine();

QString line = file.readLine();
QStringList elems = line.split(",");

// RA(t0) final
EXPECT_NEAR(elems.at(21).toDouble(), 123.9524918, 0.00001);
// RA(t1) final
EXPECT_NEAR(elems.at(26).toDouble(), -1.51532975, 0.00001);
// RA(t2) final
EXPECT_NEAR(elems.at(31).toDouble(), 0.2691039, 0.00001);
// RA(t3) final
EXPECT_NEAR(elems.at(36).toDouble(), 1.208684781, 0.00001);

// DEC(t0) final
EXPECT_NEAR(elems.at(41).toDouble(), 104.8575294, 0.00001);
// DEC(t1) final
EXPECT_NEAR(elems.at(46).toDouble(), -1.399416621, 0.00001);
// DEC(t2) final
EXPECT_NEAR(elems.at(51).toDouble(), -0.26159502200533, 0.00001);
// DEC(t3) final
EXPECT_NEAR(elems.at(56).toDouble(), 0.365064224, 0.00001);


line = file.readLine();
elems = line.split(",");

// RA(t0) final
EXPECT_NEAR(elems.at(21).toDouble(), 121.4164029, 0.00001);
// RA(t1) final
EXPECT_NEAR(elems.at(26).toDouble(), -1.510464718, 0.00001);
// RA(t2) final
EXPECT_NEAR(elems.at(31).toDouble(), 0.253046705, 0.00001);
// RA(t3) final
EXPECT_NEAR(elems.at(36).toDouble(), 1.203832854, 0.00001);

// DEC(t0) final
EXPECT_NEAR(elems.at(41).toDouble(), 106.11241033284, 0.00001);
// DEC(t1) final
EXPECT_NEAR(elems.at(46).toDouble(), -1.4160602752902001, 0.00001);
// DEC(t2) final
EXPECT_NEAR(elems.at(51).toDouble(), -0.26704142, 0.00001);
// DEC(t3) final
EXPECT_NEAR(elems.at(56).toDouble(), 0.365717165, 0.00001);

}
Kelvinrr marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions isis/tests/data/observationPair/observationImageL.isd

Large diffs are not rendered by default.

Loading