Skip to content
Snippets Groups Projects
Commit 0a954716 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by Jesse Mapel
Browse files

Logging added to Ls; couple typo corrections in Framer (#226)

* Logging added to Ls

* Logging added to Ls sensor model, log pointer setter added to head file

* More loggers added to state functions

* Fixe Travis Error

* Fixing Travis Error #2 dump json logging objects

* Travis #3

* Fixed spacing
parent d8434c15
Branches
Tags
No related merge requests found
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include <CorrelationModel.h> #include <CorrelationModel.h>
#include "Distortion.h" #include "Distortion.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
class UsgsAstroLsSensorModel : public csm::RasterGM, virtual public csm::SettableEllipsoid class UsgsAstroLsSensorModel : public csm::RasterGM, virtual public csm::SettableEllipsoid
{ {
public: public:
...@@ -115,6 +118,10 @@ public: ...@@ -115,6 +118,10 @@ public:
std::vector<double> m_covariance; std::vector<double> m_covariance;
int m_imageFlipFlag; int m_imageFlipFlag;
// Define logging pointer and file content
std::string m_logFile;
std::shared_ptr<spdlog::logger> m_logger;
// Hardcoded // Hardcoded
static const std::string _SENSOR_MODEL_NAME; // state date element 0 static const std::string _SENSOR_MODEL_NAME; // state date element 0
...@@ -683,6 +690,9 @@ public: ...@@ -683,6 +690,9 @@ public:
// reference by the given index. // reference by the given index.
//< //<
virtual std::shared_ptr<spdlog::logger> getLogger();
virtual void setLogger(std::shared_ptr<spdlog::logger> logger);
//--- //---
// Uncertainty Propagation // Uncertainty Propagation
......
...@@ -97,7 +97,7 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage(const csm::EcefCoord &g ...@@ -97,7 +97,7 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage(const csm::EcefCoord &g
double desiredPrecision, double desiredPrecision,
double *achievedPrecision, double *achievedPrecision,
csm::WarningList *warnings) const { csm::WarningList *warnings) const {
MESSAGE_LOG(this->m_logger, "Computeing groundToImage(No adjustments) for {}, {}, {}, with desired precision {}", MESSAGE_LOG(this->m_logger, "Computing groundToImage(No adjustments) for {}, {}, {}, with desired precision {}",
groundPt.x, groundPt.y, groundPt.z, desiredPrecision); groundPt.x, groundPt.y, groundPt.z, desiredPrecision);
return groundToImage(groundPt, m_noAdjustments, desiredPrecision, achievedPrecision, warnings); return groundToImage(groundPt, m_noAdjustments, desiredPrecision, achievedPrecision, warnings);
...@@ -121,7 +121,7 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage( ...@@ -121,7 +121,7 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings ) const { csm::WarningList* warnings ) const {
MESSAGE_LOG(this->m_logger, "Computeing groundToImage for {}, {}, {}, with desired precision {}", MESSAGE_LOG(this->m_logger, "Computing groundToImage for {}, {}, {}, with desired precision {}",
groundPt.x, groundPt.y, groundPt.z, desired_precision); groundPt.x, groundPt.y, groundPt.z, desired_precision);
double x = groundPt.x; double x = groundPt.x;
...@@ -171,6 +171,7 @@ csm::ImageCoordCovar UsgsAstroFrameSensorModel::groundToImage(const csm::EcefCoo ...@@ -171,6 +171,7 @@ csm::ImageCoordCovar UsgsAstroFrameSensorModel::groundToImage(const csm::EcefCoo
csm::WarningList *warnings) const { csm::WarningList *warnings) const {
MESSAGE_LOG(this->m_logger, "Computeing groundToImage(Covar) for {}, {}, {}, with desired precision {}", MESSAGE_LOG(this->m_logger, "Computeing groundToImage(Covar) for {}, {}, {}, with desired precision {}",
groundPt.x, groundPt.y, groundPt.z, desiredPrecision); groundPt.x, groundPt.y, groundPt.z, desiredPrecision);
csm::EcefCoord gp; csm::EcefCoord gp;
gp.x = groundPt.x; gp.x = groundPt.x;
gp.y = groundPt.y; gp.y = groundPt.y;
......
...@@ -28,7 +28,11 @@ ...@@ -28,7 +28,11 @@
#include <sstream> #include <sstream>
#include <Error.h> #include <Error.h>
#include <json/json.hpp> #include <json/json.hpp>
#define MESSAGE_LOG(logger, ...) if (logger) { logger->info(__VA_ARGS__); }
using json = nlohmann::json; using json = nlohmann::json;
using namespace std;
const std::string UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME const std::string UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME
= "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL"; = "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL";
...@@ -121,9 +125,13 @@ const csm::param::Type ...@@ -121,9 +125,13 @@ const csm::param::Type
csm::param::FIXED csm::param::FIXED
}; };
//***************************************************************************
// UsgsAstroLineScannerSensorModel::replaceModelState
//***************************************************************************
void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString )
{ {
MESSAGE_LOG(m_logger, "Replacing model state")
reset(); reset();
auto j = json::parse(stateString); auto j = json::parse(stateString);
int num_params = NUM_PARAMETERS; int num_params = NUM_PARAMETERS;
...@@ -134,6 +142,16 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) ...@@ -134,6 +142,16 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString )
m_nLines = j["m_nLines"]; m_nLines = j["m_nLines"];
m_nSamples = j["m_nSamples"]; m_nSamples = j["m_nSamples"];
m_platformFlag = j["m_platformFlag"]; m_platformFlag = j["m_platformFlag"];
MESSAGE_LOG(m_logger, "m_imageIdentifier: {} "
"m_sensorName: {} "
"m_nLines: {} "
"m_nSamples: {} "
"m_platformFlag: {} ",
j["m_imageIdentifier"].dump(),
j["m_sensorName"].dump(),
j["m_nLines"].dump(),
j["m_nSamples"].dump(),
j["m_platformFlag"].dump())
m_intTimeLines = j["m_intTimeLines"].get<std::vector<double>>(); m_intTimeLines = j["m_intTimeLines"].get<std::vector<double>>();
m_intTimeStartTimes = j["m_intTimeStartTimes"].get<std::vector<double>>(); m_intTimeStartTimes = j["m_intTimeStartTimes"].get<std::vector<double>>();
...@@ -144,38 +162,91 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) ...@@ -144,38 +162,91 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString )
m_detectorSampleSumming = j["m_detectorSampleSumming"]; m_detectorSampleSumming = j["m_detectorSampleSumming"];
m_startingSample = j["m_startingDetectorSample"]; m_startingSample = j["m_startingDetectorSample"];
m_ikCode = j["m_ikCode"]; m_ikCode = j["m_ikCode"];
MESSAGE_LOG(m_logger, "m_startingEphemerisTime: {} "
"m_centerEphemerisTime: {} "
"m_detectorSampleSumming: {} "
"m_startingSample: {} "
"m_ikCode: {} ",
j["m_startingEphemerisTime"].dump(),
j["m_centerEphemerisTime"].dump(),
j["m_detectorSampleSumming"].dump(),
j["m_startingSample"].dump(), j["m_ikCode"].dump())
m_focalLength = j["m_focalLength"]; m_focalLength = j["m_focalLength"];
m_zDirection = j["m_zDirection"]; m_zDirection = j["m_zDirection"];
m_distortionType = (DistortionType)j["m_distortionType"].get<int>(); m_distortionType = (DistortionType)j["m_distortionType"].get<int>();
m_opticalDistCoeffs = j["m_opticalDistCoeffs"].get<std::vector<double>>(); m_opticalDistCoeffs = j["m_opticalDistCoeffs"].get<std::vector<double>>();
MESSAGE_LOG(m_logger, "m_focalLength: {} "
"m_zDirection: {} "
"m_distortionType: {} ",
j["m_focalLength"].dump(), j["m_zDirection"].dump(),
j["m_distortionType"].dump())
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
m_iTransS[i] = j["m_iTransS"][i]; m_iTransS[i] = j["m_iTransS"][i];
m_iTransL[i] = j["m_iTransL"][i]; m_iTransL[i] = j["m_iTransL"][i];
} }
m_detectorSampleOrigin = j["m_detectorSampleOrigin"]; m_detectorSampleOrigin = j["m_detectorSampleOrigin"];
m_detectorLineOrigin = j["m_detectorLineOrigin"]; m_detectorLineOrigin = j["m_detectorLineOrigin"];
m_majorAxis = j["m_majorAxis"]; m_majorAxis = j["m_majorAxis"];
m_minorAxis = j["m_minorAxis"]; m_minorAxis = j["m_minorAxis"];
MESSAGE_LOG(m_logger, "m_detectorSampleOrigin: {} "
"m_detectorLineOrigin: {} "
"m_majorAxis: {} "
"m_minorAxis: {} ",
j["m_detectorSampleOrigin"].dump(),
j["m_detectorLineOrigin"].dump(),
j["m_majorAxis"].dump(), j["m_minorAxis"].dump())
m_platformIdentifier = j["m_platformIdentifier"]; m_platformIdentifier = j["m_platformIdentifier"];
m_sensorIdentifier = j["m_sensorIdentifier"]; m_sensorIdentifier = j["m_sensorIdentifier"];
MESSAGE_LOG(m_logger, "m_platformIdentifier: {} "
"m_sensorIdentifier: {} ",
j["m_platformIdentifier"].dump(),
j["m_sensorIdentifier"].dump())
m_minElevation = j["m_minElevation"]; m_minElevation = j["m_minElevation"];
m_maxElevation = j["m_maxElevation"]; m_maxElevation = j["m_maxElevation"];
MESSAGE_LOG(m_logger, "m_minElevation: {} "
"m_maxElevation: {} ",
j["m_minElevation"].dump(),
j["m_maxElevation"].dump())
m_dtEphem = j["m_dtEphem"]; m_dtEphem = j["m_dtEphem"];
m_t0Ephem = j["m_t0Ephem"]; m_t0Ephem = j["m_t0Ephem"];
m_dtQuat = j["m_dtQuat"]; m_dtQuat = j["m_dtQuat"];
m_t0Quat = j["m_t0Quat"]; m_t0Quat = j["m_t0Quat"];
m_numPositions = j["m_numPositions"]; m_numPositions = j["m_numPositions"];
MESSAGE_LOG(m_logger, "m_dtEphem: {} "
"m_t0Ephem: {} "
"m_dtQuat: {} "
"m_t0Quat: {} ",
j["m_dtEphem"].dump(), j["m_t0Ephem"].dump(),
j["m_dtQuat"].dump(), j["m_t0Quat"].dump())
m_numQuaternions = j["m_numQuaternions"]; m_numQuaternions = j["m_numQuaternions"];
m_referencePointXyz.x = j["m_referencePointXyz"][0]; m_referencePointXyz.x = j["m_referencePointXyz"][0];
m_referencePointXyz.y = j["m_referencePointXyz"][1]; m_referencePointXyz.y = j["m_referencePointXyz"][1];
m_referencePointXyz.z = j["m_referencePointXyz"][2]; m_referencePointXyz.z = j["m_referencePointXyz"][2];
MESSAGE_LOG(m_logger, "m_numQuaternions: {} "
"m_referencePointX: {} "
"m_referencePointY: {} "
"m_referencePointZ: {} ",
j["m_numQuaternions"].dump(), j["m_referencePointXyz"][0].dump(),
j["m_referencePointXyz"][1].dump(),
j["m_referencePointXyz"][2].dump())
m_gsd = j["m_gsd"]; m_gsd = j["m_gsd"];
m_flyingHeight = j["m_flyingHeight"]; m_flyingHeight = j["m_flyingHeight"];
m_halfSwath = j["m_halfSwath"]; m_halfSwath = j["m_halfSwath"];
m_halfTime = j["m_halfTime"]; m_halfTime = j["m_halfTime"];
MESSAGE_LOG(m_logger, "m_gsd: {} "
"m_flyingHeight: {} "
"m_halfSwath: {} "
"m_halfTime: {} ",
j["m_gsd"].dump(), j["m_flyingHeight"].dump(),
j["m_halfSwath"].dump(), j["m_halfTime"].dump())
// Vector = is overloaded so explicit get with type required. // Vector = is overloaded so explicit get with type required.
m_positions = j["m_positions"].get<std::vector<double>>(); m_positions = j["m_positions"].get<std::vector<double>>();
...@@ -184,6 +255,17 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) ...@@ -184,6 +255,17 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString )
m_currentParameterValue = j["m_currentParameterValue"].get<std::vector<double>>(); m_currentParameterValue = j["m_currentParameterValue"].get<std::vector<double>>();
m_covariance = j["m_covariance"].get<std::vector<double>>(); m_covariance = j["m_covariance"].get<std::vector<double>>();
m_logFile = j["m_logFile"].get<std::string>();
if (m_logFile.empty()) {
m_logger.reset();
}
else {
m_logger = spdlog::get(m_logFile);
if (!m_logger) {
m_logger = spdlog::basic_logger_mt(m_logFile, m_logFile);
}
}
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
for (int k = 0; k < NUM_PARAM_TYPES; k++) { for (int k = 0; k < NUM_PARAM_TYPES; k++) {
if (j["m_parameterType"][i] == PARAM_STRING_ALL[k]) { if (j["m_parameterType"][i] == PARAM_STRING_ALL[k]) {
...@@ -209,6 +291,9 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) ...@@ -209,6 +291,9 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString )
} }
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getModelNameFromModelState
//***************************************************************************
std::string UsgsAstroLsSensorModel::getModelNameFromModelState( std::string UsgsAstroLsSensorModel::getModelNameFromModelState(
const std::string& model_state) const std::string& model_state)
{ {
...@@ -236,7 +321,12 @@ std::string UsgsAstroLsSensorModel::getModelNameFromModelState( ...@@ -236,7 +321,12 @@ std::string UsgsAstroLsSensorModel::getModelNameFromModelState(
return model_name; return model_name;
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getModelState
//***************************************************************************
std::string UsgsAstroLsSensorModel::getModelState() const { std::string UsgsAstroLsSensorModel::getModelState() const {
MESSAGE_LOG(m_logger, "Running getModelState")
json state; json state;
state["m_modelName"] = _SENSOR_MODEL_NAME; state["m_modelName"] = _SENSOR_MODEL_NAME;
state["m_startingDetectorSample"] = m_startingSample; state["m_startingDetectorSample"] = m_startingSample;
...@@ -245,55 +335,124 @@ std::string UsgsAstroLsSensorModel::getModelState() const { ...@@ -245,55 +335,124 @@ std::string UsgsAstroLsSensorModel::getModelState() const {
state["m_nLines"] = m_nLines; state["m_nLines"] = m_nLines;
state["m_nSamples"] = m_nSamples; state["m_nSamples"] = m_nSamples;
state["m_platformFlag"] = m_platformFlag; state["m_platformFlag"] = m_platformFlag;
MESSAGE_LOG(m_logger, "m_imageIdentifier: {} "
"m_sensorName: {} "
"m_nLines: {} "
"m_nSamples: {} "
"m_platformFlag: {} ",
m_imageIdentifier, m_sensorName,
m_nLines, m_nSamples, m_platformFlag)
state["m_intTimeLines"] = m_intTimeLines; state["m_intTimeLines"] = m_intTimeLines;
state["m_intTimeStartTimes"] = m_intTimeStartTimes; state["m_intTimeStartTimes"] = m_intTimeStartTimes;
state["m_intTimes"] = m_intTimes; state["m_intTimes"] = m_intTimes;
state["m_startingEphemerisTime"] = m_startingEphemerisTime; state["m_startingEphemerisTime"] = m_startingEphemerisTime;
state["m_centerEphemerisTime"] = m_centerEphemerisTime; state["m_centerEphemerisTime"] = m_centerEphemerisTime;
MESSAGE_LOG(m_logger, "m_startingEphemerisTime: {} "
"m_centerEphemerisTime: {} ",
m_startingEphemerisTime,
m_centerEphemerisTime)
state["m_detectorSampleSumming"] = m_detectorSampleSumming; state["m_detectorSampleSumming"] = m_detectorSampleSumming;
state["m_startingSample"] = m_startingSample; state["m_startingSample"] = m_startingSample;
state["m_ikCode"] = m_ikCode; state["m_ikCode"] = m_ikCode;
MESSAGE_LOG(m_logger, "m_detectorSampleSumming: {} "
"m_startingSample: {} "
"m_ikCode: {} ",
m_detectorSampleSumming, m_startingSample,
m_ikCode)
state["m_focalLength"] = m_focalLength; state["m_focalLength"] = m_focalLength;
state["m_zDirection"] = m_zDirection; state["m_zDirection"] = m_zDirection;
state["m_distortionType"] = m_distortionType; state["m_distortionType"] = m_distortionType;
state["m_opticalDistCoeffs"] = m_opticalDistCoeffs; state["m_opticalDistCoeffs"] = m_opticalDistCoeffs;
MESSAGE_LOG(m_logger, "m_focalLength: {} "
"m_zDirection: {} "
"m_distortionType (0-Radial, 1-Transverse): {} ",
m_focalLength, m_zDirection,
m_distortionType)
state["m_iTransS"] = std::vector<double>(m_iTransS, m_iTransS+3); state["m_iTransS"] = std::vector<double>(m_iTransS, m_iTransS+3);
state["m_iTransL"] = std::vector<double>(m_iTransL, m_iTransL+3); state["m_iTransL"] = std::vector<double>(m_iTransL, m_iTransL+3);
state["m_detectorSampleOrigin"] = m_detectorSampleOrigin; state["m_detectorSampleOrigin"] = m_detectorSampleOrigin;
state["m_detectorLineOrigin"] = m_detectorLineOrigin; state["m_detectorLineOrigin"] = m_detectorLineOrigin;
state["m_majorAxis"] = m_majorAxis; state["m_majorAxis"] = m_majorAxis;
state["m_minorAxis"] = m_minorAxis; state["m_minorAxis"] = m_minorAxis;
MESSAGE_LOG(m_logger, "m_detectorSampleOrigin: {} "
"m_detectorLineOrigin: {} "
"m_majorAxis: {} "
"m_minorAxis: {} ",
m_detectorSampleOrigin, m_detectorLineOrigin,
m_majorAxis, m_minorAxis)
state["m_platformIdentifier"] = m_platformIdentifier; state["m_platformIdentifier"] = m_platformIdentifier;
state["m_sensorIdentifier"] = m_sensorIdentifier; state["m_sensorIdentifier"] = m_sensorIdentifier;
state["m_minElevation"] = m_minElevation; state["m_minElevation"] = m_minElevation;
state["m_maxElevation"] = m_maxElevation; state["m_maxElevation"] = m_maxElevation;
MESSAGE_LOG(m_logger, "m_platformIdentifier: {} "
"m_sensorIdentifier: {} "
"m_minElevation: {} "
"m_maxElevation: {} ",
m_platformIdentifier, m_sensorIdentifier,
m_minElevation, m_maxElevation)
state["m_dtEphem"] = m_dtEphem; state["m_dtEphem"] = m_dtEphem;
state["m_t0Ephem"] = m_t0Ephem; state["m_t0Ephem"] = m_t0Ephem;
state["m_dtQuat"] = m_dtQuat; state["m_dtQuat"] = m_dtQuat;
state["m_t0Quat"] = m_t0Quat; state["m_t0Quat"] = m_t0Quat;
MESSAGE_LOG(m_logger, "m_dtEphem: {} "
"m_t0Ephem: {} "
"m_dtQuat: {} "
"m_t0Quat: {} ",
m_dtEphem, m_t0Ephem,
m_dtQuat, m_t0Quat)
state["m_numPositions"] = m_numPositions; state["m_numPositions"] = m_numPositions;
state["m_numQuaternions"] = m_numQuaternions; state["m_numQuaternions"] = m_numQuaternions;
state["m_positions"] = m_positions; state["m_positions"] = m_positions;
state["m_velocities"] = m_velocities; state["m_velocities"] = m_velocities;
state["m_quaternions"] = m_quaternions; state["m_quaternions"] = m_quaternions;
MESSAGE_LOG(m_logger, "m_numPositions: {} "
"m_numQuaternions: {} ",
m_numPositions, m_numQuaternions)
state["m_currentParameterValue"] = m_currentParameterValue; state["m_currentParameterValue"] = m_currentParameterValue;
state["m_parameterType"] = m_parameterType; state["m_parameterType"] = m_parameterType;
state["m_gsd"] = m_gsd; state["m_gsd"] = m_gsd;
state["m_flyingHeight"] = m_flyingHeight; state["m_flyingHeight"] = m_flyingHeight;
state["m_halfSwath"] = m_halfSwath; state["m_halfSwath"] = m_halfSwath;
state["m_halfTime"] = m_halfTime; state["m_halfTime"] = m_halfTime;
state["m_covariance"] = m_covariance; state["m_covariance"] = m_covariance;
MESSAGE_LOG(m_logger, "m_gsd: {} "
"m_flyingHeight: {} "
"m_halfSwath: {} "
"m_halfTime: {} ",
m_gsd, m_flyingHeight,
m_halfSwath, m_halfTime)
state["m_referencePointXyz"] = json(); state["m_referencePointXyz"] = json();
state["m_referencePointXyz"][0] = m_referencePointXyz.x; state["m_referencePointXyz"][0] = m_referencePointXyz.x;
state["m_referencePointXyz"][1] = m_referencePointXyz.y; state["m_referencePointXyz"][1] = m_referencePointXyz.y;
state["m_referencePointXyz"][2] = m_referencePointXyz.z; state["m_referencePointXyz"][2] = m_referencePointXyz.z;
MESSAGE_LOG(m_logger, "m_referencePointXyz: {} "
"m_referencePointXyz: {} "
"m_referencePointXyz: {} ",
m_referencePointXyz.x, m_referencePointXyz.y,
m_referencePointXyz.z)
state["m_logFile"] = m_logFile;
return state.dump(); return state.dump();
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::reset
//***************************************************************************
void UsgsAstroLsSensorModel::reset() void UsgsAstroLsSensorModel::reset()
{ {
MESSAGE_LOG(m_logger, "Running reset()")
_linear = false; // default until a linear model is made _linear = false; // default until a linear model is made
_u0 = 0.0; _u0 = 0.0;
_du_dx = 0.0; _du_dx = 0.0;
...@@ -359,8 +518,10 @@ void UsgsAstroLsSensorModel::reset() ...@@ -359,8 +518,10 @@ void UsgsAstroLsSensorModel::reset()
m_halfTime = 10.0; m_halfTime = 10.0;
m_covariance = std::vector<double>(NUM_PARAMETERS * NUM_PARAMETERS,0.0); // 52 m_covariance = std::vector<double>(NUM_PARAMETERS * NUM_PARAMETERS,0.0); // 52
}
m_logFile = "";
m_logger.reset();
}
//***************************************************************************** //*****************************************************************************
// UsgsAstroLsSensorModel Constructor // UsgsAstroLsSensorModel Constructor
...@@ -385,13 +546,20 @@ void UsgsAstroLsSensorModel::updateState() ...@@ -385,13 +546,20 @@ void UsgsAstroLsSensorModel::updateState()
{ {
// If sensor model is being created for the first time // If sensor model is being created for the first time
// This routine will set some parameters not found in the ISD. // This routine will set some parameters not found in the ISD.
MESSAGE_LOG(m_logger, "Updating State")
// Reference point (image center) // Reference point (image center)
double lineCtr = m_nLines / 2.0; double lineCtr = m_nLines / 2.0;
double sampCtr = m_nSamples / 2.0; double sampCtr = m_nSamples / 2.0;
csm::ImageCoord ip(lineCtr, sampCtr); csm::ImageCoord ip(lineCtr, sampCtr);
MESSAGE_LOG(m_logger, "updateState: center image coordinate set to {} {}",
lineCtr, sampCtr)
double refHeight = 0; double refHeight = 0;
m_referencePointXyz = imageToGround(ip, refHeight); m_referencePointXyz = imageToGround(ip, refHeight);
MESSAGE_LOG(m_logger, "updateState: reference point (x, y, z) {} {} {}",
m_referencePointXyz.x, m_referencePointXyz.y,
m_referencePointXyz.z)
// Compute ground sample distance // Compute ground sample distance
ip.line += 1; ip.line += 1;
ip.samp += 1; ip.samp += 1;
...@@ -400,6 +568,9 @@ void UsgsAstroLsSensorModel::updateState() ...@@ -400,6 +568,9 @@ void UsgsAstroLsSensorModel::updateState()
double dy = delta.y - m_referencePointXyz.y; double dy = delta.y - m_referencePointXyz.y;
double dz = delta.z - m_referencePointXyz.z; double dz = delta.z - m_referencePointXyz.z;
m_gsd = sqrt((dx*dx + dy*dy + dz*dz) / 2.0); m_gsd = sqrt((dx*dx + dy*dy + dz*dz) / 2.0);
MESSAGE_LOG(m_logger, "updateState: ground sample distance set to {} "
"based on dx {} dy {} dz {}",
m_gsd, dx, dy, dz)
// Compute flying height // Compute flying height
csm::EcefCoord sensorPos = getSensorPosition(0.0); csm::EcefCoord sensorPos = getSensorPosition(0.0);
...@@ -407,14 +578,21 @@ void UsgsAstroLsSensorModel::updateState() ...@@ -407,14 +578,21 @@ void UsgsAstroLsSensorModel::updateState()
dy = sensorPos.y - m_referencePointXyz.y; dy = sensorPos.y - m_referencePointXyz.y;
dz = sensorPos.z - m_referencePointXyz.z; dz = sensorPos.z - m_referencePointXyz.z;
m_flyingHeight = sqrt(dx*dx + dy*dy + dz*dz); m_flyingHeight = sqrt(dx*dx + dy*dy + dz*dz);
MESSAGE_LOG(m_logger, "updateState: flight height set to {}"
"based on dx {} dy {} dz {}",
m_flyingHeight, dx, dy, dz)
// Compute half swath // Compute half swath
m_halfSwath = m_gsd * m_nSamples / 2.0; m_halfSwath = m_gsd * m_nSamples / 2.0;
MESSAGE_LOG(m_logger, "updateState: half swath set to {}",
m_halfSwath)
// Compute half time duration // Compute half time duration
double fullImageTime = m_intTimeStartTimes.back() - m_intTimeStartTimes.front() double fullImageTime = m_intTimeStartTimes.back() - m_intTimeStartTimes.front()
+ m_intTimes.back() * (m_nLines - m_intTimeLines.back()); + m_intTimes.back() * (m_nLines - m_intTimeLines.back());
m_halfTime = fullImageTime / 2.0; m_halfTime = fullImageTime / 2.0;
MESSAGE_LOG(m_logger, "updateState: half time duration set to {}",
m_halfTime)
// Parameter covariance, hardcoded accuracy values // Parameter covariance, hardcoded accuracy values
int num_params = NUM_PARAMETERS; int num_params = NUM_PARAMETERS;
...@@ -444,6 +622,10 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( ...@@ -444,6 +622,10 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing groundToImage(No adjustments) for {}, {}, {}, with desired precision {}",
ground_pt.x, ground_pt.y, ground_pt.z, desired_precision);
// The public interface invokes the private interface with no adjustments. // The public interface invokes the private interface with no adjustments.
return groundToImage( return groundToImage(
ground_pt, _no_adjustment, ground_pt, _no_adjustment,
...@@ -460,6 +642,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( ...@@ -460,6 +642,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing groundToImage (with adjustments) for {}, {}, {}, with desired precision {}",
ground_pt.x, ground_pt.y, ground_pt.z, desired_precision);
// Search for the line, sample coordinate that viewed a given ground point. // Search for the line, sample coordinate that viewed a given ground point.
// This method uses an iterative secant method to search for the image // This method uses an iterative secant method to search for the image
// line. // line.
...@@ -587,6 +771,8 @@ csm::ImageCoordCovar UsgsAstroLsSensorModel::groundToImage( ...@@ -587,6 +771,8 @@ csm::ImageCoordCovar UsgsAstroLsSensorModel::groundToImage(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing groundToImage(Covar) for {}, {}, {}, with desired precision {}",
groundPt.x, groundPt.y, groundPt.z, desired_precision);
// Ground to image with error propagation // Ground to image with error propagation
// Compute corresponding image point // Compute corresponding image point
csm::EcefCoord gp; csm::EcefCoord gp;
...@@ -658,6 +844,9 @@ csm::EcefCoord UsgsAstroLsSensorModel::imageToGround( ...@@ -658,6 +844,9 @@ csm::EcefCoord UsgsAstroLsSensorModel::imageToGround(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing imageToGround for {}, {}, {}, with desired precision {}",
image_pt.line, image_pt.samp, height, desired_precision);
double xc, yc, zc; double xc, yc, zc;
double vx, vy, vz; double vx, vy, vz;
double xl, yl, zl; double xl, yl, zl;
...@@ -683,14 +872,25 @@ csm::EcefCoord UsgsAstroLsSensorModel::imageToGround( ...@@ -683,14 +872,25 @@ csm::EcefCoord UsgsAstroLsSensorModel::imageToGround(
"UsgsAstroLsSensorModel::imageToGround()")); "UsgsAstroLsSensorModel::imageToGround()"));
} }
/*
MESSAGE_LOG(m_logger, "imageToGround for {} {} {} achieved precision {}",
image_pt.line, image_pt.samp, height, achieved_precision)
*/
return csm::EcefCoord(x, y, z); return csm::EcefCoord(x, y, z);
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::determineSensorCovarianceInImageSpace
//***************************************************************************
void UsgsAstroLsSensorModel::determineSensorCovarianceInImageSpace( void UsgsAstroLsSensorModel::determineSensorCovarianceInImageSpace(
csm::EcefCoord &gp, csm::EcefCoord &gp,
double sensor_cov[4] ) const double sensor_cov[4] ) const
{ {
MESSAGE_LOG(m_logger, "Calculating determineSensorCovarianceInImageSpace for {} {} {}",
gp.x, gp.y, gp.z)
int i, j, totalAdjParams; int i, j, totalAdjParams;
totalAdjParams = getNumParameters(); totalAdjParams = getNumParameters();
...@@ -725,6 +925,8 @@ csm::EcefCoordCovar UsgsAstroLsSensorModel::imageToGround( ...@@ -725,6 +925,8 @@ csm::EcefCoordCovar UsgsAstroLsSensorModel::imageToGround(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Calculating imageToGround (with error propagation) for {}, {}, {} with height varinace {} and desired precision {}",
image_pt.line, image_pt.samp, height, heightVariance, desired_precision)
// Image to ground with error propagation // Image to ground with error propagation
// Use numerical partials // Use numerical partials
...@@ -810,6 +1012,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToProximateImagingLocus( ...@@ -810,6 +1012,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToProximateImagingLocus(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing imageToProximateImagingLocus (ground {}, {}, {}) for image point {}, {} with desired precision {}",
ground_pt.x, ground_pt.y, ground_pt.z, image_pt.line, image_pt.samp, desired_precision);
// Object ray unit direction near given ground location // Object ray unit direction near given ground location
const double DELTA_GROUND = m_gsd; const double DELTA_GROUND = m_gsd;
...@@ -871,6 +1077,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToRemoteImagingLocus( ...@@ -871,6 +1077,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToRemoteImagingLocus(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Calculating imageToRemoteImagingLocus for point {}, {} with desired precision {}",
image_pt.line, image_pt.samp, desired_precision)
double vx, vy, vz; double vx, vy, vz;
csm::EcefLocus locus; csm::EcefLocus locus;
losToEcf( losToEcf(
...@@ -895,6 +1105,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToRemoteImagingLocus( ...@@ -895,6 +1105,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToRemoteImagingLocus(
std::vector<double> UsgsAstroLsSensorModel::computeGroundPartials( std::vector<double> UsgsAstroLsSensorModel::computeGroundPartials(
const csm::EcefCoord& ground_pt) const const csm::EcefCoord& ground_pt) const
{ {
MESSAGE_LOG(m_logger, "Computing computeGroundPartials for point {}, {}, {}",
ground_pt.x, ground_pt.y, ground_pt.z)
double GND_DELTA = m_gsd; double GND_DELTA = m_gsd;
// Partial of line, sample wrt X, Y, Z // Partial of line, sample wrt X, Y, Z
double x = ground_pt.x; double x = ground_pt.x;
...@@ -928,6 +1142,10 @@ csm::RasterGM::SensorPartials UsgsAstroLsSensorModel::computeSensorPartials( ...@@ -928,6 +1142,10 @@ csm::RasterGM::SensorPartials UsgsAstroLsSensorModel::computeSensorPartials(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Calculating computeSensorPartials for ground point {}, {}, {} with desired precision {}",
ground_pt.x, ground_pt.y, ground_pt.z, desired_precision)
// Compute image coordinate first // Compute image coordinate first
csm::ImageCoord img_pt = groundToImage( csm::ImageCoord img_pt = groundToImage(
ground_pt, desired_precision, achieved_precision); ground_pt, desired_precision, achieved_precision);
...@@ -948,6 +1166,10 @@ csm::RasterGM::SensorPartials UsgsAstroLsSensorModel::computeSensorPartials( ...@@ -948,6 +1166,10 @@ csm::RasterGM::SensorPartials UsgsAstroLsSensorModel::computeSensorPartials(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Calculating computeSensorPartials (with image points {}, {}) for ground point {}, {}, {} with desired precision {}",
image_pt.line, image_pt.samp, ground_pt.x, ground_pt.y, ground_pt.z, desired_precision)
// Compute numerical partials ls wrt specific parameter // Compute numerical partials ls wrt specific parameter
const double DELTA = m_gsd; const double DELTA = m_gsd;
...@@ -974,6 +1196,8 @@ UsgsAstroLsSensorModel::computeAllSensorPartials( ...@@ -974,6 +1196,8 @@ UsgsAstroLsSensorModel::computeAllSensorPartials(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing computeAllSensorPartials for ground point {}, {}, {} with desired precision {}",
ground_pt.x, ground_pt.y, ground_pt.z, desired_precision)
csm::ImageCoord image_pt = groundToImage( csm::ImageCoord image_pt = groundToImage(
ground_pt, desired_precision, achieved_precision, warnings); ground_pt, desired_precision, achieved_precision, warnings);
...@@ -993,6 +1217,10 @@ UsgsAstroLsSensorModel::computeAllSensorPartials( ...@@ -993,6 +1217,10 @@ UsgsAstroLsSensorModel::computeAllSensorPartials(
double* achieved_precision, double* achieved_precision,
csm::WarningList* warnings) const csm::WarningList* warnings) const
{ {
MESSAGE_LOG(m_logger, "Computing computeAllSensorPartials for image {} {} and ground {}, {}, {} with desired precision {}",
image_pt.line, image_pt.samp, ground_pt.x, ground_pt.y, ground_pt.z, desired_precision)
std::vector<int> indices = getParameterSetIndices(pSet); std::vector<int> indices = getParameterSetIndices(pSet);
size_t num = indices.size(); size_t num = indices.size();
std::vector<csm::RasterGM::SensorPartials> partials; std::vector<csm::RasterGM::SensorPartials> partials;
...@@ -1013,7 +1241,12 @@ double UsgsAstroLsSensorModel::getParameterCovariance( ...@@ -1013,7 +1241,12 @@ double UsgsAstroLsSensorModel::getParameterCovariance(
int index1, int index1,
int index2) const int index2) const
{ {
int index = UsgsAstroLsSensorModel::NUM_PARAMETERS * index1 + index2; int index = UsgsAstroLsSensorModel::NUM_PARAMETERS * index1 + index2;
MESSAGE_LOG(m_logger, "getParameterCovariance for {} {} is {}",
index1, index2, m_covariance[index])
return m_covariance[index]; return m_covariance[index];
} }
...@@ -1026,6 +1259,10 @@ void UsgsAstroLsSensorModel::setParameterCovariance( ...@@ -1026,6 +1259,10 @@ void UsgsAstroLsSensorModel::setParameterCovariance(
double covariance) double covariance)
{ {
int index = UsgsAstroLsSensorModel::NUM_PARAMETERS * index1 + index2; int index = UsgsAstroLsSensorModel::NUM_PARAMETERS * index1 + index2;
MESSAGE_LOG(m_logger, "setParameterCovariance for {} {} is {}",
index1, index2, m_covariance[index])
m_covariance[index] = covariance; m_covariance[index] = covariance;
} }
...@@ -1058,6 +1295,7 @@ std::string UsgsAstroLsSensorModel::getReferenceDateAndTime() const ...@@ -1058,6 +1295,7 @@ std::string UsgsAstroLsSensorModel::getReferenceDateAndTime() const
double UsgsAstroLsSensorModel::getImageTime( double UsgsAstroLsSensorModel::getImageTime(
const csm::ImageCoord& image_pt) const const csm::ImageCoord& image_pt) const
{ {
// Flip image taken backwards // Flip image taken backwards
double line1 = image_pt.line; double line1 = image_pt.line;
...@@ -1080,6 +1318,9 @@ double UsgsAstroLsSensorModel::getImageTime( ...@@ -1080,6 +1318,9 @@ double UsgsAstroLsSensorModel::getImageTime(
double time = m_intTimeStartTimes[referenceIndex] double time = m_intTimeStartTimes[referenceIndex]
+ m_intTimes[referenceIndex] * (lineUSGSFull - m_intTimeLines[referenceIndex]); + m_intTimes[referenceIndex] * (lineUSGSFull - m_intTimeLines[referenceIndex]);
MESSAGE_LOG(m_logger, "getImageTime for image line {} is {}",
image_pt.line, time)
return time; return time;
} }
...@@ -1090,6 +1331,9 @@ double UsgsAstroLsSensorModel::getImageTime( ...@@ -1090,6 +1331,9 @@ double UsgsAstroLsSensorModel::getImageTime(
csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition( csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition(
const csm::ImageCoord& imagePt) const const csm::ImageCoord& imagePt) const
{ {
MESSAGE_LOG(m_logger, "getSensorPosition at line {}",
imagePt.line)
return getSensorPosition(getImageTime(imagePt)); return getSensorPosition(getImageTime(imagePt));
} }
...@@ -1102,6 +1346,9 @@ csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition(double time) const ...@@ -1102,6 +1346,9 @@ csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition(double time) const
double x, y, z, vx, vy, vz; double x, y, z, vx, vy, vz;
getAdjSensorPosVel(time, _no_adjustment, x, y, z, vx, vy, vz); getAdjSensorPosVel(time, _no_adjustment, x, y, z, vx, vy, vz);
MESSAGE_LOG(m_logger, "getSensorPosition at {}",
time)
return csm::EcefCoord(x, y, z); return csm::EcefCoord(x, y, z);
} }
...@@ -1111,6 +1358,8 @@ csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition(double time) const ...@@ -1111,6 +1358,8 @@ csm::EcefCoord UsgsAstroLsSensorModel::getSensorPosition(double time) const
csm::EcefVector UsgsAstroLsSensorModel::getSensorVelocity( csm::EcefVector UsgsAstroLsSensorModel::getSensorVelocity(
const csm::ImageCoord& imagePt) const const csm::ImageCoord& imagePt) const
{ {
MESSAGE_LOG(m_logger, "getSensorVelocity at {}",
imagePt.line)
return getSensorVelocity(getImageTime(imagePt)); return getSensorVelocity(getImageTime(imagePt));
} }
...@@ -1122,6 +1371,9 @@ csm::EcefVector UsgsAstroLsSensorModel::getSensorVelocity(double time) const ...@@ -1122,6 +1371,9 @@ csm::EcefVector UsgsAstroLsSensorModel::getSensorVelocity(double time) const
double x, y, z, vx, vy, vz; double x, y, z, vx, vy, vz;
getAdjSensorPosVel(time, _no_adjustment, x, y, z, vx, vy, vz); getAdjSensorPosVel(time, _no_adjustment, x, y, z, vx, vy, vz);
MESSAGE_LOG(m_logger, "getSensorVelocity at {}",
time)
return csm::EcefVector(vx, vy, vz); return csm::EcefVector(vx, vy, vz);
} }
...@@ -1379,6 +1631,10 @@ UsgsAstroLsSensorModel::getValidImageRange() const ...@@ -1379,6 +1631,10 @@ UsgsAstroLsSensorModel::getValidImageRange() const
csm::EcefVector UsgsAstroLsSensorModel::getIlluminationDirection( csm::EcefVector UsgsAstroLsSensorModel::getIlluminationDirection(
const csm::EcefCoord& groundPt) const const csm::EcefCoord& groundPt) const
{ {
MESSAGE_LOG(m_logger, "Accessing illimination direction of ground point"
"{} {} {}."
"Illimination direction is not supported, throwing exception",
groundPt.x, groundPt.y, groundPt.z);
throw csm::Error( throw csm::Error(
csm::Error::UNSUPPORTED_FUNCTION, csm::Error::UNSUPPORTED_FUNCTION,
"Unsupported function", "Unsupported function",
...@@ -1400,9 +1656,11 @@ int UsgsAstroLsSensorModel::getNumGeometricCorrectionSwitches() const ...@@ -1400,9 +1656,11 @@ int UsgsAstroLsSensorModel::getNumGeometricCorrectionSwitches() const
//*************************************************************************** //***************************************************************************
// UsgsAstroLsSensorModel::getGeometricCorrectionName // UsgsAstroLsSensorModel::getGeometricCorrectionName
//*************************************************************************** //***************************************************************************
std::string UsgsAstroLsSensorModel::getGeometricCorrectionName(int index) const std::string UsgsAstroLsSensorModel::getGeometricCorrectionName(int index) const
{ {
MESSAGE_LOG(m_logger, "Accessing name of geometric correction switch {}. "
"Geometric correction switches are not supported, throwing exception",
index);
// Since there are no geometric corrections, all indices are out of range // Since there are no geometric corrections, all indices are out of range
throw csm::Error( throw csm::Error(
csm::Error::INDEX_OUT_OF_RANGE, csm::Error::INDEX_OUT_OF_RANGE,
...@@ -1419,6 +1677,10 @@ void UsgsAstroLsSensorModel::setGeometricCorrectionSwitch( ...@@ -1419,6 +1677,10 @@ void UsgsAstroLsSensorModel::setGeometricCorrectionSwitch(
csm::param::Type pType) csm::param::Type pType)
{ {
MESSAGE_LOG(m_logger, "Setting geometric correction switch {} to {} "
"with parameter type {}. "
"Geometric correction switches are not supported, throwing exception",
index, value, pType);
// Since there are no geometric corrections, all indices are out of range // Since there are no geometric corrections, all indices are out of range
throw csm::Error( throw csm::Error(
csm::Error::INDEX_OUT_OF_RANGE, csm::Error::INDEX_OUT_OF_RANGE,
...@@ -1431,6 +1693,9 @@ void UsgsAstroLsSensorModel::setGeometricCorrectionSwitch( ...@@ -1431,6 +1693,9 @@ void UsgsAstroLsSensorModel::setGeometricCorrectionSwitch(
//*************************************************************************** //***************************************************************************
bool UsgsAstroLsSensorModel::getGeometricCorrectionSwitch(int index) const bool UsgsAstroLsSensorModel::getGeometricCorrectionSwitch(int index) const
{ {
MESSAGE_LOG(m_logger, "Accessing value of geometric correction switch {}. "
"Geometric correction switches are not supported, throwing exception",
index);
// Since there are no geometric corrections, all indices are out of range // Since there are no geometric corrections, all indices are out of range
throw csm::Error( throw csm::Error(
csm::Error::INDEX_OUT_OF_RANGE, csm::Error::INDEX_OUT_OF_RANGE,
...@@ -1455,6 +1720,9 @@ std::vector<double> UsgsAstroLsSensorModel::getCrossCovarianceMatrix( ...@@ -1455,6 +1720,9 @@ std::vector<double> UsgsAstroLsSensorModel::getCrossCovarianceMatrix(
return std::vector<double>(num_rows * num_cols, 0.0); return std::vector<double>(num_rows * num_cols, 0.0);
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getCorrelationModel
//***************************************************************************
const csm::CorrelationModel& const csm::CorrelationModel&
UsgsAstroLsSensorModel::getCorrelationModel() const UsgsAstroLsSensorModel::getCorrelationModel() const
{ {
...@@ -1506,6 +1774,8 @@ bool UsgsAstroLsSensorModel::isParameterShareable(int index) const ...@@ -1506,6 +1774,8 @@ bool UsgsAstroLsSensorModel::isParameterShareable(int index) const
csm::SharingCriteria UsgsAstroLsSensorModel::getParameterSharingCriteria( csm::SharingCriteria UsgsAstroLsSensorModel::getParameterSharingCriteria(
int index) const int index) const
{ {
MESSAGE_LOG(m_logger, "Checking sharing criteria for parameter {}. "
"Sharing is not supported, throwing exception", index);
// Parameter sharing is not supported for this sensor, // Parameter sharing is not supported for this sensor,
// all indices are out of range // all indices are out of range
throw csm::Error( throw csm::Error(
...@@ -1538,7 +1808,9 @@ csm::Version UsgsAstroLsSensorModel::getVersion() const ...@@ -1538,7 +1808,9 @@ csm::Version UsgsAstroLsSensorModel::getVersion() const
return csm::Version(1, 0, 0); return csm::Version(1, 0, 0);
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getEllipsoid
//***************************************************************************
csm::Ellipsoid UsgsAstroLsSensorModel::getEllipsoid() const csm::Ellipsoid UsgsAstroLsSensorModel::getEllipsoid() const
{ {
return csm::Ellipsoid(m_majorAxis, m_minorAxis); return csm::Ellipsoid(m_majorAxis, m_minorAxis);
...@@ -1551,8 +1823,9 @@ void UsgsAstroLsSensorModel::setEllipsoid( ...@@ -1551,8 +1823,9 @@ void UsgsAstroLsSensorModel::setEllipsoid(
m_minorAxis = ellipsoid.getSemiMinorRadius(); m_minorAxis = ellipsoid.getSemiMinorRadius();
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getValue
//***************************************************************************
double UsgsAstroLsSensorModel::getValue( double UsgsAstroLsSensorModel::getValue(
int index, int index,
const std::vector<double> &adjustments) const const std::vector<double> &adjustments) const
...@@ -1564,7 +1837,6 @@ double UsgsAstroLsSensorModel::getValue( ...@@ -1564,7 +1837,6 @@ double UsgsAstroLsSensorModel::getValue(
//*************************************************************************** //***************************************************************************
// Functions pulled out of losToEcf and computeViewingPixel // Functions pulled out of losToEcf and computeViewingPixel
// ************************************************************************** // **************************************************************************
void UsgsAstroLsSensorModel::getQuaternions(const double& time, double q[4]) const{ void UsgsAstroLsSensorModel::getQuaternions(const double& time, double q[4]) const{
int nOrder = 8; int nOrder = 8;
if (m_platformFlag == 0) if (m_platformFlag == 0)
...@@ -1572,16 +1844,24 @@ void UsgsAstroLsSensorModel::getQuaternions(const double& time, double q[4]) con ...@@ -1572,16 +1844,24 @@ void UsgsAstroLsSensorModel::getQuaternions(const double& time, double q[4]) con
int nOrderQuat = nOrder; int nOrderQuat = nOrder;
if (m_numQuaternions < 6 && nOrder == 8) if (m_numQuaternions < 6 && nOrder == 8)
nOrderQuat = 4; nOrderQuat = 4;
MESSAGE_LOG(m_logger, "Calculating getQuaternions for time {} with {}"
"order lagrange",
time, nOrder)
lagrangeInterp( lagrangeInterp(
m_numQuaternions/4, &m_quaternions[0], m_t0Quat, m_dtQuat, time, 4, nOrderQuat, q); m_numQuaternions/4, &m_quaternions[0], m_t0Quat, m_dtQuat, time, 4, nOrderQuat, q);
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::calculateAttitudeCorrection
//***************************************************************************
void UsgsAstroLsSensorModel::calculateAttitudeCorrection( void UsgsAstroLsSensorModel::calculateAttitudeCorrection(
const double& time, const double& time,
const std::vector<double>& adj, const std::vector<double>& adj,
double attCorr[9]) const double attCorr[9]) const
{ {
MESSAGE_LOG(m_logger, "Computing calculateAttitudeCorrection (with adjustment)"
"for time {}", time)
double aTime = time - m_t0Quat; double aTime = time - m_t0Quat;
double euler[3]; double euler[3];
double nTime = aTime / m_halfTime; double nTime = aTime / m_halfTime;
...@@ -1592,6 +1872,8 @@ void UsgsAstroLsSensorModel::calculateAttitudeCorrection( ...@@ -1592,6 +1872,8 @@ void UsgsAstroLsSensorModel::calculateAttitudeCorrection(
(getValue(7, adj) + getValue(10, adj)* nTime + getValue(13, adj)* nTime2) / m_flyingHeight; (getValue(7, adj) + getValue(10, adj)* nTime + getValue(13, adj)* nTime2) / m_flyingHeight;
euler[2] = euler[2] =
(getValue(8, adj) + getValue(11, adj)* nTime + getValue(14, adj)* nTime2) / m_halfSwath; (getValue(8, adj) + getValue(11, adj)* nTime + getValue(14, adj)* nTime2) / m_halfSwath;
MESSAGE_LOG(m_logger, "calculateAttitudeCorrection: euler {} {} {}",
euler[0], euler[1], euler[2])
calculateRotationMatrixFromEuler(euler, attCorr); calculateRotationMatrixFromEuler(euler, attCorr);
} }
...@@ -1617,6 +1899,9 @@ void UsgsAstroLsSensorModel::losToEcf( ...@@ -1617,6 +1899,9 @@ void UsgsAstroLsSensorModel::losToEcf(
//# private_func_description //# private_func_description
// Computes image ray (look vector) in ecf coordinate system. // Computes image ray (look vector) in ecf coordinate system.
// Compute adjusted sensor position and velocity // Compute adjusted sensor position and velocity
MESSAGE_LOG(m_logger, "Computing losToEcf (with adjustments) for"
"line {} sample {}",
line, sample)
double time = getImageTime(csm::ImageCoord(line, sample)); double time = getImageTime(csm::ImageCoord(line, sample));
getAdjSensorPosVel(time, adj, xc, yc, zc, vx, vy, vz); getAdjSensorPosVel(time, adj, xc, yc, zc, vx, vy, vz);
...@@ -1636,7 +1921,7 @@ void UsgsAstroLsSensorModel::losToEcf( ...@@ -1636,7 +1921,7 @@ void UsgsAstroLsSensorModel::losToEcf(
m_iTransS, m_iTransL, m_iTransS, m_iTransL,
distortedFocalPlaneX, distortedFocalPlaneY); distortedFocalPlaneX, distortedFocalPlaneY);
// Remove lens distortion // Remove lens
double undistortedFocalPlaneX, undistortedFocalPlaneY; double undistortedFocalPlaneX, undistortedFocalPlaneY;
removeDistortion(distortedFocalPlaneX, distortedFocalPlaneY, removeDistortion(distortedFocalPlaneX, distortedFocalPlaneY,
undistortedFocalPlaneX, undistortedFocalPlaneY, undistortedFocalPlaneX, undistortedFocalPlaneY,
...@@ -1661,7 +1946,9 @@ void UsgsAstroLsSensorModel::losToEcf( ...@@ -1661,7 +1946,9 @@ void UsgsAstroLsSensorModel::losToEcf(
correctedCameraLook[2] = attCorr[6] * cameraLook[0] correctedCameraLook[2] = attCorr[6] * cameraLook[0]
+ attCorr[7] * cameraLook[1] + attCorr[7] * cameraLook[1]
+ attCorr[8] * cameraLook[2]; + attCorr[8] * cameraLook[2];
MESSAGE_LOG(m_logger, "losToEcf: corrected camera look vector {} {} {}",
correctedCameraLook[0], correctedCameraLook[1],
correctedCameraLook[2])
// Rotate the look vector into the body fixed frame from the camera reference frame by applying the rotation matrix from the sensor quaternions // Rotate the look vector into the body fixed frame from the camera reference frame by applying the rotation matrix from the sensor quaternions
double quaternions[4]; double quaternions[4];
getQuaternions(time, quaternions); getQuaternions(time, quaternions);
...@@ -1677,6 +1964,9 @@ void UsgsAstroLsSensorModel::losToEcf( ...@@ -1677,6 +1964,9 @@ void UsgsAstroLsSensorModel::losToEcf(
bodyLookZ = cameraToBody[6] * correctedCameraLook[0] bodyLookZ = cameraToBody[6] * correctedCameraLook[0]
+ cameraToBody[7] * correctedCameraLook[1] + cameraToBody[7] * correctedCameraLook[1]
+ cameraToBody[8] * correctedCameraLook[2]; + cameraToBody[8] * correctedCameraLook[2];
MESSAGE_LOG(m_logger, "losToEcf: body look vector {} {} {}",
bodyLookX, bodyLookY, bodyLookZ)
} }
...@@ -1694,6 +1984,9 @@ void UsgsAstroLsSensorModel::lightAberrationCorr( ...@@ -1694,6 +1984,9 @@ void UsgsAstroLsSensorModel::lightAberrationCorr(
double& dyl, double& dyl,
double& dzl) const double& dzl) const
{ {
MESSAGE_LOG(m_logger, "Computing lightAberrationCorr for camera velocity"
"{} {} {} and image ray {} {} {}",
vx, vy, vz, xl, yl, zl)
//# func_description //# func_description
// Computes light aberration correction vector // Computes light aberration correction vector
...@@ -1712,6 +2005,8 @@ void UsgsAstroLsSensorModel::lightAberrationCorr( ...@@ -1712,6 +2005,8 @@ void UsgsAstroLsSensorModel::lightAberrationCorr(
dxl = 0.0; dxl = 0.0;
dyl = 0.0; dyl = 0.0;
dzl = 0.0; dzl = 0.0;
MESSAGE_LOG(m_logger, "lightAberrationCorr: image ray is parallel"
"to velocity vector")
} }
// Compute the angle between the corrected image ray and spacecraft // Compute the angle between the corrected image ray and spacecraft
...@@ -1730,6 +2025,8 @@ void UsgsAstroLsSensorModel::lightAberrationCorr( ...@@ -1730,6 +2025,8 @@ void UsgsAstroLsSensorModel::lightAberrationCorr(
dxl = cfac * vx; dxl = cfac * vx;
dyl = cfac * vy; dyl = cfac * vy;
dzl = cfac * vz; dzl = cfac * vz;
MESSAGE_LOG(m_logger, "lightAberrationCorr: light of sight correction"
"{} {} {}", dxl, dyl, dzl)
} }
//*************************************************************************** //***************************************************************************
...@@ -1743,6 +2040,9 @@ void UsgsAstroLsSensorModel::computeElevation( ...@@ -1743,6 +2040,9 @@ void UsgsAstroLsSensorModel::computeElevation(
double& achieved_precision, double& achieved_precision,
const double& desired_precision) const const double& desired_precision) const
{ {
MESSAGE_LOG(m_logger, "Calculating computeElevation for {} {} {}"
"with desired precision {}",
x, y, z, desired_precision)
// Compute elevation given xyz // Compute elevation given xyz
// Requires semi-major-axis and eccentricity-square // Requires semi-major-axis and eccentricity-square
const int MKTR = 10; const int MKTR = 10;
...@@ -1770,6 +2070,7 @@ void UsgsAstroLsSensorModel::computeElevation( ...@@ -1770,6 +2070,7 @@ void UsgsAstroLsSensorModel::computeElevation(
tanPhi = zz / d; tanPhi = zz / d;
ktr++; ktr++;
} while (MKTR > ktr && fabs(h - hPrev) > desired_precision); } while (MKTR > ktr && fabs(h - hPrev) > desired_precision);
MESSAGE_LOG(m_logger, "computeElevation: point is near equator")
} }
// Suited for points near the poles // Suited for points near the poles
...@@ -1788,10 +2089,14 @@ void UsgsAstroLsSensorModel::computeElevation( ...@@ -1788,10 +2089,14 @@ void UsgsAstroLsSensorModel::computeElevation(
cotPhi = dd / z; cotPhi = dd / z;
ktr++; ktr++;
} while (MKTR > ktr && fabs(h - hPrev) > desired_precision); } while (MKTR > ktr && fabs(h - hPrev) > desired_precision);
MESSAGE_LOG(m_logger, "computeElevation: point is near poles")
} }
height = h; height = h;
achieved_precision = fabs(h - hPrev); achieved_precision = fabs(h - hPrev);
MESSAGE_LOG(m_logger, "computeElevation: height {} with achieved"
"precision of {}",
height, achieved_precision)
} }
//*************************************************************************** //***************************************************************************
...@@ -1811,6 +2116,10 @@ void UsgsAstroLsSensorModel::losEllipsoidIntersect( ...@@ -1811,6 +2116,10 @@ void UsgsAstroLsSensorModel::losEllipsoidIntersect(
double& achieved_precision, double& achieved_precision,
const double& desired_precision) const const double& desired_precision) const
{ {
MESSAGE_LOG(m_logger, "Computing losEllipsoidIntersect for camera position"
"{} {} {} looking {} {} {} with desired precision"
"{}",
xc, yc, zc, xl, yl, zl, desired_precision)
// Helper function which computes the intersection of the image ray // Helper function which computes the intersection of the image ray
// with the ellipsoid. All vectors are in earth-centered-fixed // with the ellipsoid. All vectors are in earth-centered-fixed
// coordinate system with origin at the center of the earth. // coordinate system with origin at the center of the earth.
...@@ -1860,6 +2169,9 @@ void UsgsAstroLsSensorModel::losEllipsoidIntersect( ...@@ -1860,6 +2169,9 @@ void UsgsAstroLsSensorModel::losEllipsoidIntersect(
slope = -1; slope = -1;
achieved_precision = fabs(height - h); achieved_precision = fabs(height - h);
MESSAGE_LOG(m_logger, "losEllipsoidIntersect: found intersect at {} {} {}"
"with achieved precision of {}",
x, y, z, achieved_precision)
} }
//*************************************************************************** //***************************************************************************
...@@ -1879,6 +2191,9 @@ void UsgsAstroLsSensorModel::losPlaneIntersect( ...@@ -1879,6 +2191,9 @@ void UsgsAstroLsSensorModel::losPlaneIntersect(
// 0(X), 1(Y), or 2(Z) fixed // 0(X), 1(Y), or 2(Z) fixed
// output: 0(X), 1(Y), or 2(Z) fixed // output: 0(X), 1(Y), or 2(Z) fixed
{ {
MESSAGE_LOG(m_logger, "Calculating losPlaneIntersect for camera position"
"{} {} {} and image ray {} {} {}",
xc, yc, zc, xl, yl, zl)
//# func_description //# func_description
// Computes 2 of the 3 coordinates of a ground point given the 3rd // Computes 2 of the 3 coordinates of a ground point given the 3rd
// coordinate. The 3rd coordinate that is held fixed corresponds // coordinate. The 3rd coordinate that is held fixed corresponds
...@@ -1901,7 +2216,8 @@ void UsgsAstroLsSensorModel::losPlaneIntersect( ...@@ -1901,7 +2216,8 @@ void UsgsAstroLsSensorModel::losPlaneIntersect(
mode = 2; mode = 2;
} }
} }
MESSAGE_LOG(m_logger, "losPlaneIntersect: largest/fixed image ray component"
"{} (1-x, 2-y, 3-z)", mode)
// X is the fixed or largest component // X is the fixed or largest component
if (0 == mode) if (0 == mode)
...@@ -1925,6 +2241,7 @@ void UsgsAstroLsSensorModel::losPlaneIntersect( ...@@ -1925,6 +2241,7 @@ void UsgsAstroLsSensorModel::losPlaneIntersect(
x = xc + (z - zc) * xl / zl; x = xc + (z - zc) * xl / zl;
y = yc + (z - zc) * yl / zl; y = yc + (z - zc) * yl / zl;
} }
MESSAGE_LOG(m_logger, "ground coordinate {} {} {}", x, y, z)
} }
//*************************************************************************** //***************************************************************************
...@@ -1940,6 +2257,7 @@ void UsgsAstroLsSensorModel::imageToPlane( ...@@ -1940,6 +2257,7 @@ void UsgsAstroLsSensorModel::imageToPlane(
double& z, double& z,
int& mode) const int& mode) const
{ {
MESSAGE_LOG(m_logger, "Computing imageToPlane")
//# func_description //# func_description
// Computes ground coordinates by intersecting image ray with // Computes ground coordinates by intersecting image ray with
// a plane perpendicular to the coordinate axis with the largest // a plane perpendicular to the coordinate axis with the largest
...@@ -1971,6 +2289,9 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel( ...@@ -1971,6 +2289,9 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel(
double& vy, double& vy,
double& vz) const double& vz) const
{ {
MESSAGE_LOG(m_logger, "Calculating getAdjSensorPosVel at time {}",
time)
// Sensor position and velocity (4th or 8th order Lagrange). // Sensor position and velocity (4th or 8th order Lagrange).
int nOrder = 8; int nOrder = 8;
if (m_platformFlag == 0) if (m_platformFlag == 0)
...@@ -1981,8 +2302,10 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel( ...@@ -1981,8 +2302,10 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel(
double sensVelNom[3]; double sensVelNom[3];
lagrangeInterp(m_numPositions/3, &m_velocities[0], m_t0Ephem, m_dtEphem, lagrangeInterp(m_numPositions/3, &m_velocities[0], m_t0Ephem, m_dtEphem,
time, 3, nOrder, sensVelNom); time, 3, nOrder, sensVelNom);
// Compute rotation matrix from ICR to ECF MESSAGE_LOG(m_logger, "getAdjSensorPosVel: using {} order Lagrange",
nOrder)
// Compute rotation matrix from ICR to ECF
double radialUnitVec[3]; double radialUnitVec[3];
double radMag = sqrt(sensPosNom[0] * sensPosNom[0] + double radMag = sqrt(sensPosNom[0] * sensPosNom[0] +
sensPosNom[1] * sensPosNom[1] + sensPosNom[1] * sensPosNom[1] +
...@@ -2018,8 +2341,8 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel( ...@@ -2018,8 +2341,8 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel(
ecfFromIcr[6] = inTrackUnitVec[2]; ecfFromIcr[6] = inTrackUnitVec[2];
ecfFromIcr[7] = crossTrackUnitVec[2]; ecfFromIcr[7] = crossTrackUnitVec[2];
ecfFromIcr[8] = radialUnitVec[2]; ecfFromIcr[8] = radialUnitVec[2];
// Apply position and velocity corrections
// Apply position and velocity corrections
double aTime = time - m_t0Ephem; double aTime = time - m_t0Ephem;
double dvi = getValue(3, adj) / m_halfTime; double dvi = getValue(3, adj) / m_halfTime;
double dvc = getValue(4, adj) / m_halfTime; double dvc = getValue(4, adj) / m_halfTime;
...@@ -2039,6 +2362,10 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel( ...@@ -2039,6 +2362,10 @@ void UsgsAstroLsSensorModel::getAdjSensorPosVel(
+ ecfFromIcr[3] * di + ecfFromIcr[4] * dc + ecfFromIcr[5] * dr; + ecfFromIcr[3] * di + ecfFromIcr[4] * dc + ecfFromIcr[5] * dr;
zc = sensPosNom[2] zc = sensPosNom[2]
+ ecfFromIcr[6] * di + ecfFromIcr[7] * dc + ecfFromIcr[8] * dr; + ecfFromIcr[6] * di + ecfFromIcr[7] * dc + ecfFromIcr[8] * dr;
MESSAGE_LOG(m_logger, "getAdjSensorPosVel: postition {} {} {}"
"and velocity {} {} {}",
xc, yc, zc, vx, vy, vz)
} }
...@@ -2051,6 +2378,10 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel( ...@@ -2051,6 +2378,10 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel(
const std::vector<double>& adj, const std::vector<double>& adj,
const double& desiredPrecision) const const double& desiredPrecision) const
{ {
MESSAGE_LOG(m_logger, "Computing computeViewingPixel (with adjusments)"
"for ground point {} {} {} at time {} ",
groundPoint.x, groundPoint.y, groundPoint.z, time)
// Helper function to compute the CCD pixel that views a ground point based // Helper function to compute the CCD pixel that views a ground point based
// on the exterior orientation at a given time. // on the exterior orientation at a given time.
...@@ -2062,6 +2393,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel( ...@@ -2062,6 +2393,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel(
double bodyLookX = groundPoint.x - xc; double bodyLookX = groundPoint.x - xc;
double bodyLookY = groundPoint.y - yc; double bodyLookY = groundPoint.y - yc;
double bodyLookZ = groundPoint.z - zc; double bodyLookZ = groundPoint.z - zc;
MESSAGE_LOG(m_logger, "computeViewingPixel: look vector {} {} {}",
bodyLookX, bodyLookY, bodyLookZ)
// Rotate the look vector into the camera reference frame // Rotate the look vector into the camera reference frame
double quaternions[4]; double quaternions[4];
...@@ -2079,6 +2412,9 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel( ...@@ -2079,6 +2412,9 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel(
double cameraLookZ = bodyToCamera[2] * bodyLookX double cameraLookZ = bodyToCamera[2] * bodyLookX
+ bodyToCamera[5] * bodyLookY + bodyToCamera[5] * bodyLookY
+ bodyToCamera[8] * bodyLookZ; + bodyToCamera[8] * bodyLookZ;
MESSAGE_LOG(m_logger, "computeViewingPixel: look vector (camrea ref frame)"
"{} {} {}",
cameraLookX, cameraLookY, cameraLookZ)
// Invert the attitude correction // Invert the attitude correction
double attCorr[9]; double attCorr[9];
...@@ -2094,12 +2430,18 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel( ...@@ -2094,12 +2430,18 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel(
double adjustedLookZ = attCorr[2] * cameraLookX double adjustedLookZ = attCorr[2] * cameraLookX
+ attCorr[5] * cameraLookY + attCorr[5] * cameraLookY
+ attCorr[8] * cameraLookZ; + attCorr[8] * cameraLookZ;
MESSAGE_LOG(m_logger, "computeViewingPixel: adjusted look vector"
"{} {} {}",
adjustedLookX, adjustedLookY, adjustedLookZ)
// Convert to focal plane coordinate // Convert to focal plane coordinate
double lookScale = m_focalLength / adjustedLookZ; double lookScale = m_focalLength / adjustedLookZ;
double focalX = adjustedLookX * lookScale; double focalX = adjustedLookX * lookScale;
double focalY = adjustedLookY * lookScale; double focalY = adjustedLookY * lookScale;
double distortedFocalX, distortedFocalY; double distortedFocalX, distortedFocalY;
MESSAGE_LOG(m_logger, "computeViewingPixel: focal plane coordinates"
"x:{} y:{} scale:{}",
focalX, focalY, lookScale)
// Invert distortion // Invert distortion
applyDistortion(focalX, focalY, distortedFocalX, distortedFocalY, applyDistortion(focalX, focalY, distortedFocalX, distortedFocalY,
...@@ -2117,6 +2459,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel( ...@@ -2117,6 +2459,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::computeViewingPixel(
double line = detectorLine + m_detectorLineOrigin; double line = detectorLine + m_detectorLineOrigin;
double sample = (detectorSample + m_detectorSampleOrigin - m_startingSample) double sample = (detectorSample + m_detectorSampleOrigin - m_startingSample)
/ m_detectorSampleSumming; / m_detectorSampleSumming;
MESSAGE_LOG(m_logger, "computeViewingPixel: image line sample {} {}",
line, sample)
return csm::ImageCoord(line, sample); return csm::ImageCoord(line, sample);
} }
...@@ -2143,11 +2487,15 @@ void UsgsAstroLsSensorModel::computeLinearApproximation( ...@@ -2143,11 +2487,15 @@ void UsgsAstroLsSensorModel::computeLinearApproximation(
if (ip.samp < 0.0) ip.samp = 0.0; if (ip.samp < 0.0) ip.samp = 0.0;
if (ip.samp > numCols) ip.samp = numCols; if (ip.samp > numCols) ip.samp = numCols;
MESSAGE_LOG(m_logger, "Computing computeLinearApproximation"
"with linear approximation")
} }
else else
{ {
ip.line = m_nLines / 2.0; ip.line = m_nLines / 2.0;
ip.samp = m_nSamples / 2.0; ip.samp = m_nSamples / 2.0;
MESSAGE_LOG(m_logger, "Computing computeLinearApproximation"
"nonlinear approx line/2 and sample/2")
} }
} }
...@@ -2157,6 +2505,7 @@ void UsgsAstroLsSensorModel::computeLinearApproximation( ...@@ -2157,6 +2505,7 @@ void UsgsAstroLsSensorModel::computeLinearApproximation(
//*************************************************************************** //***************************************************************************
void UsgsAstroLsSensorModel::setLinearApproximation() void UsgsAstroLsSensorModel::setLinearApproximation()
{ {
MESSAGE_LOG(m_logger, "Calculating setLinearApproximation")
double u_factors[4] = { 0.0, 0.0, 1.0, 1.0 }; double u_factors[4] = { 0.0, 0.0, 1.0, 1.0 };
double v_factors[4] = { 0.0, 1.0, 0.0, 1.0 }; double v_factors[4] = { 0.0, 1.0, 0.0, 1.0 };
...@@ -2167,10 +2516,17 @@ void UsgsAstroLsSensorModel::setLinearApproximation() ...@@ -2167,10 +2516,17 @@ void UsgsAstroLsSensorModel::setLinearApproximation()
computeElevation(refPt.x, refPt.y, refPt.z, height, aPrec, desired_precision); computeElevation(refPt.x, refPt.y, refPt.z, height, aPrec, desired_precision);
if (isnan(height)) if (isnan(height))
{ {
MESSAGE_LOG(m_logger, "setLinearApproximation: computeElevation of"
"reference point {} {} {} with desired precision"
"{} returned nan height; nonlinear",
refPt.x, refPt.y, refPt.z, desired_precision)
_linear = false; _linear = false;
return; return;
} }
MESSAGE_LOG(m_logger, "setLinearApproximation: computeElevation of"
"reference point {} {} {} with desired precision"
"{} returned {} height",
refPt.x, refPt.y, refPt.z, desired_precision, height)
double numRows = m_nLines; double numRows = m_nLines;
double numCols = m_nSamples; double numCols = m_nSamples;
...@@ -2233,6 +2589,9 @@ void UsgsAstroLsSensorModel::setLinearApproximation() ...@@ -2233,6 +2589,9 @@ void UsgsAstroLsSensorModel::setLinearApproximation()
if (fabs(denom) < 1.0e-8) // can not get derivatives this way if (fabs(denom) < 1.0e-8) // can not get derivatives this way
{ {
MESSAGE_LOG(m_logger, "setLinearApproximation: determinant3x3 of"
"matrix of partials is {}; nonlinear",
denom)
_linear = false; _linear = false;
return; return;
} }
...@@ -2275,6 +2634,7 @@ void UsgsAstroLsSensorModel::setLinearApproximation() ...@@ -2275,6 +2634,7 @@ void UsgsAstroLsSensorModel::setLinearApproximation()
_v0 = -gp[0].x * _dv_dx - gp[0].y * _dv_dy - gp[0].z * _dv_dz; _v0 = -gp[0].x * _dv_dx - gp[0].y * _dv_dy - gp[0].z * _dv_dz;
_linear = true; _linear = true;
MESSAGE_LOG(m_logger, "Completed setLinearApproximation")
} }
//*************************************************************************** //***************************************************************************
...@@ -2289,10 +2649,12 @@ double UsgsAstroLsSensorModel::determinant3x3(double mat[9]) const ...@@ -2289,10 +2649,12 @@ double UsgsAstroLsSensorModel::determinant3x3(double mat[9]) const
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::constructStateFromIsd
//***************************************************************************
std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imageSupportData, csm::WarningList *warnings) const std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imageSupportData, csm::WarningList *warnings) const
{ {
MESSAGE_LOG(m_logger, "Constructing state from Isd")
// Instantiate UsgsAstroLineScanner sensor model // Instantiate UsgsAstroLineScanner sensor model
json isd = json::parse(imageSupportData); json isd = json::parse(imageSupportData);
json state = {}; json state = {};
...@@ -2305,47 +2667,100 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2305,47 +2667,100 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
state["m_imageIdentifier"] = getImageId(isd, parsingWarnings); state["m_imageIdentifier"] = getImageId(isd, parsingWarnings);
state["m_sensorName"] = getSensorName(isd, parsingWarnings); state["m_sensorName"] = getSensorName(isd, parsingWarnings);
state["m_platformName"] = getPlatformName(isd, parsingWarnings); state["m_platformName"] = getPlatformName(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_modelName: {} "
"m_imageIdentifier: {} "
"m_sensorName: {} "
"m_platformName: {} ",
state["m_modelName"].dump(),
state["m_imageIdentifier"].dump(),
state["m_sensorName"].dump(),
state["m_platformName"].dump())
state["m_focalLength"] = getFocalLength(isd, parsingWarnings); state["m_focalLength"] = getFocalLength(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_focalLength: {} ", state["m_focalLength"].dump())
state["m_nLines"] = getTotalLines(isd, parsingWarnings); state["m_nLines"] = getTotalLines(isd, parsingWarnings);
state["m_nSamples"] = getTotalSamples(isd, parsingWarnings); state["m_nSamples"] = getTotalSamples(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_nLines: {} "
"m_nSamples: {} ",
state["m_nLines"].dump(), state["m_nSamples"].dump())
state["m_iTransS"] = getFocal2PixelSamples(isd, parsingWarnings); state["m_iTransS"] = getFocal2PixelSamples(isd, parsingWarnings);
state["m_iTransL"] = getFocal2PixelLines(isd, parsingWarnings); state["m_iTransL"] = getFocal2PixelLines(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_iTransS: {} "
"m_iTransL: {} ",
state["m_iTransS"].dump(), state["m_iTransL"].dump())
state["m_platformFlag"] = 1; state["m_platformFlag"] = 1;
state["m_ikCode"] = 0; state["m_ikCode"] = 0;
state["m_zDirection"] = 1; state["m_zDirection"] = 1;
MESSAGE_LOG(m_logger, "m_platformFlag: {} "
"m_ikCode: {} "
"m_zDirection: {} ",
state["m_platformFlag"].dump(), state["m_ikCode"].dump(),
state["m_zDirection"].dump())
state["m_distortionType"] = getDistortionModel(isd, parsingWarnings); state["m_distortionType"] = getDistortionModel(isd, parsingWarnings);
state["m_opticalDistCoeffs"] = getDistortionCoeffs(isd, parsingWarnings); state["m_opticalDistCoeffs"] = getDistortionCoeffs(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_distortionType: {} "
"m_opticalDistCoeffs: {} ",
state["m_distortionType"].dump(),
state["m_opticalDistCoeffs"].dump())
// Zero computed state values // Zero computed state values
state["m_referencePointXyz"] = std::vector<double>(3, 0.0); state["m_referencePointXyz"] = std::vector<double>(3, 0.0);
MESSAGE_LOG(m_logger, "m_referencePointXyz: {} ",
state["m_referencePointXyz"].dump())
// leave these be for now. // leave these be for now.
state["m_gsd"] = 1.0; state["m_gsd"] = 1.0;
state["m_flyingHeight"] = 1000.0; state["m_flyingHeight"] = 1000.0;
state["m_halfSwath"] = 1000.0; state["m_halfSwath"] = 1000.0;
state["m_halfTime"] = 10.0; state["m_halfTime"] = 10.0;
MESSAGE_LOG(m_logger, "m_gsd: {} "
"m_flyingHeight: {} "
"m_halfSwath: {} "
"m_halfTime: {} ",
state["m_gsd"].dump(), state["m_flyingHeight"].dump(),
state["m_halfSwath"].dump(), state["m_halfTime"].dump())
state["m_centerEphemerisTime"] = getCenterTime(isd, parsingWarnings); state["m_centerEphemerisTime"] = getCenterTime(isd, parsingWarnings);
state["m_startingEphemerisTime"] = getStartingTime(isd, parsingWarnings); state["m_startingEphemerisTime"] = getStartingTime(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_centerEphemerisTime: {} "
"m_startingEphemerisTime: {} ",
state["m_centerEphemerisTime"].dump(),
state["m_startingEphemerisTime"].dump())
state["m_intTimeLines"] = getIntegrationStartLines(isd, parsingWarnings); state["m_intTimeLines"] = getIntegrationStartLines(isd, parsingWarnings);
state["m_intTimeStartTimes"] = getIntegrationStartTimes(isd, parsingWarnings); state["m_intTimeStartTimes"] = getIntegrationStartTimes(isd, parsingWarnings);
state["m_intTimes"] = getIntegrationTimes(isd, parsingWarnings); state["m_intTimes"] = getIntegrationTimes(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_intTimeLines: {} "
"m_intTimeStartTimes: {} "
"m_intTimes: {} ",
state["m_intTimeLines"].dump(),
state["m_intTimeStartTimes"].dump(),
state["m_intTimes"].dump())
state["m_detectorSampleSumming"] = getSampleSumming(isd, parsingWarnings); state["m_detectorSampleSumming"] = getSampleSumming(isd, parsingWarnings);
state["m_startingDetectorSample"] = getDetectorStartingSample(isd, parsingWarnings); state["m_startingDetectorSample"] = getDetectorStartingSample(isd, parsingWarnings);
state["m_startingDetectorLine"] = getDetectorStartingLine(isd, parsingWarnings); state["m_startingDetectorLine"] = getDetectorStartingLine(isd, parsingWarnings);
state["m_detectorSampleOrigin"] = getDetectorCenterSample(isd, parsingWarnings); state["m_detectorSampleOrigin"] = getDetectorCenterSample(isd, parsingWarnings);
state["m_detectorLineOrigin"] = getDetectorCenterLine(isd, parsingWarnings); state["m_detectorLineOrigin"] = getDetectorCenterLine(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_detectorSampleSumming: {} "
"m_startingDetectorSample: {} "
"m_startingDetectorLine: {} "
"m_detectorSampleOrigin: {} "
"m_detectorLineOrigin: {} ",
state["m_detectorSampleSumming"].dump(),
state["m_startingDetectorSample"].dump(),
state["m_startingDetectorLine"].dump(),
state["m_detectorSampleOrigin"].dump(),
state["m_detectorLineOrigin"].dump())
// These are exlusive to LineScanners, leave them here for now. // These are exlusive to LineScanners, leave them here for now.
try { try {
state["m_dtEphem"] = isd.at("dt_ephemeris"); state["m_dtEphem"] = isd.at("dt_ephemeris");
MESSAGE_LOG(m_logger, "m_dtEphem: {} ", state["m_dtEphem"].dump())
} }
catch(...) { catch(...) {
parsingWarnings->push_back( parsingWarnings->push_back(
...@@ -2353,10 +2768,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2353,10 +2768,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
csm::Warning::DATA_NOT_AVAILABLE, csm::Warning::DATA_NOT_AVAILABLE,
"dt_ephemeris not in ISD", "dt_ephemeris not in ISD",
"UsgsAstroFrameSensorModel::constructStateFromIsd()")); "UsgsAstroFrameSensorModel::constructStateFromIsd()"));
MESSAGE_LOG(m_logger, "m_dtEphem not in ISD")
} }
try { try {
state["m_t0Ephem"] = isd.at("t0_ephemeris"); state["m_t0Ephem"] = isd.at("t0_ephemeris");
MESSAGE_LOG(m_logger, "t0_ephemeris: {}", state["m_t0Ephem"].dump())
} }
catch(...) { catch(...) {
parsingWarnings->push_back( parsingWarnings->push_back(
...@@ -2364,10 +2781,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2364,10 +2781,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
csm::Warning::DATA_NOT_AVAILABLE, csm::Warning::DATA_NOT_AVAILABLE,
"t0_ephemeris not in ISD", "t0_ephemeris not in ISD",
"UsgsAstroFrameSensorModel::constructStateFromIsd()")); "UsgsAstroFrameSensorModel::constructStateFromIsd()"));
MESSAGE_LOG(m_logger, "t0_ephemeris not in ISD")
} }
try{ try{
state["m_dtQuat"] = isd.at("dt_quaternion"); state["m_dtQuat"] = isd.at("dt_quaternion");
MESSAGE_LOG(m_logger, "dt_quaternion: {}", state["m_dtQuat"].dump())
} }
catch(...) { catch(...) {
parsingWarnings->push_back( parsingWarnings->push_back(
...@@ -2375,10 +2794,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2375,10 +2794,12 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
csm::Warning::DATA_NOT_AVAILABLE, csm::Warning::DATA_NOT_AVAILABLE,
"dt_quaternion not in ISD", "dt_quaternion not in ISD",
"UsgsAstroFrameSensorModel::constructStateFromIsd()")); "UsgsAstroFrameSensorModel::constructStateFromIsd()"));
MESSAGE_LOG(m_logger, "dt_quaternion not in ISD")
} }
try{ try{
state["m_t0Quat"] = isd.at("t0_quaternion"); state["m_t0Quat"] = isd.at("t0_quaternion");
MESSAGE_LOG(m_logger, "m_t0Quat: {}", state["m_t0Quat"].dump())
} }
catch(...) { catch(...) {
parsingWarnings->push_back( parsingWarnings->push_back(
...@@ -2386,32 +2807,55 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2386,32 +2807,55 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
csm::Warning::DATA_NOT_AVAILABLE, csm::Warning::DATA_NOT_AVAILABLE,
"t0_quaternion not in ISD", "t0_quaternion not in ISD",
"UsgsAstroFrameSensorModel::constructStateFromIsd()")); "UsgsAstroFrameSensorModel::constructStateFromIsd()"));
MESSAGE_LOG(m_logger, "t0_quaternion not in ISD")
} }
std::vector<double> positions = getSensorPositions(isd, parsingWarnings); std::vector<double> positions = getSensorPositions(isd, parsingWarnings);
state["m_positions"] = positions; state["m_positions"] = positions;
state["m_numPositions"] = positions.size(); state["m_numPositions"] = positions.size();
MESSAGE_LOG(m_logger, "m_positions: {}"
"m_numPositions: {}",
state["m_positions"].dump(),
state["m_numPositions"].dump())
state["m_velocities"] = getSensorVelocities(isd, parsingWarnings); state["m_velocities"] = getSensorVelocities(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_velocities: {}",
state["m_velocities"].dump())
std::vector<double> quaternions = getSensorOrientations(isd, parsingWarnings); std::vector<double> quaternions = getSensorOrientations(isd, parsingWarnings);
state["m_quaternions"] = quaternions; state["m_quaternions"] = quaternions;
state["m_numQuaternions"] = quaternions.size(); state["m_numQuaternions"] = quaternions.size();
MESSAGE_LOG(m_logger, "m_quaternions: {}"
"m_numQuaternions: {}",
state["m_quaternions"].dump(),
state["m_numQuaternions"].dump())
state["m_currentParameterValue"] = std::vector<double>(NUM_PARAMETERS, 0.0); state["m_currentParameterValue"] = std::vector<double>(NUM_PARAMETERS, 0.0);
MESSAGE_LOG(m_logger, "m_currentParameterValue: {}",
state["m_currentParameterValue"].dump())
// get radii // get radii
state["m_minorAxis"] = getSemiMinorRadius(isd, parsingWarnings); state["m_minorAxis"] = getSemiMinorRadius(isd, parsingWarnings);
state["m_majorAxis"] = getSemiMajorRadius(isd, parsingWarnings); state["m_majorAxis"] = getSemiMajorRadius(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_minorAxis: {}"
"m_majorAxis: {}",
state["m_minorAxis"].dump(), state["m_majorAxis"].dump())
// set identifiers // set identifiers
state["m_platformIdentifier"] = getPlatformName(isd, parsingWarnings); state["m_platformIdentifier"] = getPlatformName(isd, parsingWarnings);
state["m_sensorIdentifier"] = getSensorName(isd, parsingWarnings); state["m_sensorIdentifier"] = getSensorName(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_platformIdentifier: {}"
"m_sensorIdentifier: {}",
state["m_platformIdentifier"].dump(),
state["m_sensorIdentifier"].dump())
// get reference_height // get reference_height
state["m_minElevation"] = getMinHeight(isd, parsingWarnings); state["m_minElevation"] = getMinHeight(isd, parsingWarnings);
state["m_maxElevation"] = getMaxHeight(isd, parsingWarnings); state["m_maxElevation"] = getMaxHeight(isd, parsingWarnings);
MESSAGE_LOG(m_logger, "m_minElevation: {}"
"m_maxElevation: {}",
state["m_minElevation"].dump(),
state["m_maxElevation"].dump())
// Default to identity covariance // Default to identity covariance
state["m_covariance"] = state["m_covariance"] =
...@@ -2420,8 +2864,24 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag ...@@ -2420,8 +2864,24 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag
state["m_covariance"][i * NUM_PARAMETERS + i] = 1.0; state["m_covariance"][i * NUM_PARAMETERS + i] = 1.0;
} }
// Get the optional logging file
state["m_logFile"] = getLogFile(isd);
// The state data will still be updated when a sensor model is created since // The state data will still be updated when a sensor model is created since
// some state data is notin the ISD and requires a SM to compute them. // some state data is notin the ISD and requires a SM to compute them.
return state.dump(); return state.dump();
} }
//***************************************************************************
// UsgsAstroLineScannerSensorModel::getLogger
//***************************************************************************
std::shared_ptr<spdlog::logger> UsgsAstroLsSensorModel::getLogger() {
// MESSAGE_LOG(m_logger, "Getting log pointer, logger is {}",
// m_logger)
return m_logger;
}
void UsgsAstroLsSensorModel::setLogger(std::shared_ptr<spdlog::logger> logger) {
m_logger = logger;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment