Loading isis/src/messenger/apps/mdiscal/MdisCalUtils.h +90 −38 Original line number Diff line number Diff line Loading @@ -13,10 +13,14 @@ find files of those names at the top level of this repository. **/ #include <string> #include <vector> #include "Camera.h" #include "CSVReader.h" #include "FileName.h" #include "IString.h" #include "iTime.h" #include "NaifStatus.h" #include "Spice.h" /** * @author ????-??-?? Kris Becker * Loading Loading @@ -89,6 +93,7 @@ namespace Isis { return; } /** * @brief Computes the distance from the Sun to the observed body * Loading @@ -99,9 +104,18 @@ namespace Isis { */ static bool sunDistanceAU(const QString &scStartTime, const QString &target, double &sunDist) { double &sunDist, Cube *cube) { try { Camera *cam; cam = cube->camera(); cam->SetImage(0.5, 0.5); sunDist = cam->sunToBodyDist() / 1.49597870691E8; } catch (IException &e) { try { // Ensure NAIF kernels are loaded NaifStatus::CheckErrors(); loadNaifTiming(); sunDist = 1.0; Loading @@ -114,6 +128,7 @@ namespace Isis { // Convert starttime to et double obsStartTime; scs2e_c(-236, scStartTime.toLatin1().data(), &obsStartTime); NaifStatus::CheckErrors(); // Get the vector from target to sun and determine its length double sunv[3]; Loading @@ -124,9 +139,19 @@ namespace Isis { // Return in AU units sunDist = sunkm / 1.49597870691E8; } catch (IException &e) { QString message = "Unable to determine the sun-target distance."; throw IException(e, IException::Unknown, message, _FILEINFO_); } } return (true); } /** * Load WAC CSV. */ std::vector<double> loadWACCSV(const QString &fname, int filter, int nvalues, bool header=true, int skip=0) { // Open the CSV file Loading Loading @@ -159,6 +184,9 @@ namespace Isis { } /** * Load NAC CSV. */ std::vector<double> loadNACCSV(const QString &fname, int nvalues, bool header=true, int skip=0) { // Open the CSV file Loading @@ -180,6 +208,9 @@ namespace Isis { } /** * Load responsivity */ std::vector<double> loadResponsivity(bool isNAC, bool binned, int filter, QString &fname) { Loading @@ -205,6 +236,9 @@ namespace Isis { } /** * Load solar irradiation */ std::vector<double> loadSolarIrr(bool isNAC, bool binned, int filter, QString &fname) { Loading @@ -225,6 +259,10 @@ namespace Isis { } } /** * Loads the smear component */ double loadSmearComponent(bool isNAC, int filter, QString &fname) { FileName smearfile(fname); Loading @@ -246,6 +284,7 @@ namespace Isis { return (smear[0]); } /** * @brief Load and retrieve empirical correction factor * Loading Loading @@ -319,7 +358,7 @@ namespace Isis { * to WAC filter data. */ double loadEmpiricalCorrection(const QString &scStartTime, const int filter, QString &ename, QString &eDate) { QString &ename, QString &eDate, Cube *cube) { // This table maps the filter number extracted from BandBin/Number keyword // to the columns (index) in the empirical correction table Loading Loading @@ -363,12 +402,27 @@ namespace Isis { throw IException(IException::User, mess, _FILEINFO_); } double obsStartTime = 0.0; try { Camera *cam = cube->camera(); obsStartTime = cam->getClockTime(scStartTime, -236).Et(); } catch (IException &e) { try { // Ensure NAIF kernels are loaded for NAIF time computations NaifStatus::CheckErrors(); loadNaifTiming(); // Convert s/c clock start time to et double obsStartTime; scs2e_c(-236, scStartTime.toLatin1().data(), &obsStartTime); NaifStatus::CheckErrors(); } catch (IException &e) { QString message = "Could not convert spacecraft clock start count to ET."; throw IException(e, IException::Unknown, message, _FILEINFO_); } } // Set initial conditions and loop through all rows in the event table double evalue = 1.0; Loading @@ -378,8 +432,7 @@ namespace Isis { CSVReader::CSVAxis eRow = csv.getRow(i); QString utcTime = eRow[0]; double eTime; utc2et_c(utcTime.toLatin1().data(), &eTime); eTime = iTime(utcTime.toLatin1().data()).Et(); // If current time is greater than start time this is the post event case if (eTime > obsStartTime) { // Get closest pre or post event correction factor Loading @@ -402,6 +455,5 @@ namespace Isis { return (evalue); } }; #endif isis/src/messenger/apps/mdiscal/main.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -315,7 +315,7 @@ void IsisMain() { empiricalCorrectionFile = ""; g_empiricalCorrectionFactor = loadEmpiricalCorrection(startTime, g_filterNumber + 1, empiricalCorrectionFile, empiricalCorrectionDate); empiricalCorrectionDate, icube); empiricalCorrectionFactor = toString(g_empiricalCorrectionFactor); } else { Loading @@ -335,7 +335,7 @@ void IsisMain() { PvlGroup& inst = icube->group("Instrument"); QString target = inst["TargetName"]; QString startTime = inst["SpacecraftClockCount"]; if (sunDistanceAU(startTime, target, g_solarDist)) { if (sunDistanceAU(startTime, target, g_solarDist, icube)) { vector<double> sol = loadSolarIrr(g_isNarrowAngleCamera, g_isBinnedData, g_filterNumber + 1, solirrfile); g_Ff = sol[2]; Loading isis/src/messenger/apps/mdiscal/mdiscal.xml +4 −0 Original line number Diff line number Diff line Loading @@ -655,6 +655,10 @@ was applied. This will change the output DNs for any images where FLATFIELD=false. Updated documentation. Fixes #2338 </change> <change name="Kristin Berry" date="2021-02-26"> Updated to use camera for the target-sun distance and clock time to ET conversion, if possible. This enables the program to be run without local spice kernels (the spice server can be used for spiceinit.) </change> </history> <groups> Loading isis/src/messenger/apps/mdiscal/tsts/contamination/Makefile +15 −0 Original line number Diff line number Diff line Loading @@ -11,12 +11,14 @@ commands: catlab \ from=$(OUTPUT)/pre_contamination.cub \ to=$(OUTPUT)/pre_contamination_label.pvl > /dev/null; # contamination day 1, iof=true $(APPNAME) from=$(INPUT)/EW0217136166F.cub \ to=$(OUTPUT)/contamination_day_1.cub \ iof=true > /dev/null; catlab from=$(OUTPUT)/contamination_day_1.cub \ to=$(OUTPUT)/contamination_day_1_label.pvl > /dev/null; # more contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0217310049F.cub \ Loading @@ -25,6 +27,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jun_2011_iof.cub \ to=$(OUTPUT)/contamination_jun_2011_iof_label.pvl > /dev/null; # more contamination, iof=false $(APPNAME) \ from=$(INPUT)/EW0217310055G.cub \ Loading @@ -33,6 +36,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jun_2011_ra.cub \ to=$(OUTPUT)/contamination_jun_2011_ra_label.pvl > /dev/null; # even more contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0234069364C.cub \ Loading @@ -41,6 +45,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jan_2012_last_day.cub \ to=$(OUTPUT)/contamination_jan_2012_last_day_label.pvl > /dev/null; # post contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0234155897G.cub \ Loading @@ -49,6 +54,7 @@ commands: catlab \ from=$(OUTPUT)/post_contamination.cub \ to=$(OUTPUT)/post_contamination_label.pvl > /dev/null; # contamination day 1, iof=true, no empirical correction performed $(APPNAME) from=$(INPUT)/EW0217136166F.cub \ to=$(OUTPUT)/contamination_day_1_no_ec.cub \ Loading @@ -56,6 +62,7 @@ commands: ecf=false > /dev/null; catlab from=$(OUTPUT)/contamination_day_1_no_ec.cub \ to=$(OUTPUT)/contamination_day_1_no_ec_label.pvl > /dev/null; # post contamination, iof=true, no empirical correction performed $(APPNAME) \ from=$(INPUT)/EW0234155897G.cub \ Loading @@ -65,6 +72,7 @@ commands: catlab \ from=$(OUTPUT)/post_contamination_no_ec.cub \ to=$(OUTPUT)/post_contamination_no_ec_label.pvl > /dev/null; # NAC contamination, iof=true, no empirical correction (because NAC) $(APPNAME) \ from=$(INPUT)/EN0228199579M.cub \ Loading @@ -74,4 +82,11 @@ commands: from=$(OUTPUT)/contamination_NAC.cub \ to=$(OUTPUT)/contamination_NAC_label.pvl > /dev/null; # Test going through the camera model for sun distance and start time $(APPNAME) from=$(INPUT)/EW0217136166F.spiceinited.cub \ to=$(OUTPUT)/contamination_day_1.spiceinited.cub \ iof=true > /dev/null; catlab from=$(OUTPUT)/contamination_day_1.spiceinited.cub \ to=$(OUTPUT)/contamination_day_1_label.spiceinited.pvl > /dev/null; Loading
isis/src/messenger/apps/mdiscal/MdisCalUtils.h +90 −38 Original line number Diff line number Diff line Loading @@ -13,10 +13,14 @@ find files of those names at the top level of this repository. **/ #include <string> #include <vector> #include "Camera.h" #include "CSVReader.h" #include "FileName.h" #include "IString.h" #include "iTime.h" #include "NaifStatus.h" #include "Spice.h" /** * @author ????-??-?? Kris Becker * Loading Loading @@ -89,6 +93,7 @@ namespace Isis { return; } /** * @brief Computes the distance from the Sun to the observed body * Loading @@ -99,9 +104,18 @@ namespace Isis { */ static bool sunDistanceAU(const QString &scStartTime, const QString &target, double &sunDist) { double &sunDist, Cube *cube) { try { Camera *cam; cam = cube->camera(); cam->SetImage(0.5, 0.5); sunDist = cam->sunToBodyDist() / 1.49597870691E8; } catch (IException &e) { try { // Ensure NAIF kernels are loaded NaifStatus::CheckErrors(); loadNaifTiming(); sunDist = 1.0; Loading @@ -114,6 +128,7 @@ namespace Isis { // Convert starttime to et double obsStartTime; scs2e_c(-236, scStartTime.toLatin1().data(), &obsStartTime); NaifStatus::CheckErrors(); // Get the vector from target to sun and determine its length double sunv[3]; Loading @@ -124,9 +139,19 @@ namespace Isis { // Return in AU units sunDist = sunkm / 1.49597870691E8; } catch (IException &e) { QString message = "Unable to determine the sun-target distance."; throw IException(e, IException::Unknown, message, _FILEINFO_); } } return (true); } /** * Load WAC CSV. */ std::vector<double> loadWACCSV(const QString &fname, int filter, int nvalues, bool header=true, int skip=0) { // Open the CSV file Loading Loading @@ -159,6 +184,9 @@ namespace Isis { } /** * Load NAC CSV. */ std::vector<double> loadNACCSV(const QString &fname, int nvalues, bool header=true, int skip=0) { // Open the CSV file Loading @@ -180,6 +208,9 @@ namespace Isis { } /** * Load responsivity */ std::vector<double> loadResponsivity(bool isNAC, bool binned, int filter, QString &fname) { Loading @@ -205,6 +236,9 @@ namespace Isis { } /** * Load solar irradiation */ std::vector<double> loadSolarIrr(bool isNAC, bool binned, int filter, QString &fname) { Loading @@ -225,6 +259,10 @@ namespace Isis { } } /** * Loads the smear component */ double loadSmearComponent(bool isNAC, int filter, QString &fname) { FileName smearfile(fname); Loading @@ -246,6 +284,7 @@ namespace Isis { return (smear[0]); } /** * @brief Load and retrieve empirical correction factor * Loading Loading @@ -319,7 +358,7 @@ namespace Isis { * to WAC filter data. */ double loadEmpiricalCorrection(const QString &scStartTime, const int filter, QString &ename, QString &eDate) { QString &ename, QString &eDate, Cube *cube) { // This table maps the filter number extracted from BandBin/Number keyword // to the columns (index) in the empirical correction table Loading Loading @@ -363,12 +402,27 @@ namespace Isis { throw IException(IException::User, mess, _FILEINFO_); } double obsStartTime = 0.0; try { Camera *cam = cube->camera(); obsStartTime = cam->getClockTime(scStartTime, -236).Et(); } catch (IException &e) { try { // Ensure NAIF kernels are loaded for NAIF time computations NaifStatus::CheckErrors(); loadNaifTiming(); // Convert s/c clock start time to et double obsStartTime; scs2e_c(-236, scStartTime.toLatin1().data(), &obsStartTime); NaifStatus::CheckErrors(); } catch (IException &e) { QString message = "Could not convert spacecraft clock start count to ET."; throw IException(e, IException::Unknown, message, _FILEINFO_); } } // Set initial conditions and loop through all rows in the event table double evalue = 1.0; Loading @@ -378,8 +432,7 @@ namespace Isis { CSVReader::CSVAxis eRow = csv.getRow(i); QString utcTime = eRow[0]; double eTime; utc2et_c(utcTime.toLatin1().data(), &eTime); eTime = iTime(utcTime.toLatin1().data()).Et(); // If current time is greater than start time this is the post event case if (eTime > obsStartTime) { // Get closest pre or post event correction factor Loading @@ -402,6 +455,5 @@ namespace Isis { return (evalue); } }; #endif
isis/src/messenger/apps/mdiscal/main.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -315,7 +315,7 @@ void IsisMain() { empiricalCorrectionFile = ""; g_empiricalCorrectionFactor = loadEmpiricalCorrection(startTime, g_filterNumber + 1, empiricalCorrectionFile, empiricalCorrectionDate); empiricalCorrectionDate, icube); empiricalCorrectionFactor = toString(g_empiricalCorrectionFactor); } else { Loading @@ -335,7 +335,7 @@ void IsisMain() { PvlGroup& inst = icube->group("Instrument"); QString target = inst["TargetName"]; QString startTime = inst["SpacecraftClockCount"]; if (sunDistanceAU(startTime, target, g_solarDist)) { if (sunDistanceAU(startTime, target, g_solarDist, icube)) { vector<double> sol = loadSolarIrr(g_isNarrowAngleCamera, g_isBinnedData, g_filterNumber + 1, solirrfile); g_Ff = sol[2]; Loading
isis/src/messenger/apps/mdiscal/mdiscal.xml +4 −0 Original line number Diff line number Diff line Loading @@ -655,6 +655,10 @@ was applied. This will change the output DNs for any images where FLATFIELD=false. Updated documentation. Fixes #2338 </change> <change name="Kristin Berry" date="2021-02-26"> Updated to use camera for the target-sun distance and clock time to ET conversion, if possible. This enables the program to be run without local spice kernels (the spice server can be used for spiceinit.) </change> </history> <groups> Loading
isis/src/messenger/apps/mdiscal/tsts/contamination/Makefile +15 −0 Original line number Diff line number Diff line Loading @@ -11,12 +11,14 @@ commands: catlab \ from=$(OUTPUT)/pre_contamination.cub \ to=$(OUTPUT)/pre_contamination_label.pvl > /dev/null; # contamination day 1, iof=true $(APPNAME) from=$(INPUT)/EW0217136166F.cub \ to=$(OUTPUT)/contamination_day_1.cub \ iof=true > /dev/null; catlab from=$(OUTPUT)/contamination_day_1.cub \ to=$(OUTPUT)/contamination_day_1_label.pvl > /dev/null; # more contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0217310049F.cub \ Loading @@ -25,6 +27,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jun_2011_iof.cub \ to=$(OUTPUT)/contamination_jun_2011_iof_label.pvl > /dev/null; # more contamination, iof=false $(APPNAME) \ from=$(INPUT)/EW0217310055G.cub \ Loading @@ -33,6 +36,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jun_2011_ra.cub \ to=$(OUTPUT)/contamination_jun_2011_ra_label.pvl > /dev/null; # even more contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0234069364C.cub \ Loading @@ -41,6 +45,7 @@ commands: catlab \ from=$(OUTPUT)/contamination_jan_2012_last_day.cub \ to=$(OUTPUT)/contamination_jan_2012_last_day_label.pvl > /dev/null; # post contamination, iof=true $(APPNAME) \ from=$(INPUT)/EW0234155897G.cub \ Loading @@ -49,6 +54,7 @@ commands: catlab \ from=$(OUTPUT)/post_contamination.cub \ to=$(OUTPUT)/post_contamination_label.pvl > /dev/null; # contamination day 1, iof=true, no empirical correction performed $(APPNAME) from=$(INPUT)/EW0217136166F.cub \ to=$(OUTPUT)/contamination_day_1_no_ec.cub \ Loading @@ -56,6 +62,7 @@ commands: ecf=false > /dev/null; catlab from=$(OUTPUT)/contamination_day_1_no_ec.cub \ to=$(OUTPUT)/contamination_day_1_no_ec_label.pvl > /dev/null; # post contamination, iof=true, no empirical correction performed $(APPNAME) \ from=$(INPUT)/EW0234155897G.cub \ Loading @@ -65,6 +72,7 @@ commands: catlab \ from=$(OUTPUT)/post_contamination_no_ec.cub \ to=$(OUTPUT)/post_contamination_no_ec_label.pvl > /dev/null; # NAC contamination, iof=true, no empirical correction (because NAC) $(APPNAME) \ from=$(INPUT)/EN0228199579M.cub \ Loading @@ -74,4 +82,11 @@ commands: from=$(OUTPUT)/contamination_NAC.cub \ to=$(OUTPUT)/contamination_NAC_label.pvl > /dev/null; # Test going through the camera model for sun distance and start time $(APPNAME) from=$(INPUT)/EW0217136166F.spiceinited.cub \ to=$(OUTPUT)/contamination_day_1.spiceinited.cub \ iof=true > /dev/null; catlab from=$(OUTPUT)/contamination_day_1.spiceinited.cub \ to=$(OUTPUT)/contamination_day_1_label.spiceinited.pvl > /dev/null;