Unverified Commit beafc19a authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

MVIC TDI Driver (#484)

* Added initial Mvic driver

* Fixed imports

* Added in mvic tdi tests

* Added data for mvic load test

* Added doc strings and fixed how instrument_id is obtained

* General small clean up and bringing mvic tdi in line with the mvic framer
parent f45a876f
Loading
Loading
Loading
Loading
+153 −7
Original line number Diff line number Diff line
from glob import glob
import os

import struct
import pvl
import spiceypy as spice
import numpy as np
import spiceypy as spice
import pvl

from ale import util

from ale.base import Driver
from ale.base.type_distortion import NoDistortion, LegendreDistortion
@@ -426,3 +424,151 @@ class NewHorizonsMvicIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Lege
        return {**super().naif_keywords,
                f"INS{self.parent_id}_DISTORTION_COEF_X": self.odtx,
                f"INS{self.parent_id}_DISTORTION_COEF_Y": self.odty}

class NewHorizonsMvicTdiIsisLabelNaifSpiceDriver(LineScanner, IsisLabel, NaifSpice, LegendreDistortion, Driver):
    """
    Driver for reading New Horizons MVIC TDI ISIS3 Labels. These are Labels that have been
    ingested into ISIS from PDS EDR images but have not been spiceinit'd yet.
    """
    @property
    def parent_id(self):
        """
        The base naif id of the spacecraft.  For New Horizons, this is -98000.
        Required for distortion coefficients, which are not unique to instruments,
        but are instead shared by all instruments on the spacecraft + residuals.
        Returns
        -------
        : int
          Naif id of the spacecraft
        """
        return round(self.ikid, -2)

    @property
    def instrument_id(self):
        """
        Returns an instrument id for uniquely 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.

        Returns
        -------
        : str
          instrument id
        """
        id_lookup = {
            "MVIC_TDI" : "ISIS_NH_RALPH_MVIC_METHANE"
        }
        return id_lookup[super().instrument_id]

    @property
    def ikid(self):
        """
        Read the ikid from the cube label
        """
        if not hasattr(self, "_ikid"):
            self._ikid = None
            # Attempt to get the frame code using frame name,
            # If that fails, try to get it directly from the cube label
            try:
                self._ikid = spice.frmname(self.instrument_id)
            except:
                self._ikid = self.label["IsisCube"]["Kernels"]["NaifFrameCode"].value
        return self._ikid

    @property
    def sensor_name(self):
        """
        Returns the name of the instrument

        Returns
        -------
        : str
          Name of the sensor
        """
        return self.label['IsisCube']['Instrument']['InstrumentId']

    @property
    def exposure_duration(self):
        """
        Returns the exposure duration for MVIC TDI cameras

        Returns
        -------
        : float
          The exposure duration
        """
        return (1.0 / self.label["IsisCube"]["Instrument"]["TdiRate"].value)

    @property
    def detector_center_sample(self):
        """
        Returns the center detector sample. This is currently defaulted to 0
        as it is unused in ISIS

        Returns
        -------
        : float
          Detector sample of the principal point
        """
        return 0

    @property
    def detector_center_line(self):
        """
        Returns the center detector line. This is currently defaulted to 0
        as it is unused in ISIS

        Returns
        -------
        : float
          Detector line of the principal point
        """
        return 0

    @property
    def odtx(self):
        """
        Returns the x coefficient for the optical distortion model
        Expects ikid to be defined. This must be the integer Naif id code of the instrument
        Returns
        -------
        : list
          Optical distortion x coefficients
        """
        return spice.gdpool('INS{}_DISTORTION_COEF_X'.format(self.parent_id),0, 20).tolist()

    @property
    def odty(self):
        """
        Returns the y coefficient for the optical distortion model.
        Expects ikid to be defined. This must be the integer Naif id code of the instrument
        Returns
        -------
        : list
          Optical distortion y coefficients
        """
        return spice.gdpool('INS{}_DISTORTION_COEF_Y'.format(self.parent_id), 0, 20).tolist()

    @property
    def naif_keywords(self):
        """
        Adds base NH instrument distortion, which is shared among all instruments on NH.

        Returns
        -------
        : dict
          Dictionary of keywords and values that ISIS creates and attaches to the label
        """
        return {**super().naif_keywords,
                f"INS{self.parent_id}_DISTORTION_COEF_X": self.odtx,
                f"INS{self.parent_id}_DISTORTION_COEF_Y": self.odty}

    @property
    def sensor_model_version(self):
        """
        Returns
        -------
        : int
          ISIS sensor model version
        """
        return 1
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ dependencies:
  - python
  - python-dateutil
  - scipy>=1.4.0
  - spiceypy>=4.0.1
  - spiceypy>=5.1.0
  - pyyaml
  - pytest
  - pytest-cov
+9589 −0

File added.

Preview size limit exceeded, changes collapsed.

+288 −0
Original line number Diff line number Diff line
DAFETF NAIF DAF ENCODED TRANSFER FILE
'DAF/SPK '
'2'
'6'
'SPKMERGE                                                    '
BEGIN_ARRAY 1 73
'nh_20060119_20070319_recon_e2j.nio      '
'D77237C5E0B88^7'
'D77246FDA7608^7'
'-62'
'5'
'1'
'1'
73
'D77272EB37EEA8^7'
'A96D773B3E508^3'
'14007A85374D1^4'
'1C5E60CDAC2988^4'
'22FABE42F8CB18^4'
'28DB1155E77728^4'
'2E143EBC10E57^4'
'32B8D8DDFCF22^4'
'3663FD5148E2E^4'
'394A0727A469C8^4'
'3B9454755B546^4'
'3D6394B2C2C9C8^4'
'3ED19B35736298^4'
'4754A387514B68^4'
'766A1923CD027^4'
'DC1C8B04F7E788^4'
'-1E23600891695D^6'
'-AACCEDAD8DC16^1'
'11D072F6D053E2^6'
'-111FCC7528B7BC^2'
'3553DB9F9D6F3A^5'
'-69192D03CD081^1'
'157034912BB73F^-3'
'57DFC76AB00C5C^-5'
'-864463ED18C0F^-6'
'-71EC573FB83954^-7'
'B8EC1EF05B69E8^-8'
'135AFD14C62C4A^-8'
'-1883DAB72EF2C2^-9'
'-4CB9704EF7BCB8^-A'
'3701360496AA5A^-B'
'16A89A^-B'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'-CAC0D4A0CE72F^-4'
'7C536D1D5A3134^-5'
'5EEF6FA0DC872C^-6'
'-776390560AC278^-7'
'-B2C8F32EE046C^-8'
'D7381AEC2944B8^-9'
'2453B969D995DA^-9'
'-1DBDF2205535DC^-A'
'-9DA90AF436AF6^-B'
'2CBEE8^-C'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'-25EE210E690976^-4'
'3091726D9EE1AA^-5'
'13FEAB70F52EEF^-6'
'-312502AFD6F55C^-7'
'-2B6AB5EAFF4D02^-8'
'61704DCE5856D4^-9'
'9EDE528E5BC748^-A'
'-105852FEC71348^-A'
'-2F795EC26D692A^-B'
'2CF8D693C29DB4^-C'
'F9396^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'C^1'
'9^1'
'9^1'
'B^1'
'D77272EB37EEA8^7'
'1^1'
END_ARRAY 1 73
BEGIN_ARRAY 2 39
'DE-0413LE-0413                          '
'D77237C5E0B88^7'
'D77246FDA7608^7'
'A'
'0'
'1'
'2'
39
'D6D9F4^7'
'A8C^5'
'4BF19A11B9610C^5'
'-19E9E21C5194F9^4'
'-B4B99503C78^1'
'-1B012C9D211^0'
'339F227C2^-1'
'-41E6B733CE^-2'
'-7B02EA2^-3'
'290DDF91^-3'
'-370795^-4'
'-7280AB6^-5'
'26ACF1C^-5'
'918336532181E^5'
'EF3A97F3DB45F8^3'
'-F639A39C9A^1'
'-13D275692C58^0'
'-2F456FC4^-2'
'564DF97A38^-2'
'-E45A188^-3'
'41244B08^-4'
'4792F8^-4'
'-C4A7867^-5'
'2E43CE^-6'
'3B14B17FB640DC^5'
'6DB893E99BE854^3'
'-64C2021EF1^1'
'-8A2102856A8^-1'
'-63A66097^-2'
'35506CBB1D^-2'
'-6D3FA14^-3'
'-215772E^-4'
'2BF02B^-4'
'-5D2D74D8^-5'
'-277101^-6'
'D63134^7'
'1518^6'
'23^2'
'1^1'
END_ARRAY 2 39
BEGIN_ARRAY 3 30
'DE-0413LE-0413                          '
'D77237C5E0B88^7'
'D77246FDA7608^7'
'5'
'0'
'1'
'2'
30
'D63134^7'
'1518^6'
'-13793B80F0E247^8'
'F826FF91D4D07^6'
'9DA91A9F018^4'
'-13D6F80638CC^3'
'-96076878^0'
'3AE6D68^-2'
'4AB8^-4'
'453^-6'
'-282E6C603A6EA4^8'
'-59460001523468^6'
'14553B7990F8^5'
'9C590D7104E^2'
'-AF683C8^0'
'-620C0B3^-2'
'-944^-5'
'-39048^-5'
'-10BFCA6B1ED407^8'
'-2C4EE62DC51A78^6'
'879B50A2D21^4'
'4ABE6B700FF^2'
'-47887D3^0'
'-2B72FFC8^-2'
'-6F8^-5'
'-1967A^-5'
'D4DFB4^7'
'2A3^6'
'1A^2'
'1^1'
END_ARRAY 3 30
BEGIN_ARRAY 4 72
'JUP260                                  '
'D77237C5E0B88^7'
'D77246FDA7608^7'
'257'
'5'
'1'
'3'
72
'D76D9C^7'
'1518^5'
'-887037DCEE036^2'
'-1DFA0A1575197F^2'
'238B5061E0575^2'
'C62154BF84B87^1'
'-7078D3C8246164^1'
'-2451A42A20E886^1'
'DE7B00674EAE4^0'
'2FFB5790F07EF^0'
'-105353FF8E8FE^0'
'-21125996CB43C^-1'
'FCA84BAE918DC^-2'
'309FD4D4ED55CE^2'
'-5EF873B430495^2'
'-1162A3CE36807^2'
'E1882B11AEA5A^1'
'57180440FB3828^1'
'-269FAAE81CC5D8^1'
'-A549C705447BF^0'
'38616994CBE4F^0'
'9F04A9B477AF^-1'
'-3707302243F8^-1'
'-5030928B87121^-2'
'14F453F904FDB8^2'
'-2D9B1A7035A1FA^2'
'-7C4162313D887^1'
'6E6FBB071ADC28^1'
'27B3D57E9D65E4^1'
'-13005F4E5F3F81^1'
'-4B1E063A0BF6E^0'
'1BACC528F06078^0'
'4777C35704B2^-1'
'-1AC93497E80D4^-1'
'-22089F3F78BCC^-2'
'-23A6E4E3C7CBC^-3'
'4861F448FB846C^-2'
'2904F0B1F83224^-2'
'-237609D74232F^-2'
'-F5675EAE826BA^-3'
'731E86C4DAF41^-3'
'1E14F600ECC3EE^-3'
'-B728A86FB560A^-4'
'-1C389E5E8B51B4^-4'
'EF8E80A5845148^-5'
'0^0'
'-3009F0F9DE0AA8^-2'
'-1924394F882F4C^-2'
'2FFF01E9A8DAD8^-2'
'1B9B58DF6233E^-2'
'-1027B98E491B61^-2'
'-56C9FA37429798^-3'
'227C314D9648BA^-3'
'73DDC445748838^-4'
'-2EF5112E4E7AE^-4'
'-4C0820C0F96E08^-5'
'0^0'
'-16DC6F75107CB9^-2'
'-AF8D098545612^-3'
'1776B17D58F81A^-2'
'C972FD2192E5F^-3'
'-7F30B1ADC2EA08^-3'
'-2778A954B1820C^-3'
'10F0787731B17A^-3'
'34315F1E01B75E^-4'
'-16DB7B62E8269D^-4'
'-2044DB41DE90D4^-5'
'0^0'
'D75884^7'
'2A3^5'
'44^2'
'1^1'
END_ARRAY 4 72
TOTAL_ARRAYS 4
 ~NAIF/SPC BEGIN COMMENTS~
; ../sliced_kernels/mc3_0034948318_0x536_sci_1_Truth.spice_0.bsp LOG FILE

; Created 2022-08-15/14:42:03.00.
;
; BEGIN SPKMERGE COMMANDS

LEAPSECONDS_KERNEL = /Volumes/pkgs/isis3/isis_data/base/kernels/lsk/naif0012.tls

SPK_KERNEL     = ../sliced_kernels/mc3_0034948318_0x536_sci_1_Truth.spice_0.bsp
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/spk/nh_recon_e2j_v1.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = -98
    BEGIN_TIME       = 2007 FEB 28 05:13:31.182
    END_TIME         = 2007 FEB 28 05:17:34.668
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/tspk/de413.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 5, 10
    BEGIN_TIME       = 2007 FEB 28 05:13:31.182
    END_TIME         = 2007 FEB 28 05:17:34.668
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/tspk/jup260.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 599
    BEGIN_TIME       = 2007 FEB 28 05:13:31.182
    END_TIME         = 2007 FEB 28 05:17:34.668

; END SPKMERGE COMMANDS
 ~NAIF/SPC END COMMENTS~
+288 −0
Original line number Diff line number Diff line
DAFETF NAIF DAF ENCODED TRANSFER FILE
'DAF/SPK '
'2'
'6'
'SPKMERGE                                                    '
BEGIN_ARRAY 1 73
'nh_20060119_20070319_recon_e2j.nio      '
'D772DE9B492BC^7'
'D772ED9F13EC5^7'
'-62'
'5'
'1'
'1'
73
'D7738E3E9583A^7'
'342CB1129FCC^3'
'628D4E78840F8^3'
'87322354145E^3'
'A426272AA5FE^3'
'B87BD91815178^3'
'C6C3F959B3518^3'
'D0CBC9C59779^3'
'D70EDCA590C78^3'
'DB74C077303F8^3'
'DDA01EA7A60C^3'
'462B2BE90F3968^4'
'47FA6C2676AED^4'
'496872A92747A^4'
'766A1923CD027^4'
'DC1C8B04F7E788^4'
'-1EDF946DFE3206^6'
'-A94CCAB7D69D8^1'
'10A0BDE4A862FD^6'
'-112D5A31E865B2^2'
'2E0D67F9807BDA^5'
'-694047A01FADBC^1'
'15EE1C6F2005^-3'
'1524A67FF5CDF6^-5'
'-E1C2B4C186464^-7'
'-1FB0BB1D3EACBA^-8'
'1FB2EEA98FDCEF^-9'
'5CF11B0186BD4^-B'
'-6CC459A2D26C28^-C'
'-1E4E^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'-BCFBC1D9A39B2^-4'
'29A13E9E32AC4E^-5'
'6DED124DFA16E^-7'
'-42C72DDD74230C^-8'
'-EA0C4DCD423CE^-A'
'C9D2FF7B11823^-B'
'30EDF068D72B58^-C'
'-33C78^-D'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'-20B5886207DB66^-4'
'F8F5694A43515^-6'
'112FB7C57F753E^-7'
'-18C4FAE88C4FC3^-8'
'-2257063311BBCC^-A'
'4A9D0D07CB546^-B'
'6F533434791B4^-D'
'-106AC1A05F52A1^-D'
'81AA^-E'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'0^0'
'9^1'
'7^1'
'7^1'
'8^1'
'D7738E3E9583A^7'
'1^1'
END_ARRAY 1 73
BEGIN_ARRAY 2 39
'DE-0413LE-0413                          '
'D772DE9B492BC^7'
'D772ED9F13EC5^7'
'A'
'0'
'1'
'2'
39
'D6D9F4^7'
'A8C^5'
'4BF19A11B9610C^5'
'-19E9E21C5194F9^4'
'-B4B99503C78^1'
'-1B012C9D211^0'
'339F227C2^-1'
'-41E6B733CE^-2'
'-7B02EA2^-3'
'290DDF91^-3'
'-370795^-4'
'-7280AB6^-5'
'26ACF1C^-5'
'918336532181E^5'
'EF3A97F3DB45F8^3'
'-F639A39C9A^1'
'-13D275692C58^0'
'-2F456FC4^-2'
'564DF97A38^-2'
'-E45A188^-3'
'41244B08^-4'
'4792F8^-4'
'-C4A7867^-5'
'2E43CE^-6'
'3B14B17FB640DC^5'
'6DB893E99BE854^3'
'-64C2021EF1^1'
'-8A2102856A8^-1'
'-63A66097^-2'
'35506CBB1D^-2'
'-6D3FA14^-3'
'-215772E^-4'
'2BF02B^-4'
'-5D2D74D8^-5'
'-277101^-6'
'D63134^7'
'1518^6'
'23^2'
'1^1'
END_ARRAY 2 39
BEGIN_ARRAY 3 30
'DE-0413LE-0413                          '
'D772DE9B492BC^7'
'D772ED9F13EC5^7'
'5'
'0'
'1'
'2'
30
'D63134^7'
'1518^6'
'-13793B80F0E247^8'
'F826FF91D4D07^6'
'9DA91A9F018^4'
'-13D6F80638CC^3'
'-96076878^0'
'3AE6D68^-2'
'4AB8^-4'
'453^-6'
'-282E6C603A6EA4^8'
'-59460001523468^6'
'14553B7990F8^5'
'9C590D7104E^2'
'-AF683C8^0'
'-620C0B3^-2'
'-944^-5'
'-39048^-5'
'-10BFCA6B1ED407^8'
'-2C4EE62DC51A78^6'
'879B50A2D21^4'
'4ABE6B700FF^2'
'-47887D3^0'
'-2B72FFC8^-2'
'-6F8^-5'
'-1967A^-5'
'D4DFB4^7'
'2A3^6'
'1A^2'
'1^1'
END_ARRAY 3 30
BEGIN_ARRAY 4 72
'JUP260                                  '
'D772DE9B492BC^7'
'D772ED9F13EC5^7'
'257'
'5'
'1'
'3'
72
'D76D9C^7'
'1518^5'
'-887037DCEE036^2'
'-1DFA0A1575197F^2'
'238B5061E0575^2'
'C62154BF84B87^1'
'-7078D3C8246164^1'
'-2451A42A20E886^1'
'DE7B00674EAE4^0'
'2FFB5790F07EF^0'
'-105353FF8E8FE^0'
'-21125996CB43C^-1'
'FCA84BAE918DC^-2'
'309FD4D4ED55CE^2'
'-5EF873B430495^2'
'-1162A3CE36807^2'
'E1882B11AEA5A^1'
'57180440FB3828^1'
'-269FAAE81CC5D8^1'
'-A549C705447BF^0'
'38616994CBE4F^0'
'9F04A9B477AF^-1'
'-3707302243F8^-1'
'-5030928B87121^-2'
'14F453F904FDB8^2'
'-2D9B1A7035A1FA^2'
'-7C4162313D887^1'
'6E6FBB071ADC28^1'
'27B3D57E9D65E4^1'
'-13005F4E5F3F81^1'
'-4B1E063A0BF6E^0'
'1BACC528F06078^0'
'4777C35704B2^-1'
'-1AC93497E80D4^-1'
'-22089F3F78BCC^-2'
'-23A6E4E3C7CBC^-3'
'4861F448FB846C^-2'
'2904F0B1F83224^-2'
'-237609D74232F^-2'
'-F5675EAE826BA^-3'
'731E86C4DAF41^-3'
'1E14F600ECC3EE^-3'
'-B728A86FB560A^-4'
'-1C389E5E8B51B4^-4'
'EF8E80A5845148^-5'
'0^0'
'-3009F0F9DE0AA8^-2'
'-1924394F882F4C^-2'
'2FFF01E9A8DAD8^-2'
'1B9B58DF6233E^-2'
'-1027B98E491B61^-2'
'-56C9FA37429798^-3'
'227C314D9648BA^-3'
'73DDC445748838^-4'
'-2EF5112E4E7AE^-4'
'-4C0820C0F96E08^-5'
'0^0'
'-16DC6F75107CB9^-2'
'-AF8D098545612^-3'
'1776B17D58F81A^-2'
'C972FD2192E5F^-3'
'-7F30B1ADC2EA08^-3'
'-2778A954B1820C^-3'
'10F0787731B17A^-3'
'34315F1E01B75E^-4'
'-16DB7B62E8269D^-4'
'-2044DB41DE90D4^-5'
'0^0'
'D75884^7'
'2A3^5'
'44^2'
'1^1'
END_ARRAY 4 72
TOTAL_ARRAYS 4
 ~NAIF/SPC BEGIN COMMENTS~
; ../sliced_kernels/mc3_0034948318_0x536_sci_1_Truth.spice_1.bsp LOG FILE

; Created 2022-08-15/14:42:08.00.
;
; BEGIN SPKMERGE COMMANDS

LEAPSECONDS_KERNEL = /Volumes/pkgs/isis3/isis_data/base/kernels/lsk/naif0012.tls

SPK_KERNEL     = ../sliced_kernels/mc3_0034948318_0x536_sci_1_Truth.spice_1.bsp
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/spk/nh_recon_e2j_v1.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = -98
    BEGIN_TIME       = 2007 FEB 28 05:58:00.520
    END_TIME         = 2007 FEB 28 06:02:00.757
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/tspk/de413.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 5, 10
    BEGIN_TIME       = 2007 FEB 28 05:58:00.520
    END_TIME         = 2007 FEB 28 06:02:00.757
SOURCE_SPK_KERNEL = /Volumes/pkgs/isis3/isis_data/newhorizons/kernels/tspk/jup260.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 599
    BEGIN_TIME       = 2007 FEB 28 05:58:00.520
    END_TIME         = 2007 FEB 28 06:02:00.757

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