From 1e155f3ca493092bacb1a0d2bddf5b46a207ca4e Mon Sep 17 00:00:00 2001
From: Kelvin Rodriguez <krodriguez@usgs.gov>
Date: Sun, 3 Nov 2024 17:56:22 -0700
Subject: [PATCH] SCLK Bug fixes (#44)

* fixed bug where cks were using interval scope

* fixed sclk bugs
---
 SpiceQL/db/mess.json        |  5 +++--
 SpiceQL/src/spice_types.cpp | 19 ++++++++++++-------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/SpiceQL/db/mess.json b/SpiceQL/db/mess.json
index 9850788..fa5b8dd 100644
--- a/SpiceQL/db/mess.json
+++ b/SpiceQL/db/mess.json
@@ -30,14 +30,15 @@
             "kernels" : "pck00010_msgr_v[0-9]{2}.tpc"
           }
         },
-        "deps" : ["/mdis_att", "/messenger"]
+        "deps" : ["/mdis_att"]
     },
     "mdis_att" : {
         "ck" : {
             "reconstructed" : {
               "kernels" : "msgr_mdis_sc[0-9]{6}_[0-9]{6}_sub_v[0-9]{1}.bc"
             }
-        }
+        },
+        "deps" : ["/messenger"]
     },
     "messenger" : {
         "ck" : {
diff --git a/SpiceQL/src/spice_types.cpp b/SpiceQL/src/spice_types.cpp
index d38e32b..1b56137 100644
--- a/SpiceQL/src/spice_types.cpp
+++ b/SpiceQL/src/spice_types.cpp
@@ -236,15 +236,20 @@ namespace SpiceQL {
       KernelSet sclkSet(sclks);
       KernelSet lskSet(lsks);
       
-      // we want the platforms code, if they passs in an instrument code (e.g. -85600), truncate it to (-85)
-      frameCode = (abs(frameCode / 1000) > 0) ? frameCode/1000 : frameCode; 
-
       SpiceDouble et;
       checkNaifErrors();
-      scs2e_c(frameCode, sclk.c_str(), &et);
-      checkNaifErrors();
-      SPDLOG_DEBUG("strsclktoet({}, {}, {}) -> {}", frameCode, mission, sclk, et);
-      
+      try {
+        scs2e_c(frameCode, sclk.c_str(), &et);
+        checkNaifErrors();
+        SPDLOG_DEBUG("strsclktoet({}, {}, {}) -> {}", frameCode, mission, sclk, et);
+      }
+      catch(exception &e) { 
+        // we want the platforms code, if they passs in an instrument code (e.g. -85600), truncate it to (-85)
+        frameCode = (abs(frameCode / 1000) > 0) ? frameCode/1000 : frameCode;
+        scs2e_c(frameCode, sclk.c_str(), &et);
+        checkNaifErrors();
+        SPDLOG_DEBUG("strsclktoet({}, {}, {}) -> {}", frameCode, mission, sclk, et); 
+      }
       return et;
   }
 
-- 
GitLab