Commit 8c996b08 authored by paarongiroux's avatar paarongiroux Committed by Kristin
Browse files

UNFINISHED lronac isis driver work. (#296)

* ISIS ideal now fails if inst id is not ISIS Ideal

* redo super

* updated ideal test

* updated themis tests

* added themis test data

* updates as per comments

* updated as per comments

* updated tests

* unfinished lronac isis driver work

* added missing kernels

* error in body code

* updated tests

* patched int line

* addressing comments
parent a7d114bf
Loading
Loading
Loading
Loading
+200 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ from ale.util import get_metakernels
from ale.base import Driver
from ale.base.data_naif import NaifSpice
from ale.base.label_pds3 import Pds3Label
from ale.base.label_isis import IsisLabel
from ale.base.type_sensor import LineScanner


@@ -220,3 +221,202 @@ class LroLrocPds3LabelNaifSpiceDriver(LineScanner, NaifSpice, Pds3Label, Driver)
          Number of samples and lines combined from the original data to produce a single pixel in this image
        """
        return self.crosstrack_summing

class LroLrocIsisLabelNaifSpiceDriver(LineScanner, NaifSpice, IsisLabel, Driver):
    @property
    def instrument_id(self):
        """
        The short text name for the instrument

        Returns an instrument id uniquely identifying the instrument. Used to acquire
        instrument codes from Spice Lib bods2c routine.

        Returns
        -------
        str
          The short text name for the instrument
        """
        id_lookup = {
            "NACL": "LRO_LROCNACL",
            "NACR": "LRO_LROCNACR"
        }

        return id_lookup[super().instrument_id]

    @property
    def sensor_model_version(self):
        """
        Returns ISIS instrument sensor model version number

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

    @property
    def usgscsm_distortion_model(self):
        """
        The distortion model name with its coefficients

        LRO LROC NAC does not use the default distortion model so we need to overwrite the
        method packing the distortion model into the ISD.

        Returns
        -------
        : dict
          Returns a dict with the model name : dict of the coefficients
        """

        return {"lrolrocnac":
                {"coefficients": self.odtk}}

    @property
    def odtk(self):
        """
        The coefficients for the distortion model

        Returns
        -------
        : list
          Radial distortion coefficients. There is only one coefficient for LROC NAC l/r
        """
        return spice.gdpool('INS{}_OD_K'.format(self.ikid), 0, 1).tolist()

    @property
    def light_time_correction(self):
        """
        Returns the type of light time correciton and abberation correction to
        use in NAIF calls.

        LROC is specifically set to not use light time correction because it is
        so close to the surface of the moon that light time correction to the
        center of the body is incorrect.

        Returns
        -------
        : str
          The light time and abberation correction string for use in NAIF calls.
          See https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/abcorr.html
          for the different options available.
        """
        return 'NONE'

    @property
    def detector_center_sample(self):
        """
        The center of the CCD in detector pixels
        ISIS uses 0.5 based CCD samples, so we need to convert to 0 based.

        Returns
        -------
        float :
            The center sample of the CCD
        """
        return super().detector_center_sample - 0.5

    @property
    def ephemeris_start_time(self):
        """
        The starting ephemeris time for LRO is computed by taking the
        LRO:SPACECRAFT_CLOCK_PREROLL_COUNT, as defined in the label, and
        adding offsets that were taken from an IAK.
        -------
        : double
          Starting ephemeris time of the image
        """
        start_time = spice.scs2e(self.spacecraft_id, self.label['IsisCube']['Instrument']['SpacecraftClockPrerollCount'])
        return start_time + self.constant_time_offset + self.additional_preroll * self.exposure_duration

    @property
    def exposure_duration(self):
        """
        Takes the exposure_duration defined in a parent class and adds
        offsets taken from an IAK.

         Returns
         -------
         : float
           Returns the exposure duration in seconds.
         """
        return super().exposure_duration * (1 + self.multiplicative_line_error) + self.additive_line_error

    @property
    def multiplicative_line_error(self):
        """
        Returns the multiplicative line error defined in an IAK.

         Returns
         -------
         : float
           Returns the multiplicative line error.
         """
        return 0.0045

    @property
    def additive_line_error(self):
        """
        Returns the additive line error defined in an IAK.

         Returns
         -------
         : float
           Returns the additive line error.
         """
        return 0.0

    @property
    def constant_time_offset(self):
        """
        Returns the constant time offset defined in an IAK.

         Returns
         -------
         : float
           Returns the constant time offset.
         """
        return 0.0

    @property
    def additional_preroll(self):
        """
        Returns the addition preroll defined in an IAK.

         Returns
         -------
         : float
           Returns the additionl preroll.
         """
        return 1024.0

    @property
    def sampling_factor(self):
        """
        Returns the summing factor from the PDS3 label that is defined by the CROSSTRACK_SUMMING.
        For example a return value of 2 indicates that 2 lines and 2 samples (4 pixels)
        were summed and divided by 4 to produce the output pixel value.

        Returns
        -------
        : int
          Number of samples and lines combined from the original data to produce a single pixel in this image
        """
        return self.label['IsisCube']['Instrument']['SpatialSumming']

    @property
    def target_frame_id(self):
        """
        Returns the Naif ID code for the target body
        Expects target_name to be defined. This must be a string containig the name
        of the target body.

        Returns
        -------
        : int
          Naif ID code for the target body
        """
        name_lookup = {
            "MOON": "MOON_ME"
        }
        return int(spice.gdpool('FRAME_{}'.format(name_lookup[self.target_name]),0,1))
+9 −9
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ DAFETF NAIF DAF ENCODED TRANSFER FILE
BEGIN_ARRAY 1 44
'SPK_STATES_13                           '
'1203A21863267E^8'
'1203A2253DC63C^8'
'1203A2253D432A^8'
'-55'
'12D'
'1'
@@ -60,7 +60,7 @@ END_ARRAY 1 44
BEGIN_ARRAY 2 45
'DE-0421LE-0421                          '
'1203A21863267E^8'
'1203A2253DC63C^8'
'1203A2253D432A^8'
'12D'
'3'
'1'
@@ -115,7 +115,7 @@ END_ARRAY 2 45
BEGIN_ARRAY 3 39
'DE-0421LE-0421                          '
'1203A21863267E^8'
'1203A2253DC63C^8'
'1203A2253D432A^8'
'A'
'0'
'1'
@@ -164,7 +164,7 @@ END_ARRAY 3 39
BEGIN_ARRAY 4 45
'DE-0421LE-0421                          '
'1203A21863267E^8'
'1203A2253DC63C^8'
'1203A2253D432A^8'
'3'
'0'
'1'
@@ -218,25 +218,25 @@ BEGIN_ARRAY 4 45
END_ARRAY 4 45
TOTAL_ARRAYS 4
 ~NAIF/SPC BEGIN COMMENTS~
; /Users/jmapel/ale/nb_test/M103595705LE_0.bsp LOG FILE
; /home/pgiroux/Desktop/lro_slices/M103595705LE_0.bsp LOG FILE

; Created 2019-09-04/12:46:24.00.
; Created 2019-10-11/11:26:30.00.
;
; BEGIN SPKMERGE COMMANDS

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

SPK_KERNEL           = /Users/jmapel/ale/nb_test/M103595705LE_0.bsp
SPK_KERNEL           = /home/pgiroux/Desktop/lro_slices/M103595705LE_0.bsp
SOURCE_SPK_KERNEL = /usgs/cpkgs/isis3/data/lro/kernels/spk/fdf29r_2009182_2009213_v01.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = -85
    BEGIN_TIME       = 2009 JUL 30 12:12:06.204
    END_TIME         = 2009 JUL 30 12:12:19.058
    END_TIME         = 2009 JUL 30 12:12:19.056
  SOURCE_SPK_KERNEL  = /usgs/cpkgs/isis3/data/lro/kernels/tspk/de421.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 3, 10, 301
    BEGIN_TIME       = 2009 JUL 30 12:12:06.204
    END_TIME         = 2009 JUL 30 12:12:19.058
    END_TIME         = 2009 JUL 30 12:12:19.056

; END SPKMERGE COMMANDS
 ~NAIF/SPC END COMMENTS~
+9 −9
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ DAFETF NAIF DAF ENCODED TRANSFER FILE
BEGIN_ARRAY 1 44
'SPK_STATES_13                           '
'1203A4135E494D^8'
'1203A41DC803AB^8'
'1203A41DC78099^8'
'-55'
'12D'
'1'
@@ -60,7 +60,7 @@ END_ARRAY 1 44
BEGIN_ARRAY 2 45
'DE-0421LE-0421                          '
'1203A4135E494D^8'
'1203A41DC803AB^8'
'1203A41DC78099^8'
'12D'
'3'
'1'
@@ -115,7 +115,7 @@ END_ARRAY 2 45
BEGIN_ARRAY 3 39
'DE-0421LE-0421                          '
'1203A4135E494D^8'
'1203A41DC803AB^8'
'1203A41DC78099^8'
'A'
'0'
'1'
@@ -164,7 +164,7 @@ END_ARRAY 3 39
BEGIN_ARRAY 4 45
'DE-0421LE-0421                          '
'1203A4135E494D^8'
'1203A41DC803AB^8'
'1203A41DC78099^8'
'3'
'0'
'1'
@@ -218,25 +218,25 @@ BEGIN_ARRAY 4 45
END_ARRAY 4 45
TOTAL_ARRAYS 4
 ~NAIF/SPC BEGIN COMMENTS~
; /Users/jmapel/ale/nb_test/M103595705LE_1.bsp LOG FILE
; /home/pgiroux/Desktop/lro_slices/M103595705LE_1.bsp LOG FILE

; Created 2019-09-04/12:46:24.00.
; Created 2019-10-11/11:26:31.00.
;
; BEGIN SPKMERGE COMMANDS

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

SPK_KERNEL           = /Users/jmapel/ale/nb_test/M103595705LE_1.bsp
SPK_KERNEL           = /home/pgiroux/Desktop/lro_slices/M103595705LE_1.bsp
SOURCE_SPK_KERNEL = /usgs/cpkgs/isis3/data/lro/kernels/spk/fdf29r_2009182_2009213_v01.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = -85
    BEGIN_TIME       = 2009 JUL 30 12:20:33.185
    END_TIME         = 2009 JUL 30 12:20:43.598
    END_TIME         = 2009 JUL 30 12:20:43.596
  SOURCE_SPK_KERNEL  = /usgs/cpkgs/isis3/data/lro/kernels/tspk/de421.bsp
    INCLUDE_COMMENTS = NO
    BODIES           = 3, 10, 301
    BEGIN_TIME       = 2009 JUL 30 12:20:33.185
    END_TIME         = 2009 JUL 30 12:20:43.598
    END_TIME         = 2009 JUL 30 12:20:43.596

; END SPKMERGE COMMANDS
 ~NAIF/SPC END COMMENTS~
+101 −0
Original line number Diff line number Diff line
Object = IsisCube
  Object = Core
    StartByte   = 65537
    Format      = Tile
    TileSamples = 422
    TileLines   = 512

    Group = Dimensions
      Samples = 5064
      Lines   = 400
      Bands   = 1
    End_Group

    Group = Pixels
      Type       = Real
      ByteOrder  = Lsb
      Base       = 0.0
      Multiplier = 1.0
    End_Group
  End_Object

  Group = Instrument
    SpacecraftName              = "LUNAR RECONNAISSANCE ORBITER"
    InstrumentHostName          = "LUNAR RECONNAISSANCE ORBITER"
    InstrumentHostId            = LRO
    InstrumentName              = "LUNAR RECONNAISSANCE ORBITER NARROW ANGLE
                                   CAMERA LEFT"
    InstrumentId                = NACL
    FrameId                     = LEFT
    TargetName                  = MOON
    MissionPhaseName            = COMMISSIONING
    PrerollTime                 = 2009-07-30T12:20:37.127
    StartTime                   = 2009-07-30T12:20:38.185
    StopTime                    = 2009-07-30T12:21:32.155
    SpacecraftClockPrerollCount = 1/270649237:07208
    SpacecraftClockStartCount   = 1/270649238:11024
    SpacecraftClockStopCount    = 1/270649292:09046
    LineExposureDuration        = 1.028800 <ms>
    TemperatureSCS              = 2.49 <degC>
    TemperatureFPA              = 16.89 <degC>
    TemperatureFPGA             = -14.08 <degC>
    TemperatureTelescope        = 12.38 <degC>
    SpatialSumming              = 1
    SampleFirstPixel            = 0
    TemperatureSCSRaw           = 2833
    TemperatureFPARaw           = 2155
    TemperatureFPGARaw          = 3476
    TemperatureTelescopeRaw     = 2370
  End_Group

  Group = Archive
    DataSetId               = LRO-L-LROC-2-EDR-V1.0
    OriginalProductId       = nacl00002965
    ProductId               = M103595705LE
    ProducerId              = LRO_LROC_TEAM
    ProducerInstitutionName = "ARIZONA STATE UNIVERSITY"
    ProductVersionId        = v1.8
    UploadId                = SC_2009211_0000_B_V01.txt
    OrbitNumber             = 433
    RationaleDescription    = "TARGET OF OPPORTUNITY"
    DataQualityId           = 0
    LineExposureCode        = 81
    DACResetLevel           = 198
    ChannelAOffset          = 40
    ChannelBOffset          = 104
    CompandCode             = 0
    LineCode                = 51
    BTerms                  = (0, 8, 25, 59, 128)
    MTerms                  = (0.5, 0.25, 0.125, 0.0625, 0.03125)
    XTerms                  = (0, 32, 136, 543, 2207)
    CompressionFlag         = 1
    Mode                    = 7
  End_Group

  Group = BandBin
    FilterName = BroadBand
    Center     = 600 <nm>
    Width      = 300 <nm>
  End_Group

  Group = Kernels
    NaifFrameCode = -85600
  End_Group
End_Object

Object = Label
  Bytes = 65536
End_Object

Object = History
  Name      = IsisCube
  StartByte = 1057914881
  Bytes     = 428
End_Object

Object = OriginalLabel
  Name      = IsisCube
  StartByte = 1057915309
  Bytes     = 4411
End_Object
End
+22663 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading