Skip to content

Commit

Permalink
Save and apply jigsaw adjustments (#5419)
Browse files Browse the repository at this point in the history
* Current state

* Save and apply bundle values

* Add test

* Update changelog

* Update yaml and fix for loop issue

* Address test failures

* Make adjustment_output and _input optional

* Update workflow, added new param adjustmentout_h5, updated docs

* Add orientation check

* Update doc

* Address test failures

* Address comments
  • Loading branch information
chkim-usgs authored Sep 20, 2024
1 parent dd18e6b commit 778abcb
Show file tree
Hide file tree
Showing 11 changed files with 441 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ release.
- Fixed gllssi2isis to support V1.1 data [#5396](https://github.com/DOI-USGS/ISIS3/issues/5396)

### Added
- Added option to save and apply bundle adjustment values in `jigsaw` [#4474](https://github.com/DOI-USGS/ISIS3/issues/4474)
- Added versioned default values to lrowacphomap's PHOALGO and PHOPARCUBE parameters and updated lrowacphomap to handle them properly. [#5452](https://github.com/DOI-USGS/ISIS3/pull/5452)

## [8.2.0] - 2024-04-18
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- graphviz
- conda-forge::gsl >=2.6, <2.7
- hdf5
- highfive
- icu
- inja
- jama
Expand Down
37 changes: 21 additions & 16 deletions isis/src/base/objs/SpiceRotation/SpiceRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,11 @@ namespace Isis {
const std::vector<double> &coeffAng3,
const Source type) {

if (type == PolyFunctionOverSpice && !m_orientation) {
QString msg = "The quaternion SPICE tables are no longer available. "
"Either re-run spiceinit or set OVEREXISTING to False.";
throw IException(IException::User, msg, _FILEINFO_);
}
NaifStatus::CheckErrors();
Isis::PolynomialUnivariate function1(p_degree);
Isis::PolynomialUnivariate function2(p_degree);
Expand Down Expand Up @@ -3253,7 +3258,7 @@ namespace Isis {
* @see SpiceRotation::SetEphemerisTime
*/
void SpiceRotation::setEphemerisTimeMemcache() {
// If the cache has only one rotation, set it
// If the cache has only one rotation, set it
NaifStatus::CheckErrors();
if (p_cacheTime.size() == 1) {
p_CJ = m_orientation->getRotations()[0].toRotationMatrix();
Expand Down Expand Up @@ -3487,23 +3492,23 @@ namespace Isis {
p_av[index] += cacheVelocity[index];
}

if (angles[0] <= -1 * pi_c()) {
angles[0] += twopi_c();
}
else if (angles[0] > pi_c()) {
angles[0] -= twopi_c();
}
if (angles[0] <= -1 * pi_c()) {
angles[0] += twopi_c();
}
else if (angles[0] > pi_c()) {
angles[0] -= twopi_c();
}

if (angles[2] <= -1 * pi_c()) {
angles[2] += twopi_c();
}
else if (angles[2] > pi_c()) {
angles[2] -= twopi_c();
}
if (angles[2] <= -1 * pi_c()) {
angles[2] += twopi_c();
}
else if (angles[2] > pi_c()) {
angles[2] -= twopi_c();
}

eul2m_c((SpiceDouble) angles[2], (SpiceDouble) angles[1], (SpiceDouble) angles[0],
p_axis3, p_axis2, p_axis1,
(SpiceDouble( *)[3]) &p_CJ[0]);
eul2m_c((SpiceDouble) angles[2], (SpiceDouble) angles[1], (SpiceDouble) angles[0],
p_axis3, p_axis2, p_axis1,
(SpiceDouble( *)[3]) &p_CJ[0]);
}


Expand Down
58 changes: 58 additions & 0 deletions isis/src/base/objs/Table/Table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ find files of those names at the top level of this repository. **/
#include "Table.h"

#include <fstream>
#include <sstream>
#include <string>

#include "Blob.h"
Expand Down Expand Up @@ -137,6 +138,63 @@ namespace Isis {
}
}

/**
* This constructor takes in a string to create a Table object.
*
* @param tableName The name of the Table to be read
* @param tableStr The table string
* @param fieldDelimiter The delimiter to separate fields with
*/
Table::Table(const QString &tableName, const std::string &tableString, const char &fieldDelimiter) {
p_name = tableName;

std::stringstream tableStream;
tableStream << tableString;

std::vector<std::string> tableLinesStringList;
std::string line;
while(std::getline(tableStream, line, '\n')) {
tableLinesStringList.push_back(line);
}

int numOfFieldValues = tableLinesStringList.size() - 1; // minus the header line

std::string fieldNamesLineString = tableLinesStringList.front();
std::stringstream fieldNamesStringStream;
fieldNamesStringStream << fieldNamesLineString;

std::vector<QString> fieldNames;
std::string fieldNameString;
while(std::getline(fieldNamesStringStream, fieldNameString, fieldDelimiter)) {
fieldNames.push_back(QString::fromStdString(fieldNameString));
}

// Clear error flags and set pointer back to beginning
tableStream.clear();
tableStream.seekg(0, ios::beg);

// Add records to table
std::string recordString;
int index = 0;
while(std::getline(tableStream, recordString, '\n')) {
// skip first line bc that's the header line
if (index == 0) {
index++;
continue;
}

TableRecord tableRecord(recordString, fieldDelimiter, fieldNames, numOfFieldValues);
p_record = tableRecord;
this->operator+=(tableRecord);
index++;
}

// Add fields
for (int f = 0; f < p_record.Fields(); f++) {
p_label.addGroup(p_record[f].pvlGroup());
}
}


/**
* Initialize a Table from a Blob that has been read from a file.
Expand Down
1 change: 1 addition & 0 deletions isis/src/base/objs/Table/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace Isis {
Table(const QString &tableName, const QString &file,
const Pvl &fileHeader);
Table(const Table &other);
Table(const QString &tableName, const std::string &tableString, const char &fieldDelimiter);
Table &operator=(const Isis::Table &other);

~Table();
Expand Down
26 changes: 25 additions & 1 deletion isis/src/base/objs/TableRecord/TableRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ find files of those names at the top level of this repository. **/
#include "TableRecord.h"

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

Expand All @@ -21,6 +22,29 @@ namespace Isis {
TableRecord::TableRecord(){
}

/**
* TableRecord constructor
*
* @param tableRecordStr Table record string
* @param fieldDelimiter The delimiter to separate fields with
* @param fieldNames Table header names
* @param numOfFieldValues Number of fields (rows)
*/
TableRecord::TableRecord(std::string tableRecordStr, char fieldDelimiter,
std::vector<QString> fieldNames, int numOfFieldValues) {
std::stringstream tableRecordStream;
tableRecordStream << tableRecordStr;

std::string fieldStr;
int i = 0;
while(std::getline(tableRecordStream, fieldStr, fieldDelimiter)) {
TableField tableField(fieldNames[i], TableField::Double);
tableField = std::stod(fieldStr); // convert string to double
this->operator+=(tableField);
i++;
}
}

//! Destroys the TableRecord object
TableRecord::~TableRecord() {
}
Expand Down Expand Up @@ -155,7 +179,7 @@ namespace Isis {
Isis::TableField &field = p_fields[f];
field = (void *)&buf[sbyte];
sbyte += field.bytes();
}
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions isis/src/base/objs/TableRecord/TableRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace Isis {
class TableRecord {
public:
TableRecord();
TableRecord(std::string tableRecordStr, char fieldDelimiter,
std::vector<QString> fieldNames, int numOfFieldValues);
~TableRecord();


Expand Down
Loading

0 comments on commit 778abcb

Please sign in to comment.