From 32cb4697a1a35dc9c739a0e27aba6a5dea5b4265 Mon Sep 17 00:00:00 2001 From: Kristin Date: Thu, 25 Apr 2019 08:18:36 -0700 Subject: [PATCH] Cassini ALE driver. (#110) * Add getPosition with coefficients * Add some exceptions and associated test * remove debug statements and change test name * Updated to use gsl for polynomial evaluation and separated out into a helper function. Swapped order of coeffs, other changes in response to review comments * Added a couple of suggested tests and updated documentation * Inital work toward ALE cassini driver * Updated comments in base.py and removed notebook from this PR * Update mk location to be accessible beyond my computer * remove newlines * Update name of Cassini ISS Ale driver * Update comment based on feedback --- ale/config.py | 3 ++- ale/drivers/base.py | 6 +++++- ale/drivers/cassini_drivers.py | 34 +++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ale/config.py b/ale/config.py index 9be30c3..2aa91b1 100644 --- a/ale/config.py +++ b/ale/config.py @@ -4,8 +4,9 @@ Config File # Directory with metakernals spice_root = "/data/spice/" -cassini = '/data/big/spice/co-s_j_e_v-spice-6-v1.0/cosp_1000/extras/mk' +cassini = '/usgs/cpkgs/isis3/data/cassini/kernels/mk/' # Cassini ISS mdis = '/data/spice/mess-e_v_h-spice-6-v1.0/messsp_1000/extras/mk' # Messenger mro = '/data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk' # Mars Reconnaissance Orbiter kaguya = '/data/spice/SELENE/kernels/mk/' dawn = '/data/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk' + diff --git a/ale/drivers/base.py b/ale/drivers/base.py index 790ad26..5dd538a 100644 --- a/ale/drivers/base.py +++ b/ale/drivers/base.py @@ -577,7 +577,11 @@ class Pds3Label(): @property def _exposure_duration(self): - return self.label['EXPOSURE_DURATION'].value * 0.001 + # The EXPOSURE_DURATION may either be stored as a (value, unit) or just a value + try: + return self.label['EXPOSURE_DURATION'].value * 0.001 + except: + return self.label['EXPOSURE_DURATION'] * 0.001 class NaifSpice(): diff --git a/ale/drivers/cassini_drivers.py b/ale/drivers/cassini_drivers.py index a424b07..12f42e4 100644 --- a/ale/drivers/cassini_drivers.py +++ b/ale/drivers/cassini_drivers.py @@ -6,11 +6,11 @@ import spiceypy as spice import numpy as np from ale import config -from ale.drivers.base import Framer, RadialDistortion, Driver, Pds3, NaifSpice +from ale.drivers.base import Framer, RadialDistortion, Driver, Pds3Label, NaifSpice - -class CassiniIssPds3NaifSpiceDriver(Driver, Pds3, NaifSpice, Framer, RadialDistortion): +class CassiniIssPds3LabelNaifSpiceDriver(Driver, Pds3Label, NaifSpice, Framer, RadialDistortion): """ + Cassini mixin class for defining Spice calls. """ id_lookup = { "ISSNA" : "CASSINI_ISS_NAC", @@ -28,19 +28,20 @@ class CassiniIssPds3NaifSpiceDriver(Driver, Pds3, NaifSpice, Framer, RadialDisto Path to latest metakernel file """ metakernel_dir = config.cassini + mks = sorted(glob(os.path.join(metakernel_dir,'*.tm'))) if not hasattr(self, '_metakernel'): for mk in mks: - if str(self.start_time.year) in os.path.basename(mk): - self._metakernel = mk + if str(self.start_time.year) in os.path.basename(mk): + self._metakernel = mk return self._metakernel @property def instrument_id(self): """ Returns an instrument id for unquely identifying the instrument, but often - also used to be piped into Spice Kernels to acquire IKIDs. Therefore they - the same ID the Spice expects in bods2c calls. + also used to be piped into Spice Kernels to acquire instrument kernel (IK) NAIF IDs. + Therefore they use the same NAIF ID asin bods2c calls. Returns ------- @@ -73,12 +74,7 @@ class CassiniIssPds3NaifSpiceDriver(Driver, Pds3, NaifSpice, Framer, RadialDisto return [0.0, 0.0, 1/pixel_size] @property - def _exposure_duration(self): - # labels do not specify a unit explicitly - return self.label['EXPOSURE_DURATION'] * 0.001 # Scale to seconds - - @property - def odtk(self): + def _odtk(self): """ The radial distortion coeffs are not defined in the ik kernels, instead they are defined in the ISS Data User Guide (Knowles). Therefore, we @@ -90,3 +86,15 @@ class CassiniIssPds3NaifSpiceDriver(Driver, Pds3, NaifSpice, Framer, RadialDisto elif self.instrument_id == 'CASSINI_ISS_NAC': # NAC return [float('-8e-6'), 0, 0] + + @property + # FOV_CENTER_PIXEL doesn't specify which coordinate is sample or line, but they are the same + # number, so the order doesn't matter + def _detector_center_line(self): + return float(spice.gdpool('INS{}_FOV_CENTER_PIXEL'.format(self.ikid), 0, 2)[1]) + + @property + # FOV_CENTER_PIXEL doesn't specify which coordinate is sample or line, but they are the same + # number, so the order doesn't matter + def _detector_center_sample(self): + return float(spice.gdpool('INS{}_FOV_CENTER_PIXEL'.format(self.ikid), 0, 2)[0]) -- GitLab