Commit 42ee087a authored by AustinSanders's avatar AustinSanders Committed by Jesse Mapel
Browse files

Initial commit of ideal drivers and tests (#217)

* Fixed kaguya driver and added example notebook

* updated documentation

* Swapped clock start/stop for corrected start/stop, fixed test failures.

* Swapped utc start/stop time for corrected utc start/stop time

* Initial notebook for kaguya / isis comparison

* Initial commit of ideal drivers and tests

* Removed csm / isis comparison notebook for kaguya
parent c82fbf0b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -663,3 +663,18 @@ class IsisSpice():
        """
        return self.isis_naif_keywords["INS{}_OD_K".format(self.ikid)]


    @property
    def sensor_frame_id(self):
        if 'ConstantFrames' in self.inst_pointing_table:
            return self.inst_pointing_table['ConstantFrames'][0]
        else:
            return self.inst_pointing_table['TimeDependentFrames'][0]


    @property
    def target_frame_id(self):
        if 'ConstantFrames' in self.inst_pointing_table:
            return self.body_rotation_table['ConstantFrames'][0]
        else:
            return self.body_rotation_table['TimeDependentFrames'][0]
+14 −0
Original line number Diff line number Diff line
@@ -15,3 +15,17 @@ class RadialDistortion():
                "coefficients" : self.odtk
            }
        }


class NoDistortion():
    @property
    def usgscsm_distortion_model(self):
        """
        Returns the specification for no distortion in usgscsm.
        
        Returns
        -------
        : dict
          Dictionary containing the usgscsm specification for no distortion.
        """
        return {"radial": {"coefficients": [0.0, 0.0, 0.0]}}
+164 −0
Original line number Diff line number Diff line
from ale.base.data_isis import IsisSpice
from ale.base.label_isis import IsisLabel
from ale.base import Driver
from ale.base.type_sensor import LineScanner
from ale.base.type_distortion import NoDistortion


class IdealLsIsisLabelIsisSpiceDriver(IsisSpice, LineScanner, IsisLabel, NoDistortion, Driver):
    @property
    def sensor_name(self):
        """
        Returns the name of the instrument

        Returns
        -------
        : str
          name of the instrument.
        """
        return self.instrument_id


    @property
    def ephemeris_start_time(self):
        """
        The image start time in ephemeris time.
        
        Returns
        -------
        float :
            The image start ephemeris time
        """

        return self.label.get('IsisCube').get('Instrument').get("EphemerisTime").value


    @property 
    def ephemeris_stop_time(self):
        """
        Returns the sum of the starting ephemeris time and the number of lines
        times the exposure duration. Expects ephemeris start time, exposure duration
        and image lines to be defined. These should be double precision numbers
        containing the ephemeris start, exposure duration, and number of lines of
        the image.

        Returns
        -------
        : double
          Center ephemeris time for an image
        """
        return super().ephemeris_stop_time
        

    @property
    def spacecraft_name(self):
        """
        Returns the spacecraft name used in various Spice calls to acquire
        ephemeris data.
        Expects the platform_name to be defined. This should be a string of
        the form 'Mars_Reconnaissance_Orbiter'

        Returns
        -------
        : str
          spacecraft name
        """
        return super().platform_name


    @property
    def detector_start_line(self):
        """
        Returns the starting detector line for the image.

        Returns
        -------
        : int
          Starting detector line for the image
        """
        return 0


    @property
    def detector_start_sample(self):
        """
        Returns the starting detector sample for the image.

        Returns
        -------
        : int
          Starting detector sample for the image
        """
        return 0


    @property
    def sensor_model_version(self):
        """
        Returns the ISIS sensor model version.

        Returns
        -------
        : int
          ISIS sensor model version
        """

        return 1


    @property
    def pixel2focal_x(self):
        """
        Returns detector to focal plane x.

        Returns
        -------
        : list<double>
          detector to focal plane x
       """
        return self.isis_naif_keywords.get('IDEAL_TRANSX')


    @property
    def pixel2focal_y(self):
        """
        Returns detector to focal plane y.

        Returns
        -------
        : list<double>
          detector to focal plane y
       """
        return self.isis_naif_keywords.get('IDEAL_TRANSY')


    @property
    def focal2pixel_lines(self):
        """
        Returns focal plane to detector lines.

        Returns
        -------
        : list<double>
          focal plane to detector lines
       """

        return self.isis_naif_keywords.get('IDEAL_TRANSL')
        

    @property
    def focal2pixel_samples(self):
        """
        Returns focal plane to detector samples.

        Returns
        -------
        : list<double>
          focal plane to detector samples
       """
        return self.isis_naif_keywords.get('IDEAL_TRANSS')


    @property
    def frame_chain(self):
        pass
+64 −0
Original line number Diff line number Diff line
import pytest
from ale.drivers import isis_ideal_drivers
from ale.base import data_isis
from ale.base import label_isis
from ale.drivers.isis_ideal_drivers import IdealLsIsisLabelIsisSpiceDriver

from conftest import SimpleSpice
from unittest.mock import patch


simplespice = SimpleSpice()

isis_ideal_drivers.spice = simplespice
data_isis.spice = simplespice
label_isis.spice = simplespice

@pytest.fixture
def IdealDriver():
    return IdealLsIsisLabelIsisSpiceDriver("")


@patch('ale.base.label_isis.IsisLabel.instrument_id', 1)
def test_sensor_name(IdealDriver):
    assert IdealDriver.sensor_name == 1


@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.ephemeris_start_time', 451262458.99571)
def test_ephemeris_start_time(IdealDriver):
    assert IdealDriver.ephemeris_start_time == 451262458.99571
    

@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.ephemeris_stop_time', 451262459.29003815)
def test_ephemeris_stop_time(IdealDriver):
    assert IdealDriver.ephemeris_stop_time == 451262459.29003815


@patch('ale.base.label_isis.IsisLabel.platform_name', 'Mars Reconnaissance Orbiter')
def test_spacecraft_name(IdealDriver):
    assert IdealDriver.spacecraft_name == 'Mars Reconnaissance Orbiter'


@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.detector_start_line', 0)
def test_detector_start_line(IdealDriver):
    assert IdealDriver.detector_start_line == 0


@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.detector_start_sample', 0)
def test_detector_start_sample(IdealDriver):
    assert IdealDriver.detector_start_sample == 0

@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.sensor_model_version', 0)
def test_sensor_model_version(IdealDriver):
    assert IdealDriver.sensor_model_version == 0


@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.pixel2focal_x', 0)
def test_pixel2focal_x(IdealDriver):
    assert IdealDriver.pixel2focal_x == 0


@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.pixel2focal_y', 0)
def test_pixel2focal_y(IdealDriver):
    assert IdealDriver.pixel2focal_y == 0