Unverified Commit 6e2df9c2 authored by Stuart Sides's avatar Stuart Sides Committed by GitHub
Browse files

Added ability to get sun distance from the camera Ref #4303 (#4320)

parent 4dee7204
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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") ) {
+5 −1
Original line number Diff line number Diff line
@@ -12,3 +12,7 @@ commands:
          | 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
	$(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
+1 −1
Original line number Diff line number Diff line
@@ -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") ) {
+7 −4
Original line number Diff line number Diff line
@@ -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"
@@ -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 */
@@ -53,7 +56,7 @@ 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()+"]");
@@ -61,7 +64,7 @@ namespace Isis {
        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;
+39 −20
Original line number Diff line number Diff line
@@ -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"
@@ -295,12 +296,22 @@ bool HiCalConf::_naifLoaded = false;
   *
   * @return double Distance in AU between Sun and observed body
   */
  double HiCalConf::sunDistanceAU() {
  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();
    }
    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");
@@ -314,8 +325,16 @@ bool HiCalConf::_naifLoaded = false;
        double lt;
        (void) spkpos_c(targetName.toLatin1().data(), obsStartTime, "J2000", "LT+S", "sun",
                        sunv, &lt);
    double sunkm = vnorm_c(sunv);
        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);
  }
Loading