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

ISIS Ephemeris Times (#479)

* Updated ALE to create initial ISIS ephemeris data before any sort of reduction

* Removed left over prints in type_sensor and updated doc strings

* Further fixed lro doc strings

* Updated MRO tests

* Updated lro tests

* Updated mex tests

* Further updated mro tests

* Updated new horizons leisa tests

* Updated cassini tests

* Updated data_naif tests

* Fixed CTX kernels from poor slice

* Final edit to tests

* Removed leftover debugging print statements

* Fixed tests

* Reduced marci image and ISD sizes for testing

* Pushed smaller ctx data/isds and fixed marci tests

* Final changes to test data
parent 71990f46
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -54,7 +54,9 @@ class LineScanner():
        : ndarray
        : ndarray
          ephemeris times split based on image lines
          ephemeris times split based on image lines
        """
        """
        return np.linspace(self.ephemeris_start_time,  self.ephemeris_stop_time, max(2, int(self.image_lines/64)))
        if not hasattr(self, "_ephemeris_time"):
          self._ephemeris_time = np.linspace(self.ephemeris_start_time, self.ephemeris_stop_time, self.image_lines + 1)
        return self._ephemeris_time


    @property
    @property
    def ephemeris_stop_time(self):
    def ephemeris_stop_time(self):
@@ -227,7 +229,7 @@ class Radar():
    def ephemeris_time(self):
    def ephemeris_time(self):
        """
        """
        Returns an array of times between the start/stop ephemeris times
        Returns an array of times between the start/stop ephemeris times
        based on the start/stop times with a timestep 0.25.
        based on the start/stop times with a timestep (stop - start) / image_lines.
        Expects ephemeris start/stop times to be defined. These should be
        Expects ephemeris start/stop times to be defined. These should be
        floating point numbers containing the start and stop times of the
        floating point numbers containing the start and stop times of the
        images.
        images.
@@ -237,9 +239,9 @@ class Radar():
        : ndarray
        : ndarray
          ephemeris times split based on image lines
          ephemeris times split based on image lines
        """
        """
        # 0.25 is the delta used by minirf, used as a default.
        if not hasattr(self, "_ephemeris_time"):
        num_states = int((self.ephemeris_stop_time - self.ephemeris_start_time)/0.25) + 1
          self._ephemeris_time = np.linspace(self.ephemeris_start_time, self.ephemeris_stop_time, self.image_lines + 1)
        return np.linspace(self.ephemeris_start_time,  self.ephemeris_stop_time, num_states)
        return self._ephemeris_time


    @property
    @property
    def wavelength(self):
    def wavelength(self):
+2 −2
Original line number Original line Diff line number Diff line
@@ -807,7 +807,7 @@ class LroMiniRfIsisLabelNaifSpiceDriver(Radar, NaifSpice, IsisLabel, Driver):
    @property
    @property
    def ephemeris_start_time(self):
    def ephemeris_start_time(self):
        """
        """
        Returns the start and stop ephemeris times for the image.
        Returns the start ephemeris time for the image.


        Returns
        Returns
        -------
        -------
@@ -819,7 +819,7 @@ class LroMiniRfIsisLabelNaifSpiceDriver(Radar, NaifSpice, IsisLabel, Driver):
    @property
    @property
    def ephemeris_stop_time(self):
    def ephemeris_stop_time(self):
        """
        """
        Returns the stop ephemeris times for the image.
        Returns the stop ephemeris time for the image.


        Returns
        Returns
        -------
        -------
+43 −28
Original line number Original line Diff line number Diff line
@@ -99,7 +99,10 @@ class FrameChain(nx.DiGraph):
    def from_spice(cls, sensor_frame, target_frame, center_ephemeris_time, ephemeris_times=[], nadir=False, exact_ck_times=False):
    def from_spice(cls, sensor_frame, target_frame, center_ephemeris_time, ephemeris_times=[], nadir=False, exact_ck_times=False):
        frame_chain = cls()
        frame_chain = cls()
        sensor_times = []
        sensor_times = []
        target_times = np.array(ephemeris_times)
        # Default assume one time
        target_times = np.asarray(ephemeris_times)
        if len(target_times) > 1:
            target_times = np.asarray([ephemeris_times[0], ephemeris_times[-1]])


        if exact_ck_times and not nadir:
        if exact_ck_times and not nadir:
            try:
            try:
@@ -120,31 +123,8 @@ class FrameChain(nx.DiGraph):


        constant_frames.extend(target_constant_frames)
        constant_frames.extend(target_constant_frames)


        for s, d in sensor_time_dependent_frames:
        frame_chain.compute_time_dependent_rotiations(sensor_time_dependent_frames, sensor_times)
            quats = np.zeros((len(sensor_times), 4))
        frame_chain.compute_time_dependent_rotiations(target_time_dependent_frames, target_times)
            avs = np.zeros((len(sensor_times), 3))
            for j, time in enumerate(sensor_times):
                state_matrix = spice.sxform(spice.frmnam(s), spice.frmnam(d), time)
                rotation_matrix, avs[j] = spice.xf2rav(state_matrix)
                quat_from_rotation = spice.m2q(rotation_matrix)
                quats[j,:3] = quat_from_rotation[1:]
                quats[j,3] = quat_from_rotation[0]

            rotation = TimeDependentRotation(quats, sensor_times, s, d, av=avs)
            frame_chain.add_edge(rotation=rotation)

        for s, d in target_time_dependent_frames:
            quats = np.zeros((len(target_times), 4))
            avs = np.zeros((len(target_times), 3))
            for j, time in enumerate(target_times):
                state_matrix = spice.sxform(spice.frmnam(s), spice.frmnam(d), time)
                rotation_matrix, avs[j] = spice.xf2rav(state_matrix)
                quat_from_rotation = spice.m2q(rotation_matrix)
                quats[j,:3] = quat_from_rotation[1:]
                quats[j,3] = quat_from_rotation[0]

            rotation = TimeDependentRotation(quats, target_times, s, d, av=avs)
            frame_chain.add_edge(rotation=rotation)


        for s, d in constant_frames:
        for s, d in constant_frames:
            quats = np.zeros(4)
            quats = np.zeros(4)
@@ -324,10 +304,13 @@ class FrameChain(nx.DiGraph):
        SOURCESIZ = 128;
        SOURCESIZ = 128;


        currentTime = observStart
        currentTime = observStart
        timeLoaded = False


        count = spice.ktotal("ck")
        count = spice.ktotal("ck")
        file, filtyp, source, handle = spice.kdata(0, "ck", FILESIZ, TYPESIZ, SOURCESIZ)
        if (count > 1):
            msg = "Unable to get exact CK record times when more than 1 CK is loaded, Aborting"
            raise Exception(msg)

        _, _, _, handle = spice.kdata(0, "ck", FILESIZ, TYPESIZ, SOURCESIZ)
        spice.dafbfs(handle)
        spice.dafbfs(handle)
        found = spice.daffna()
        found = spice.daffna()
        spCode = int(targetFrame / 1000) * 1000
        spCode = int(targetFrame / 1000) * 1000
@@ -395,3 +378,35 @@ class FrameChain(nx.DiGraph):
            found = spice.daffna()   # Find next forward array in current daf
            found = spice.daffna()   # Find next forward array in current daf


        return times
        return times

    def compute_time_dependent_rotiations(self, frames, times):
        """
        Computes the time dependent rotations based on a list of tuples that define the
        relationships between frames as (source, destination) and a list of times to
        compute the rotation at. The rotations are then appended to the frame chain
        object

        frames : list
                 A list of tuples that define the relationships between frames

        times : list
                A list of times to compute the rotation at
        """
        for s, d in frames:
            quats = np.zeros((len(times), 4))
            avs = []
            for j, time in enumerate(times):
                try:
                    state_matrix = spice.sxform(spice.frmnam(s), spice.frmnam(d), time)
                    rotation_matrix, av = spice.xf2rav(state_matrix)
                    avs.append(av)
                except:
                    rotation_matrix = spice.pxform(spice.frmnam(s), spice.frmnam(d), time)
                quat_from_rotation = spice.m2q(rotation_matrix)
                quats[j,:3] = quat_from_rotation[1:]
                quats[j,3] = quat_from_rotation[0]

            if not avs:
                avs = None
            rotation = TimeDependentRotation(quats, times, s, d, av=avs)
            self.add_edge(rotation=rotation)
 No newline at end of file
+3 −0
Original line number Original line Diff line number Diff line
@@ -277,6 +277,9 @@ def get_kernels_from_isis_pvl(kernel_group, expand=True, format_as="list"):
              warnings.warn("No IsisPreferences file found, is your ISISROOT env var set?")
              warnings.warn("No IsisPreferences file found, is your ISISROOT env var set?")


            kernels = [expandvars(expandvars(k, dict_to_lower(isisprefs['DataDirectory']))) for k in kernels]
            kernels = [expandvars(expandvars(k, dict_to_lower(isisprefs['DataDirectory']))) for k in kernels]
        # Ensure that the ISIS Addendum kernel is last in case it overrides
        # some values from the default Instrument kernel
        kernels = sorted(kernels, key=lambda x: "Addendum" in x)
        return kernels
        return kernels
    elif (format_as == 'dict'):
    elif (format_as == 'dict'):
        # return created dict
        # return created dict
+58 −38
Original line number Original line Diff line number Diff line
@@ -104,7 +104,7 @@ Object = IsisCube


  Group = Kernels
  Group = Kernels
    NaifFrameCode             = -85700
    NaifFrameCode             = -85700
    LeapSecond                = $base/kernels/lsk/naif0009.tls
    LeapSecond                = $base/kernels/lsk/naif0012.tls
    TargetAttitudeShape       = ($base/kernels/pck/pck00009.tpc,
    TargetAttitudeShape       = ($base/kernels/pck/pck00009.tpc,
                                 $lro/kernels/pck/moon_080317.tf,
                                 $lro/kernels/pck/moon_080317.tf,
                                 $lro/kernels/pck/moon_assoc_me.tf)
                                 $lro/kernels/pck/moon_assoc_me.tf)
@@ -112,18 +112,20 @@ Object = IsisCube
                                 $lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
                                 $lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
                                 $lro/kernels/tspk/de421.bsp)
                                 $lro/kernels/tspk/de421.bsp)
    InstrumentPointing        = (Table,
    InstrumentPointing        = (Table,
                                 $lro/kernels/ck/moc42_2010115_2010116_v02.bc,
                                 $lro/kernels/ck/moc42r_2010090_2010121_v03.bc,
                                 $lro/kernels/fk/lro_frames_2010277_v01.tf)
                                 $lro/kernels/fk/lro_frames_2014049_v01.tf)
    Instrument                = Null
    Instrument                = Null
    SpacecraftClock           = $lro/kernels/sclk/lro_clkcor_2010292_v00.tsc
    SpacecraftClock           = $lro/kernels/sclk/lro_clkcor_2022208_v00.tsc
    InstrumentPosition        = (Table, LOLA_spk/spkLOLA_100209_100503.bsp)
    InstrumentPosition        = (Table,
                                 $lro/kernels/spk/fdf29r_2010091_2010121_v01.b-
                                 sp)
    InstrumentAddendum        = $lro/kernels/iak/mrflroAddendum002.ti
    InstrumentAddendum        = $lro/kernels/iak/mrflroAddendum002.ti
    ShapeModel                = Null
    ShapeModel                = $base/dems/ldem_128ppd_Mar2011_clon180_radius-
    InstrumentPositionQuality = Unknown
                                _pad.cub
    InstrumentPositionQuality = Reconstructed
    InstrumentPointingQuality = Reconstructed
    InstrumentPointingQuality = Reconstructed
    StartPadding              = 2.0 <seconds>
    EndPadding                = 2.0 <seconds>
    CameraVersion             = 1
    CameraVersion             = 1
    Source                    = isis
  End_Group
  End_Group


  Group = ImageInfo
  Group = ImageInfo
@@ -146,21 +148,22 @@ End_Object


Object = Table
Object = Table
  Name                = InstrumentPointing
  Name                = InstrumentPointing
  StartByte           = 628892136
  StartByte           = 7536641
  Bytes               = 98624
  Bytes               = 1216
  Records             = 1541
  Records             = 19
  ByteOrder           = Lsb
  ByteOrder           = Lsb
  TimeDependentFrames = (-85000, 1)
  TimeDependentFrames = (-85000, 1)
  ConstantFrames      = (-85700, -85000)
  ConstantFrames      = (-85700, -85000)
  ConstantRotation    = (1.0, 0.0, 0.0, 0.0, 0.67430238758372,
  ConstantRotation    = (1.0, 0.0, 0.0, 0.0, 0.67430238758372,
                         0.73845534062588, 0.0, -0.73845534062588,
                         0.73845534062588, 0.0, -0.73845534062588,
                         0.67430238758372)
                         0.67430238758372)
  CkTableStartTime    = 325441415.42572
  CkTableStartTime    = 325441417.42572
  CkTableEndTime      = 325441723.22785
  CkTableEndTime      = 325441420.72822
  CkTableOriginalSize = 64577
  CkTableOriginalSize = 701
  FrameTypeCode       = 3
  Description         = "Created by spiceinit"
  Description         = "Created by spiceinit"
  Kernels             = ($lro/kernels/ck/moc42_2010115_2010116_v02.bc,
  Kernels             = ($lro/kernels/ck/moc42r_2010090_2010121_v03.bc,
                         $lro/kernels/fk/lro_frames_2010277_v01.tf)
                         $lro/kernels/fk/lro_frames_2014049_v01.tf)


  Group = Field
  Group = Field
    Name = J2000Q0
    Name = J2000Q0
@@ -214,12 +217,15 @@ End_Object
Object = Table
Object = Table
  Name                 = InstrumentPosition
  Name                 = InstrumentPosition
  StartByte            = 628990760
  StartByte            = 628990760
  Bytes       = 280
  Bytes                = 168
  Records     = 5
  Records              = 3
  ByteOrder            = Lsb
  ByteOrder            = Lsb
  CacheType            = HermiteSpline
  CacheType            = HermiteSpline
  SpkTableStartTime    = 325441417.42572
  SpkTableEndTime      = 325441420.72822
  SpkTableOriginalSize = 701.0
  Description          = "Created by spiceinit"
  Description          = "Created by spiceinit"
  Kernels     = LOLA_spk/spkLOLA_100209_100503.bsp
  Kernels              = $lro/kernels/spk/fdf29r_2010091_2010121_v01.bsp


  Group = Field
  Group = Field
    Name = J2000X
    Name = J2000X
@@ -277,16 +283,17 @@ Object = Table
                         0.99999994578431, -1.45444093783627e-06,
                         0.99999994578431, -1.45444093783627e-06,
                         -3.80869119096078e-04, 1.57985578682691e-06,
                         -3.80869119096078e-04, 1.57985578682691e-06,
                         0.99999992746811)
                         0.99999992746811)
  CkTableStartTime    = 325441415.42572
  CkTableStartTime    = 325441417.42572
  CkTableEndTime      = 325441723.22785
  CkTableEndTime      = 325441420.72822
  CkTableOriginalSize = 2
  CkTableOriginalSize = 2
  FrameTypeCode       = 6
  Description         = "Created by spiceinit"
  Description         = "Created by spiceinit"
  Kernels             = ($lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
  Kernels             = ($lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
                         $lro/kernels/tspk/de421.bsp,
                         $lro/kernels/tspk/de421.bsp,
                         $base/kernels/pck/pck00009.tpc,
                         $base/kernels/pck/pck00009.tpc,
                         $lro/kernels/pck/moon_080317.tf,
                         $lro/kernels/pck/moon_080317.tf,
                         $lro/kernels/pck/moon_assoc_me.tf)
                         $lro/kernels/pck/moon_assoc_me.tf)
  SolarLongitude      = 106.55850890612
  SolarLongitude      = 106.55387897673


  Group = Field
  Group = Field
    Name = J2000Q0
    Name = J2000Q0
@@ -344,6 +351,9 @@ Object = Table
  Records              = 2
  Records              = 2
  ByteOrder            = Lsb
  ByteOrder            = Lsb
  CacheType            = Linear
  CacheType            = Linear
  SpkTableStartTime    = 325441417.42572
  SpkTableEndTime      = 325441420.72822
  SpkTableOriginalSize = 2.0
  Description          = "Created by spiceinit"
  Description          = "Created by spiceinit"
  Kernels              = ($lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
  Kernels              = ($lro/kernels/tspk/moon_pa_de421_1900-2050.bpc,
                          $lro/kernels/tspk/de421.bsp)
                          $lro/kernels/tspk/de421.bsp)
@@ -394,7 +404,7 @@ End_Object
Object = History
Object = History
  Name      = IsisCube
  Name      = IsisCube
  StartByte = 628991280
  StartByte = 628991280
  Bytes     = 1816
  Bytes     = 3667
End_Object
End_Object


Object = OriginalLabel
Object = OriginalLabel
@@ -402,4 +412,14 @@ Object = OriginalLabel
  StartByte = 628883457
  StartByte = 628883457
  Bytes     = 7598
  Bytes     = 7598
End_Object
End_Object

Object = NaifKeywords
  BODY_CODE         = 301
  BODY301_RADII     = (1737.4, 1737.4, 1737.4)
  BODY_FRAME_CODE   = 31001
  INS-85700_TRANSX  = (-7.5, 7.5, 0.0)
  INS-85700_TRANSY  = (0.0, 0.0, 0.0)
  INS-85700_ITRANSS = (1.0, 0.13333333333333, 0.0)
  INS-85700_ITRANSL = (0.0, 0.0, 0.0)
End_Object
End
End
Loading