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

Save and apply jigsaw adjustments #5419

Merged
merged 17 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we are reading in Jigsaw results we should be able to use the ISIS CSVReader class instead of implementing the reader in Table. I could be missing something about our CSV Reader though.

Something to try when we get back to this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSVReader was kind of a mess. I dont mind re-visiting trying it, originally, we wanted to just write out the blobs using with something like Table -> toBlob -> write(stringstream) -> write to HDF5. But that also was a mess. If we revisit I think trying the blob route would be best. She was able to get it work with a quick ghetto method than I was trying to de-tangle Blob writing with streams. Only spent a day on it, but I was getting a bunch of segfaults and stream errors for whatever reason.

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