Skip to content

Commit

Permalink
Added ability to get sun distance from the camera Ref DOI-USGS#4303
Browse files Browse the repository at this point in the history
  • Loading branch information
scsides committed Feb 25, 2021
1 parent 24ac6f7 commit c4c27ac
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 28 deletions.
2 changes: 1 addition & 1 deletion isis/src/mro/apps/hical/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void IsisMain(){
HiHistory GucHist;
GucHist.add("Profile["+ hiprof.Name()+"]");
if ( !SkipModule(hiprof) ) {
GainUnitConversion guc(hiconf, units);
GainUnitConversion guc(hiconf, units, hifrom);
calVars->add(hiconf.getProfileName(), guc.ref());
GucHist = guc.History();
if ( hiprof.exists("DumpModuleFile") ) {
Expand Down
6 changes: 5 additions & 1 deletion isis/src/mro/apps/hical/tsts/default/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ commands:
cat PSP_001446_1790_RED2_0.hical.log \
| sed 's/\([0-9][0-9]*\.[0-9]\{12\}\)\([0-9][0-9]*\)/\1/g' \
> $(OUTPUT)/output.txt;
$(RM) PSP_001446_1790_RED2_0.hical.log
$(RM) PSP_001446_1790_RED2_0.hical.log
$(APPNAME) FROM=$(INPUT)/PSP_001446_1790_RED2_0_spiceinit.cub \
TO=$(OUTPUT)/output_spiceinit.cub OPATH=. > /dev/null;
$(RM) PSP_001446_1790_RED2_0.hical.log

2 changes: 1 addition & 1 deletion isis/src/mro/apps/hicalbeta/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void IsisMain(){
HiHistory GucHist;
GucHist.add("Profile["+ hiprof.Name()+"]");
if ( !SkipModule(hiprof) ) {
GainUnitConversion guc(hiconf, units);
GainUnitConversion guc(hiconf, units, hifrom);
calVars->add(hiconf.getProfileName(), guc.ref());
GucHist = guc.History();
if ( hiprof.exists("DumpModuleFile") ) {
Expand Down
11 changes: 7 additions & 4 deletions isis/src/mro/objs/HiCal/GainUnitConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ find files of those names at the top level of this repository. **/
#include <string>
#include <vector>

#include "Cube.h"
#include "IString.h"
#include "HiCalTypes.h"
#include "HiCalUtil.h"
Expand All @@ -36,15 +37,17 @@ namespace Isis {
* @internal
* @history 2010-10-28 Kris Becker Renamed parameters replacing "Ziof" with
* "GainUnitConversion".
* @history 2021-02-24 Stuart Sides Added a cube parameter to the
* constructor to support getting sun distance from the camera
*/
class GainUnitConversion : public Module {

public:
// Constructors and Destructor
GainUnitConversion() : Module("GainUnitConversion"), _units("DN") { }
GainUnitConversion(HiCalConf &conf, const QString &units) :
GainUnitConversion(HiCalConf &conf, const QString &units, Cube *cube) :
Module("GainUnitConversion"), _units(units) {
init(conf);
init(conf, cube);
}

/** Destructor */
Expand All @@ -53,15 +56,15 @@ namespace Isis {
private:
QString _units;

void init(HiCalConf &conf) {
void init(HiCalConf &conf, Cube *cube) {
_history.clear();
DbProfile prof = conf.getMatrixProfile();
_history.add("Profile["+ prof.Name()+"]");

double sed = ToDouble(prof("ScanExposureDuration")); // units = us
if ( IsEqual(_units, "IOF") ) {
// Add solar I/F correction parameters
double au = conf.sunDistanceAU();
double au = conf.sunDistanceAU(cube);
_history.add("SunDist[" + ToString(au) + " (AU)]");
double suncorr = 1.5 / au;
suncorr *= suncorr;
Expand Down
59 changes: 39 additions & 20 deletions isis/src/mro/objs/HiCal/HiCalConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ find files of those names at the top level of this repository. **/
#include <SpiceUsr.h>

#include "Brick.h"
#include "Camera.h"
#include "Cube.h"
#include "FileName.h"
#include "HiCalConf.h"
Expand Down Expand Up @@ -295,27 +296,45 @@ bool HiCalConf::_naifLoaded = false;
*
* @return double Distance in AU between Sun and observed body
*/
double HiCalConf::sunDistanceAU() {
NaifStatus::CheckErrors();
loadNaifTiming();

QString scStartTime = getKey("SpacecraftClockStartCount", "Instrument");
double obsStartTime;
scs2e_c (-74999,scStartTime.toLatin1().data(),&obsStartTime);

QString targetName = getKey("TargetName", "Instrument");
if (targetName.toLower() == "sky" ||
targetName.toLower() == "cal" ||
targetName.toLower() == "phobos" ||
targetName.toLower() == "deimos") {
targetName = "Mars";
double HiCalConf::sunDistanceAU(Cube *cube) {
double sunkm = 0.0;
try {
Camera *cam;
cam = cube->camera();
cam->SetImage(0.5, 0.5);
sunkm = cam->sunToBodyDist();
NaifStatus::CheckErrors();
}
double sunv[3];
double lt;
(void) spkpos_c(targetName.toLatin1().data(), obsStartTime, "J2000", "LT+S", "sun",
sunv, &lt);
double sunkm = vnorm_c(sunv);
NaifStatus::CheckErrors();
catch (IException &e) {
try {
loadNaifTiming();

QString scStartTime = getKey("SpacecraftClockStartCount", "Instrument");
double obsStartTime;
NaifStatus::CheckErrors();
scs2e_c (-74999,scStartTime.toLatin1().data(),&obsStartTime);

QString targetName = getKey("TargetName", "Instrument");
if (targetName.toLower() == "sky" ||
targetName.toLower() == "cal" ||
targetName.toLower() == "phobos" ||
targetName.toLower() == "deimos") {
targetName = "Mars";
}
double sunv[3];
double lt;
(void) spkpos_c(targetName.toLatin1().data(), obsStartTime, "J2000", "LT+S", "sun",
sunv, &lt);
sunkm = vnorm_c(sunv);

NaifStatus::CheckErrors();
}
catch(IException &e) {
QString msg = "Unable to determine the distance from the target to the sun";
throw IException(e, IException::User, msg, _FILEINFO_);
}
}

// Return in AU units
return (sunkm/1.49597870691E8);
}
Expand Down
4 changes: 3 additions & 1 deletion isis/src/mro/objs/HiCal/HiCalConf.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ find files of those names at the top level of this repository. **/

namespace Isis {

class Cube;

/**
* @brief HiCalConf manages HiRISE calibration matrices
* that alter some or all of the
Expand Down Expand Up @@ -111,7 +113,7 @@ namespace Isis {
int getMatrixBand() const;
int getMatrixBand(const DbProfile &p) const;

double sunDistanceAU();
double sunDistanceAU(Cube *cube);

DbProfile getMatrixProfile(const QString &profile = "") const;
ValueList getList(const DbProfile &profile, const QString &key) const;
Expand Down

0 comments on commit c4c27ac

Please sign in to comment.