Commit e03708cb authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Fixed Viking and Cassini ISIS label ISIS SPICE drivers (#392)

* Added instrument check to cassini and viking drivers

* Added more logic to viking and cassini iss drivers

* Moved CO lookups to module

* Added Cassini ISS isis label isis spice test
parent 9d57995b
Loading
Loading
Loading
Loading
+125 −91
Original line number Diff line number Diff line
@@ -17,16 +17,16 @@ from ale.rotation import ConstantRotation
from ale.transformation import FrameChain
from scipy.spatial.transform import Rotation


class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDistortion, Driver):
    """
    Cassini mixin class for defining Spice calls.
    """
id_lookup = {
    "ISSNA" : "CASSINI_ISS_NAC",
    "ISSWA" : "CASSINI_ISS_WAC"
}

name_lookup = {
    "ISSNA" : "Imaging Science Subsystem Narrow Angle Camera",
    "ISSWA" : "Imaging Science Subsystem Wide Angle Camera"
}

nac_filter_to_focal_length = {
    ("P0","BL2"):2002.19,
    ("P0","CB1"):2002.30,
@@ -110,6 +110,12 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis
    ("T3","IRP90"):201.07
}

class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDistortion, Driver):
    """
    Cassini mixin class for defining Spice calls.
    """


    @property
    def instrument_id(self):
        """
@@ -124,7 +130,7 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis
        : str
          instrument id
        """
        return self.id_lookup[super().instrument_id]
        return id_lookup[super().instrument_id]

    @property
    def focal_epsilon(self):
@@ -259,10 +265,10 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis
        filters = tuple(self.label['FILTER_NAME'])

        if self.instrument_id == "CASSINI_ISS_NAC":
          return self.nac_filter_to_focal_length.get(filters, default_focal_len)
          return nac_filter_to_focal_length.get(filters, default_focal_len)

        elif self.instrument_id == "CASSINI_ISS_WAC":
          return self.wac_filter_to_focal_length.get(filters, default_focal_len)
          return wac_filter_to_focal_length.get(filters, default_focal_len)

    @property
    def _original_naif_sensor_frame_id(self):
@@ -329,6 +335,19 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis
        return self._frame_chain

class CassiniIssIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion, Driver):

    @property
    def instrument_id(self):
        """
        Returns the ID of the instrument

        Returns
        -------
        : str
          ID of the sensor
        """
        return id_lookup[super().instrument_id]

    @property
    def sensor_name(self):
        """
@@ -339,4 +358,19 @@ class CassiniIssIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistort
        : str
          Name of the sensor
        """
        return self.label['IsisCube']['Instrument']['SpacecraftName']
        return name_lookup[super().instrument_id]

    @property
    def center_ephemeris_time(self):
        """
        Returns the middle exposure time for the image in ephemeris seconds.

        This is overriden because the ISIS ISSNAC and ISSWAC sensor models use the
        label utc times so the converted times are not available in the
        NaifKeywords. Instead we get it from the tables.

        Returns
        -------
        : float
        """
        return self.inst_position_table['SpkTableStartTime']
+78 −12
Original line number Diff line number Diff line
@@ -8,8 +8,54 @@ from ale.base.type_sensor import Framer
from ale.base.type_distortion import NoDistortion
from ale.base.base import Driver

sensor_name_lookup = {
    "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A" : "Visual Imaging Subsystem Camera A",
    "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B" : "Visual Imaging Subsystem Camera B"
}

spacecraft_name_lookup = {
    'VIKING_ORBITER_1': 'VIKING ORBITER 1',
    'VIKING_ORBITER_2': 'VIKING ORBITER 2'
}

alt_id_lookup = {
    'VIKING ORBITER 1': -27999,
    'VIKING ORBITER 2':-30999
}

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



    @property
    def instrument_id(self):
        """
        Overriden to check that the instrument ID is correct

        Returns
        -------
        : str
          The name of the sensor
        """
        instrument_id = super().instrument_id

        if(instrument_id not in sensor_name_lookup):
            raise Exception (f'Instrument ID [{instrument_id}] is wrong.')

        return instrument_id

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

        Returns
        -------
        : str
          Name of the sensor
        """
        return sensor_name_lookup[super().instrument_id]

    @property
    def spacecraft_name(self):
        """
@@ -20,12 +66,7 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver):
        : str
          Name of the spacecraft.
        """
        name_lookup = {
            'VIKING_ORBITER_1': 'VIKING ORBITER 1',
            'VIKING_ORBITER_2': 'VIKING ORBITER 2'
        }

        return name_lookup[super().spacecraft_name]
        return spacecraft_name_lookup[super().spacecraft_name]

    @property
    def alt_ikid(self):
@@ -41,11 +82,6 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver):
        Alternate Naif Integer ID code for the instrument
        """

        alt_id_lookup = {
            'VIKING ORBITER 1': -27999,
            'VIKING ORBITER 2':-30999
        }

        return alt_id_lookup[self.spacecraft_name]

    @property
@@ -84,6 +120,24 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver):
        return ephemeris_start_time + offset1 + offset2

class VikingIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion, Driver):

    @property
    def instrument_id(self):
        """
        Overriden to check that the instrument ID is correct

        Returns
        -------
        : str
          The name of the sensor
        """
        instrument_id = super().instrument_id

        if(instrument_id not in sensor_name_lookup):
            raise Exception (f'Instrument ID [{instrument_id}] is wrong.')

        return instrument_id

    @property
    def sensor_name(self):
        """
@@ -94,4 +148,16 @@ class VikingIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion,
        : str
          Name of the sensor
        """
        return self.label['IsisCube']['Instrument']['SpacecraftName']
        return sensor_name_lookup[super().instrument_id]

    @property
    def spacecraft_name(self):
        """
        Overridden to work with spice calls.

        Returns
        -------
        : str
          Name of the spacecraft.
        """
        return spacecraft_name_lookup[super().spacecraft_name]
+18 −0
Original line number Diff line number Diff line
@@ -4,9 +4,12 @@ import re
import warnings
import numpy as np
import json
import pvl

import ale

from ale.base.data_isis import read_table_data

from glob import glob

class SimpleSpice():
@@ -95,6 +98,21 @@ def get_image_label(image, label_type='pds3'):

    return label_file[0]

def get_table_data(image, table_name):
    if not isinstance(image, str):
        try:
            image = str(image)
        except:
            raise KeyError('Cannot coerce requested image name to string')

    table_file = glob(os.path.join(data_root, '*',f'{image}_{table_name}.tbl'))
    if not table_file:
        raise Exception(f'Could not find {table_name} table file for {image}')

    table_label = pvl.load(table_file[0])
    return read_table_data(table_label["Table"], table_file[0])


def get_isd(instrument):
    if not isinstance(instrument, str):
        raise KeyError('instrument name is not a string')
+1.51 KiB

File added.

No diff preview for this file type.

+1.59 KiB

File added.

No diff preview for this file type.

Loading