Commit 25da26ee authored by acpaquette's avatar acpaquette Committed by Jesse Mapel
Browse files

Voyager ISIS NaifSpice Class (#267)

* Adds voyager driver and associated tests

* Dictionary diff changes and isis_formatter updates

* Removed unnecessary imports from MRO driver

* Removed voyager playground notebook

* Removed comments on test data.

* Added comments to isis_formatter

* Updated tests based on changes to the isis_formatter

* Updated sun_position again for light time correction
parent a1748cf2
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
from glob import glob
import os

import numpy as np
import pvl
import spiceypy as spice

from ale.base import Driver
+46 −0
Original line number Diff line number Diff line
import spiceypy as spice

import ale
from ale.base.data_naif import NaifSpice
from ale.base.label_isis import IsisLabel
from ale.base.type_sensor import Framer
from ale.base.base import Driver

class Voyager2IssnacIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver):

    @property
    def sensor_model_version(self):
        return 1

    @property
    def ikid(self):
        return self.label['IsisCube']['Kernels']['NaifFrameCode']

    @property
    def spacecraft_name(self):
        return super().spacecraft_name.replace('_', ' ')

    @property
    def pixel_size(self):
        return spice.gdpool('INS{}_PIXEL_PITCH'.format(self.ikid), 0, 1)[0]

    @property
    def detector_center_sample(self):
        return 499.5

    @property
    def detector_center_line(self):
        return 499.5

    @property
    def ephemeris_start_time(self):
        inital_time = spice.utc2et(self.utc_start_time.isoformat())
        # To get shutter end (close) time, subtract 2 seconds from the start time
        updated_time = inital_time - 2
        # To get shutter start (open) time, take off the exposure duration from the end time.
        start_time = updated_time - self.exposure_duration
        return start_time

    @property
    def ephemeris_stop_time(self):
        return self.ephemeris_start_time + self.exposure_duration
+11 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ def to_isis(driver):

    frame_chain = driver.frame_chain
    sensor_frame = driver.sensor_frame_id
    target_frame = driver.target_frame_id

    instrument_pointing = {}
    source_frame, destination_frame, time_dependent_sensor_frame = frame_chain.last_time_dependent_frame_between(sensor_frame, 1)
@@ -39,7 +40,7 @@ def to_isis(driver):
        instrument_pointing['CkTableEndTime'] = time_dependent_rotation.times[-1]
        instrument_pointing['CkTableOriginalSize'] = len(time_dependent_rotation.times)
        instrument_pointing['EphemerisTimes'] = time_dependent_rotation.times
        instrument_pointing['Quaternions'] = time_dependent_rotation.quats
        instrument_pointing['Quaternions'] = time_dependent_rotation.quats[:, [3, 0, 1, 2]]

    if source_frame != sensor_frame:
        # Reverse the frame order because ISIS orders frames as
@@ -62,7 +63,7 @@ def to_isis(driver):
        body_rotation['CkTableEndTime'] = time_dependent_rotation.times[-1]
        body_rotation['CkTableOriginalSize'] = len(time_dependent_rotation.times)
        body_rotation['EphemerisTimes'] = time_dependent_rotation.times
        body_rotation['Quaternions'] = time_dependent_rotation.quats
        body_rotation['Quaternions'] = time_dependent_rotation.quats[:, [3, 0, 1, 2]]

    if source_frame != target_frame:
        # Reverse the frame order because ISIS orders frames as
@@ -72,13 +73,18 @@ def to_isis(driver):
        body_rotation['ConstantRotation'] = constant_rotation.rotation_matrix()
    meta_data['BodyRotation'] = body_rotation

    j2000_rotation = frame_chain.compute_rotation(target_frame, 1)

    instrument_position = {}
    positions, velocities, times = driver.sensor_position
    instrument_position['SpkTableStartTime'] = times[0]
    instrument_position['SpkTableEndTime'] = times[-1]
    instrument_position['SpkTableOriginalSize'] = len(times)
    instrument_position['EphemerisTimes'] = times
    # Rotate positions and velocities into J2000 then scale into kilometers
    positions = j2000_rotation._rots.apply(positions) * 1/1000
    instrument_position['Positions'] = positions
    velocities = j2000_rotation._rots.apply(velocities) * 1/1000
    instrument_position['Velocities'] = velocities
    meta_data['InstrumentPosition'] = instrument_position

@@ -88,7 +94,10 @@ def to_isis(driver):
    sun_position['SpkTableEndTime'] = times[-1]
    sun_position['SpkTableOriginalSize'] = len(times)
    sun_position['EphemerisTimes'] = times
    # Rotate positions and velocities into J2000 then scale into kilometers
    positions = j2000_rotation._rots.apply(positions) * 1/1000
    sun_position['Positions'] = positions
    velocities = j2000_rotation._rots.apply(velocities) * 1/1000
    sun_position['Velocities'] = velocities
    meta_data['SunPosition'] = sun_position

+6 −1
Original line number Diff line number Diff line
@@ -53,11 +53,16 @@ def compare_dicts(ldict, rdict):
        elif isinstance(item, dict):
            differences.extend(compare_dicts(item, rdict[key]))
        elif isinstance(item, np.ndarray) or isinstance(item, list):
            if not np.allclose(item, rdict[key]):
            if len(item) != len(rdict[key]):
                differences.append(f'Array sizes of key {key} are not equal {item} : {rdict[key]}.')
            elif not np.allclose(item, rdict[key]):
                differences.append(f'Array values of key {key} are not almost equal {item} : {rdict[key]}.')
        elif isinstance(item, str):
            if item.lower() != rdict[key].lower():
                differences.append(f'Values of key {key} are not equal {item} : {rdict[key]}.')
        elif isinstance(item, float):
            if not np.isclose(item, rdict[key]):
                differences.append(f'Floating point values of key {key} are not close {item} : {rdict[key]}.')
        else:
            if item != rdict[key]:
                differences.append(f'Values of key {key} are not equal {item} : {rdict[key]}.')
+313 −0
Original line number Diff line number Diff line
DAFETF NAIF DAF ENCODED TRANSFER FILE
'DAF/SPK '
'2'
'6'
'SPKMERGE                                                    '
BEGIN_ARRAY 1 73
'vgr2.jup230.nio                         '
'-268682B620CCB6^8'
'-26868248B89B8E^8'
'-20'
'5'
'1'
'1'
73
'-268678A5686616^8'
'25916465F18^3'
'4B22C8CBE3^3'
'70B42D31D48^3'
'96459197C6^3'
'BBD6F5FDB78^3'
'E1685A63A9^3'
'106F9BEC99A8^4'
'12C8B232F8C^4'
'1521C87957D8^4'
'177ADEBFB6F^4'
'19D3F5061608^4'
'1C2D0B4C752^4'
'1E862192D438^4'
'20DF37D9335^4'
'22F5848987D8^4'
'C2FC644744EFB^5'
'-B3432192102D4^1'
'31A592866722C6^5'
'E889FE17C5FD68^1'
'2A50F1952FDD5A^4'
'55AF1A8C9670EC^1'
'-BD662468F31E9^-3'
'-16A4791851D6BA^-4'
'C54ED3F7EFD898^-6'
'E3F30CCA10841^-7'
'600F91F179A8D^-8'
'-53EE605162DC2^-9'
'-CE9D29CFE67E9^-A'
'-AD04F814FC438^-B'
'B68B10BD4D5128^-C'
'3782ADB61D61F4^-C'
'-453^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'-30549DE66F5572^-3'
'-2CC692E8E6F9C4^-4'
'-10CE9EB80EC8D7^-5'
'16FBF23FD6EEA8^-7'
'99C789514C723^-8'
'997F47DC7FA32^-9'
'-4C7C644E2A3F8^-B'
'-BE1BBC7DF23D28^-B'
'-1DEA95318BD173^-B'
'225D7E804C3D4C^-C'
'5D9C^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'-28F2C569428D9A^-4'
'-CAAE40E5EDCFC8^-5'
'-61ED097D4C432C^-6'
'-8E0F5BE9121BD^-8'
'2AD8D3057CB6A8^-8'
'3317F6F73934A2^-9'
'16CAE603541464^-A'
'-3D40319F847542^-B'
'-4E04BCEC50DE2^-C'
'-15C569^-C'
'-3D012^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'B^1'
'A^1'
'A^1'
'A^1'
'-268678A5686616^8'
'1^1'
END_ARRAY 1 73
BEGIN_ARRAY 2 39
'DE-0431LE-0431                          '
'-268682B620CCB6^8'
'-26868248B89B8E^8'
'A'
'0'
'1'
'2'
39
'-269088C^8'
'A8C^5'
'1036772F22158D^6'
'18520B546527D9^4'
'-123EC5F26719B2^2'
'-EAE7FE3B6D6248^-1'
'-8E75D3EA1579A^-2'
'30B01940D73CFA^-3'
'C7DBFD61A86F2^-4'
'-151407AC91072C^-4'
'1FA2B483D7B264^-5'
'-22AEF4C4E163B6^-6'
'131A2D3375957C^-7'
'-3FF2EA1822D7BC^5'
'1C9BE917E4395^4'
'FC3DF7A05A98^1'
'FCEC8DF00A194^-2'
'-16314915EB1BBF^-2'
'-CAA73D95DA7298^-3'
'CE74D5261F4228^-4'
'-5F18550189B6FC^-5'
'-47C00DFE121034^-6'
'1CBE366E63A72^-6'
'-3C99E46C15DD54^-7'
'-23C583E825259E^5'
'B813BB9FA07548^3'
'73C1462D5A2244^1'
'130D073312C932^-1'
'97B4324F027A48^-3'
'-6BF0B6117C3F6^-3'
'58A2170564FEB4^-4'
'-1068A5CDA2F449^-5'
'-5AD2225860DF2^-6'
'12F5C65C962E3E^-6'
'-2252526866C9AA^-7'
'-269B14C^8'
'1518^6'
'23^2'
'1^1'
END_ARRAY 2 39
BEGIN_ARRAY 3 30
'DE-0431LE-0431                          '
'-268682B620CCB6^8'
'-26868248B89B8E^8'
'5'
'0'
'1'
'2'
30
'-2685FCC^8'
'1518^6'
'-23095B332579FA^8'
'-BD0582AF46C1A^6'
'11F8B950533C7D^5'
'E0CF1ED698767^2'
'-DE910C6039DAB8^0'
'-D0EC0A68256368^-3'
'2EABE8DE25B6AA^-4'
'C5A62EF855D028^-6'
'1D1D34F9A2E441^8'
'-B1003A8467DEE8^6'
'-EEC155443E2CE^4'
'10DD92E3CBAEA3^3'
'68E3D00022799^0'
'-79F7AC590D0B54^-2'
'3AD219638752D^-4'
'5C987F0EEBA05^-6'
'D55803DFEFB728^7'
'-47450EAF2DCFF4^6'
'-6D5AB1CF7571C8^4'
'6E33FF1B5945B^2'
'3264EC9678848C^0'
'-33FB4F3A7AECDA^-2'
'17333AFBD6BF22^-4'
'2A595FECAAF3EA^-6'
'-269B14C^8'
'2A3^6'
'1A^2'
'1^1'
END_ARRAY 3 30
BEGIN_ARRAY 4 102
'JUP310                                  '
'-268682B620CCB6^8'
'-26868248B89B8E^8'
'1F6'
'5'
'1'
'3'
102
'-2686A58^8'
'A8C^4'
'80928DA8D49C48^5'
'1A96D3AD15B1FF^5'
'-1DD13A955C794E^5'
'-F42565138B14D^3'
'8600FC63A15AA^3'
'2E359A8A2A6A^2'
'-10F860113328^2'
'-5F453D12F^0'
'1AD15E13E^0'
'A57AEA6E^-2'
'-30C6904C^-2'
'560B1EA^-3'
'11E29E8^-3'
'-EEEAC6^-4'
'-3D4A48^-4'
'22819^-4'
'-18730B7666B72D^5'
'7485590CE627A^5'
'5A6A3A2E4E758^4'
'-4174BDE7E297D8^4'
'-1A7CBD49468ADC^3'
'B746D05E3BAC^2'
'3E2A1BCC211^1'
'-136638FC9E^1'
'-92491EAD^-1'
'221601778^-1'
'3179DB99^-2'
'-471D2F8^-3'
'-37C04^-3'
'-40183^-4'
'666966^-4'
'1B2E08^-4'
'-ACE8560407FC9^4'
'382C29EC88D498^5'
'27F4863216E25C^4'
'-1F8EB6F1928054^4'
'-BBFA4E9BFF61E^2'
'58629BD36D6E^2'
'1BE7BB88EB4^1'
'-95C23E6648^0'
'-438526F52^-1'
'1053B1248^-1'
'17D969F6C^-2'
'-1D2A548^-3'
'-1B04FC2^-3'
'-29953C^-4'
'3044E4^-4'
'EBCBC^-5'
'2414BC048F2984^1'
'-AEA867604BB03^1'
'-882F2B0F9C844^0'
'64728DE93EA83^0'
'2B52E4C49EDFC2^-1'
'-13269A93F868AD^-1'
'-7D52BC7C11111^-3'
'28546E8856789A^-3'
'123B83C5C28F5C^-4'
'-5A95C1CEB24078^-5'
'94CDC0DA740DA^-6'
'1E877A4FA4FA5^-6'
'-1EAD2FC3518A6E^-6'
'-A2B6CA8641FDB8^-7'
'622693E93E93E4^-7'
'0^0'
'9E7BF3CED5C448^1'
'210D54DAF7665A^1'
'-24908BD4F06EB^1'
'-13D16EC42CD0A1^0'
'AC2D9288826EB8^-1'
'45E23BA79A375C^-2'
'-1986A05EF08B91^-2'
'-D87C6F4CD2DE4^-4'
'39930050AFF9EC^-4'
'56F445B302A7A^-5'
'-9961C2F0734B7^-6'
'-6DDF26D3A06D38^-6'
'-50B17CC6BB5AA^-7'
'10FE256789ABCE^-6'
'4D4FBBBBBBBBB8^-7'
'0^0'
'4C66CFD04FC0C4^1'
'E9AA34D6FD888^0'
'-11A0DBC7C72359^1'
'-8C9FE68E36C6B8^-1'
'53084FDF433D6C^-1'
'1F5C2AD53F17E5^-2'
'-C510AC853A06D8^-3'
'-63D0162E6AF37C^-4'
'1B9CB7A02468AC^-4'
'29E2120474CFD4^-5'
'-409FA8641FDB94^-6'
'-3579A7A1F1969^-6'
'-3C97240795CEB^-7'
'8025419CA252B^-7'
'29EB5555555554^-7'
'0^0'
'-26874E4^8'
'1518^5'
'62^2'
'1^1'
END_ARRAY 4 102
TOTAL_ARRAYS 4
 ~NAIF/SPC BEGIN COMMENTS~
; /home/acpaquette/kernel_split/c2065022.spice_0.bsp LOG FILE

; Created 2019-09-04/15:36:34.00.
;
; BEGIN SPKMERGE COMMANDS

LEAPSECONDS_KERNEL   = /usgs/cpkgs/isis3/data/base/kernels/lsk/naif0012.tls

SPK_KERNEL           = /home/acpaquette/kernel_split/c2065022.spice_0.bsp
SOURCE_SPK_KERNEL = /usgs/cpkgs/isis3/data/voyager2/kernels/spk//vgr2_jup230.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = -32
    BEGIN_TIME       = 1979 JUL 09 14:27:35.688
    END_TIME         = 1979 JUL 09 14:29:25.095
  SOURCE_SPK_KERNEL  = /usgs/cpkgs/isis3/data/base/kernels/spk/jup310.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 5, 10, 502
    BEGIN_TIME       = 1979 JUL 09 14:27:35.688
    END_TIME         = 1979 JUL 09 14:29:25.095

; END SPKMERGE COMMANDS
 ~NAIF/SPC END COMMENTS~
Loading