Loading isis/src/viking/apps/vikcal/CalParameters.cpp +42 −19 Original line number Diff line number Diff line Loading @@ -15,9 +15,12 @@ find files of those names at the top level of this repository. **/ #include <SpiceZmc.h> #include "CalParameters.h" #include "Camera.h" #include "Cube.h" #include "FileName.h" #include "IException.h" #include "IString.h" #include "iTime.h" #include "LeastSquares.h" #include "Pvl.h" #include "TextFile.h" Loading @@ -26,7 +29,7 @@ find files of those names at the top level of this repository. **/ using namespace std; namespace Isis { CalParameters::CalParameters(const QString &fname) { CalParameters::CalParameters(const QString &fname, Cube *icube) { try { // Extract Pvl Information from the file Pvl pvl(fname.toLatin1().data()); Loading Loading @@ -76,7 +79,7 @@ namespace Isis { } QString startTime = instrument["STARTTIME"]; CalcSunDist(startTime); p_dist1 = CalcSunDist(startTime, icube); p_labexp = (double)instrument["EXPOSUREDURATION"] * 1000.0; // convert to msec QString target = " "; PvlKeyword cs1 = instrument["FLOODMODEID"]; Loading Loading @@ -360,11 +363,26 @@ namespace Isis { } /** * Calculates the distance from the sun at the specified time * Calculates the distance from Mars to the sun at the specified time. * Try to useing the camera assiciated with the cube first, if that * doesn't work fall back to using the SPICE data. * * @param t iTime * @param t The UTC time at which the sun distance is being requested * @param iCube The cube we are calibrating * * @return Distance from the Sun to Mars in km */ void CalParameters::CalcSunDist(QString t) { double CalParameters::CalcSunDist(QString t, Cube *iCube) { try { Camera *cam; cam = iCube->camera(); iTime startTime(t); cam->setTime(startTime); return cam->sunToBodyDist(); } catch(IException &e) { // Failed to instantiate a camera, try furnishing kernels directly try { NaifStatus::CheckErrors(); double sunv[3]; SpiceDouble lt, et; Loading @@ -376,8 +394,13 @@ namespace Isis { furnsh_c(tempfname2.toLatin1().data()); utc2et_c(t.toLatin1().data(), &et); spkezp_c(10, et, "J2000", "LT+S", 499, sunv, <); p_dist1 = sqrt(sunv[0] * sunv[0] + sunv[1] * sunv[1] + sunv[2] * sunv[2]); return sqrt(sunv[0] * sunv[0] + sunv[1] * sunv[1] + sunv[2] * sunv[2]); NaifStatus::CheckErrors(); } catch(IException &e) { QString msg = "Unable to determine the distance from Mars to the Sun"; throw IException(e, IException::User, msg, _FILEINFO_); } } } } // end namespace isis isis/src/viking/apps/vikcal/CalParameters.h +5 −3 Original line number Diff line number Diff line Loading @@ -35,10 +35,12 @@ namespace Isis { * were signaled. References #2248 * */ class Cube; class CalParameters { public: // Constructor CalParameters(const QString &fname); CalParameters(const QString &fname, Cube *icube); /** * Calculates and returns time based offset at specified line and sample Loading @@ -62,7 +64,7 @@ namespace Isis { } /** * Returns distance value found in the vikcal.sav file * Returns estimated distance from Mars to the Sun found in the vikcal.sav file * * @return double Approximate distance from the sun */ Loading Loading @@ -221,7 +223,7 @@ namespace Isis { int cam, QString wav, int cs1, int cs2, int cs3, int cs4); void vikoffSetup(QString mission, int spn, QString target, int cam, double clock, int cs3); void CalcSunDist(QString t); double CalcSunDist(QString t, Cube *icube); double p_labexp; //!<Exposure Duration from cube label double p_w0; //!<Omega0 from vikcal.sav file Loading isis/src/viking/apps/vikcal/main.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,10 @@ void IsisMain() { // linear = ui.GetBoolean("LINEAR"); const QString in = ui.GetFileName("FROM"); calParam = new CalParameters(in); // Open the input cube Cube icube; icube.open(in, "r"); calParam = new CalParameters(in, &icube); Progress prog; // If the file has already been calibrated, throw an error Loading Loading @@ -98,15 +97,13 @@ void IsisMain() { p.EndProcess(); } void cal(vector<Buffer *> &in, vector<Buffer *> &out) { void cal(vector<Buffer *> &in, vector<Buffer *> &out) { Buffer &inp = *in[0]; // Input Cube Buffer &dcf = *in[1]; // Dark Current File Buffer &fff = *in[2]; // Flat Field File Buffer &outp = *out[0]; // Output Cube // Loop for each pixel in the line. for(int i = 0; i < inp.size(); i++) { if(IsSpecial(inp[i])) { Loading isis/src/viking/apps/vikcal/tsts/default/Makefile +2 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,5 @@ include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/f387a06.cub \ to=$(OUTPUT)/vikcalTruth.cub > /dev/null; $(APPNAME) from=$(INPUT)/f319b18.cub \ to=$(OUTPUT)/vikcalCameraTruth.cub > /dev/null; isis/src/viking/apps/vikcal/vikcal.xml +5 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ <change name="Christopher Austin" date="2010-06-16"> Fixed pvl comments </change> <change name="Stuart Sides" date="2021-02-22"> Added ability to calibrate using the camera instead of direcly using SPICE kernels </change> </history> <groups> Loading Loading
isis/src/viking/apps/vikcal/CalParameters.cpp +42 −19 Original line number Diff line number Diff line Loading @@ -15,9 +15,12 @@ find files of those names at the top level of this repository. **/ #include <SpiceZmc.h> #include "CalParameters.h" #include "Camera.h" #include "Cube.h" #include "FileName.h" #include "IException.h" #include "IString.h" #include "iTime.h" #include "LeastSquares.h" #include "Pvl.h" #include "TextFile.h" Loading @@ -26,7 +29,7 @@ find files of those names at the top level of this repository. **/ using namespace std; namespace Isis { CalParameters::CalParameters(const QString &fname) { CalParameters::CalParameters(const QString &fname, Cube *icube) { try { // Extract Pvl Information from the file Pvl pvl(fname.toLatin1().data()); Loading Loading @@ -76,7 +79,7 @@ namespace Isis { } QString startTime = instrument["STARTTIME"]; CalcSunDist(startTime); p_dist1 = CalcSunDist(startTime, icube); p_labexp = (double)instrument["EXPOSUREDURATION"] * 1000.0; // convert to msec QString target = " "; PvlKeyword cs1 = instrument["FLOODMODEID"]; Loading Loading @@ -360,11 +363,26 @@ namespace Isis { } /** * Calculates the distance from the sun at the specified time * Calculates the distance from Mars to the sun at the specified time. * Try to useing the camera assiciated with the cube first, if that * doesn't work fall back to using the SPICE data. * * @param t iTime * @param t The UTC time at which the sun distance is being requested * @param iCube The cube we are calibrating * * @return Distance from the Sun to Mars in km */ void CalParameters::CalcSunDist(QString t) { double CalParameters::CalcSunDist(QString t, Cube *iCube) { try { Camera *cam; cam = iCube->camera(); iTime startTime(t); cam->setTime(startTime); return cam->sunToBodyDist(); } catch(IException &e) { // Failed to instantiate a camera, try furnishing kernels directly try { NaifStatus::CheckErrors(); double sunv[3]; SpiceDouble lt, et; Loading @@ -376,8 +394,13 @@ namespace Isis { furnsh_c(tempfname2.toLatin1().data()); utc2et_c(t.toLatin1().data(), &et); spkezp_c(10, et, "J2000", "LT+S", 499, sunv, <); p_dist1 = sqrt(sunv[0] * sunv[0] + sunv[1] * sunv[1] + sunv[2] * sunv[2]); return sqrt(sunv[0] * sunv[0] + sunv[1] * sunv[1] + sunv[2] * sunv[2]); NaifStatus::CheckErrors(); } catch(IException &e) { QString msg = "Unable to determine the distance from Mars to the Sun"; throw IException(e, IException::User, msg, _FILEINFO_); } } } } // end namespace isis
isis/src/viking/apps/vikcal/CalParameters.h +5 −3 Original line number Diff line number Diff line Loading @@ -35,10 +35,12 @@ namespace Isis { * were signaled. References #2248 * */ class Cube; class CalParameters { public: // Constructor CalParameters(const QString &fname); CalParameters(const QString &fname, Cube *icube); /** * Calculates and returns time based offset at specified line and sample Loading @@ -62,7 +64,7 @@ namespace Isis { } /** * Returns distance value found in the vikcal.sav file * Returns estimated distance from Mars to the Sun found in the vikcal.sav file * * @return double Approximate distance from the sun */ Loading Loading @@ -221,7 +223,7 @@ namespace Isis { int cam, QString wav, int cs1, int cs2, int cs3, int cs4); void vikoffSetup(QString mission, int spn, QString target, int cam, double clock, int cs3); void CalcSunDist(QString t); double CalcSunDist(QString t, Cube *icube); double p_labexp; //!<Exposure Duration from cube label double p_w0; //!<Omega0 from vikcal.sav file Loading
isis/src/viking/apps/vikcal/main.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,10 @@ void IsisMain() { // linear = ui.GetBoolean("LINEAR"); const QString in = ui.GetFileName("FROM"); calParam = new CalParameters(in); // Open the input cube Cube icube; icube.open(in, "r"); calParam = new CalParameters(in, &icube); Progress prog; // If the file has already been calibrated, throw an error Loading Loading @@ -98,15 +97,13 @@ void IsisMain() { p.EndProcess(); } void cal(vector<Buffer *> &in, vector<Buffer *> &out) { void cal(vector<Buffer *> &in, vector<Buffer *> &out) { Buffer &inp = *in[0]; // Input Cube Buffer &dcf = *in[1]; // Dark Current File Buffer &fff = *in[2]; // Flat Field File Buffer &outp = *out[0]; // Output Cube // Loop for each pixel in the line. for(int i = 0; i < inp.size(); i++) { if(IsSpecial(inp[i])) { Loading
isis/src/viking/apps/vikcal/tsts/default/Makefile +2 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,5 @@ include $(ISISROOT)/make/isismake.tsts commands: $(APPNAME) from=$(INPUT)/f387a06.cub \ to=$(OUTPUT)/vikcalTruth.cub > /dev/null; $(APPNAME) from=$(INPUT)/f319b18.cub \ to=$(OUTPUT)/vikcalCameraTruth.cub > /dev/null;
isis/src/viking/apps/vikcal/vikcal.xml +5 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ <change name="Christopher Austin" date="2010-06-16"> Fixed pvl comments </change> <change name="Stuart Sides" date="2021-02-22"> Added ability to calibrate using the camera instead of direcly using SPICE kernels </change> </history> <groups> Loading