Unverified Commit 917d38e9 authored by Austin Sanders's avatar Austin Sanders Committed by GitHub
Browse files

Initial MGS MOC WAC isislabelnaifspice driver (#516)



* Initial MGS MOC WA driver

* Added test data for mgsmocwa tests

* Added tests for MGS MOC WA driver

* Update mgs_drivers.py

Updated distortion coefficients for MGS MOC Wide Angle

* Added test for blue optical distortion coeffs

---------

Co-authored-by: default avatarJacob Cain <115182890+jrcain-usgs@users.noreply.github.com>
parent b7cd5f9e
Loading
Loading
Loading
Loading
+152 −0
Original line number Diff line number Diff line
import spiceypy as spice

from ale.base import Driver
from ale.base.data_naif import NaifSpice
from ale.base.data_isis import IsisSpice
from ale.base.label_pds3 import Pds3Label
from ale.base.label_isis import IsisLabel
from ale.base.type_distortion import RadialDistortion, NoDistortion
from ale.base.type_sensor import LineScanner
from ale.base.type_distortion import NoDistortion

from ale import util


class MgsMocWideAngleCameraIsisLabelNaifSpiceDriver(LineScanner, IsisLabel, NaifSpice, RadialDistortion, Driver):
    """
    Driver for reading MGS MOC WA ISIS labels.
    """

    @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.
        Expects instrument_id to be defined in the IsisLabel mixin. This should be
        a string of the form 'MOC-WA'

        Returns
        -------
        : str
          instrument id
        """
        id_lookup = {
        "MOC-WA" : "MGS_MOC_WA_"
        }
        pref = id_lookup[super().instrument_id]
        bandbin_filter = self.label['IsisCube']['BandBin']['FilterName']
        return pref+bandbin_filter


    @property
    def sensor_name(self):
        """
        Returns
        -------
        : String
          The name of the sensor
        """
        return self.instrument_id

    @property
    def ephemeris_start_time(self):
        """
        Returns the ephemeris start time of the image.
        Expects spacecraft_id to be defined. This should be the integer
        Naif ID code for the spacecraft.

        Returns
        -------
        : float
          ephemeris start time of the image
        """
        if not hasattr(self, '_ephemeris_start_time'):
            sclock = self.label['IsisCube']['Instrument']['SpacecraftClockCount']
            self._ephemeris_start_time = spice.scs2e(self.spacecraft_id, sclock)
        return self._ephemeris_start_time

    @property
    def ephemeris_stop_time(self):
        """
        ISIS doesn't preserve the spacecraft stop count that we can use to get
        the ephemeris stop time of the image, so compute the ephemeris stop time
        from the start time and the exposure duration.
        """
        return self.ephemeris_start_time + (self.exposure_duration/1000 * ((self.image_lines) * self.label['IsisCube']['Instrument']['DowntrackSumming']))

    @property
    def detector_start_sample(self):
        """
        Returns
        -------
        : int
          The starting detector sample of the image
        """
        return self.label['IsisCube']['Instrument']['FirstLineSample']


    @property
    def detector_center_sample(self):
        """
        Returns the center detector sample. Expects ikid to be defined. This should
        be an integer containing the Naif Id code of the instrument.

        Returns
        -------
        : float
          Detector sample of the principal point
        """
        return float(spice.gdpool('INS{}_CENTER'.format(self.ikid), 0, 1)[0])

    @property
    def detector_center_line(self):
        """
        Returns the center detector line. Expects ikid to be defined. This should
        be an integer containing the Naif Id code of the instrument.

        Returns
        -------
        : float
          Detector line of the principal point
        """
        return float(spice.gdpool('INS{}_CENTER'.format(self.ikid), 0, 2)[1])


    @property
    def sensor_model_version(self):
        """
        The ISIS Sensor model number for HiRise in ISIS. This is likely just 1

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

    @property
    def ikid(self):
        """
        Overridden to grab the ikid from the Isis Cube since there is no way to
        obtain this value with a spice bods2c call. Isis sets this value during
        ingestion, based on the original IMG file.

        Returns
        -------
        : int
          Naif ID used to for identifying the instrument in Spice kernels
        """
        return self.label["IsisCube"]["Kernels"]["NaifFrameCode"]

    @property
    def odtk(self):
        """
        The optical distortion coefficients for radial distortion in MGS MOC WA.

        These values appear in the IK / IAK, but are not listed under OD_K.
        """
        if self.instrument_id == "MGS_MOC_WA_RED":
            return [0, -.007, .007]
        else:
            return [0, .007, .007]
+172 −0
Original line number Diff line number Diff line
KPL/SCLK

Status 
-----------------------------------------------

   This file is a SPICE spacecraft clock (SCLK) kernel containing
   information required for Mars Global Surveyor spacecraft on-board
   clock to ET conversion. This file also contains definitions
   of MGS reference frames.


Production/History of this SCLK files
-----------------------------------------------

   This file was generated by the NAIF utility program MAKCLK,
   version 3.3, from the most recent Mars Global Surveyor spacecraft
   SCLK SCET file.


Usage
-----------------------------------------------

   This file must be loaded into the user's program by a call to
   the LDPOOL subroutine
   
         CALL LDPOOL( 'this_file_name' )
         
   in order to use the SPICELIB SCLK family of subroutines to
   convert MGS spacecraft on-board clock to ET and vice versa and
   to use MGS frames defined below as reference frames for
   geometric quantities being returned by high-level SPK and
   CK subroutines.


References
-----------------------------------------------

   1. SCLK Required Reading file, NAIF document number 222
   2. MAKCLK User's Guide, NAIF document number 267
   

Inquiries
-----------------------------------------------

   If you have any questions regarding this file contact
   
   MGS Spacecraft Operations Team (SCOPS)
   Lockheed/Martin, Denver

   Boris Semenov - NAIF/JPL
   (818) 354-8136
   bsemenov@spice.jpl.nasa.gov


SCLK DATA
-----------------------------------------------

\begindata

SCLK_KERNEL_ID           = ( @2006-02-26/00:38:24.00 )

SCLK_DATA_TYPE_94        = ( 1 )
SCLK01_TIME_SYSTEM_94    = ( 2 )
SCLK01_N_FIELDS_94       = ( 2 )
SCLK01_MODULI_94         = ( 4294967296 256 )
SCLK01_OFFSETS_94        = ( 0 0 )
SCLK01_OUTPUT_DELIM_94   = ( 1 )

SCLK_PARTITION_START_94  = ( 1.3611133440000E+11 )

SCLK_PARTITION_END_94    = ( 1.0995116277750E+12 )

SCLK01_COEFFICIENTS_94   = (
 
    0.0000000000000E+00     -9.9510252675000E+07     9.9999996301748E-01
    8.3066265600000E+08     -9.6265476795000E+07     9.9999994844682E-01
    1.9330583040000E+09     -9.1959244017000E+07     9.9999994927604E-01
    2.7708477440000E+09     -8.8686629183000E+07     9.9999994213351E-01
    4.0538009600000E+09     -8.3675093473000E+07     9.9999993609973E-01
    4.7829370880000E+09     -8.0826905655000E+07     9.9999993275158E-01
    5.2473643520000E+09     -7.9012736777000E+07     9.9999993064539E-01
    5.4909818880000E+09     -7.8061105843000E+07     9.9999992770059E-01
    6.7515176960000E+09     -7.3137138199000E+07     9.9999992410889E-01
    7.9017973760000E+09     -6.8643858540000E+07     9.9999992038548E-01
    8.9854187520000E+09     -6.4410962877000E+07     9.9999991689249E-01
    9.9588085760000E+09     -6.0608659193000E+07     9.9999991330346E-01
    1.1222619136000E+10     -5.5671899621000E+07     9.9999990916047E-01
    1.2448517120000E+10     -5.0883236056000E+07     9.9999990447344E-01
    1.3831336704000E+10     -4.5481597572000E+07     9.9999990051645E-01
    1.5223486464000E+10     -4.0043513113000E+07     9.9999989497162E-01
    1.7390367488000E+10     -3.1579135002000E+07     9.9999988993180E-01
    1.7567130624000E+10     -3.0888654078000E+07     9.9999989034894E-01
    1.9308801024000E+10     -2.4085254824000E+07     9.9999988778163E-01
    2.0709498624000E+10     -1.8613780438000E+07     9.9999988586150E-01
    2.1416008704000E+10     -1.5853975753000E+07     9.9999988403100E-01
    2.2566109184000E+10     -1.1361396274000E+07     9.9999988221971E-01
    2.3583325184000E+10     -7.3878967420000E+06     9.9999988085764E-01
    2.4401976064000E+10     -4.1900421230000E+06     9.9999987748439E-01
    2.6148822784000E+10     2.6335770410000E+06     9.9999987443431E-01
    2.7343544064000E+10     7.3004564550000E+06     9.9999987288243E-01
    2.7697987584000E+10     8.6850012790000E+06     9.9999986959544E-01
    3.0497398784000E+10     1.9620199853000E+07     9.9999986397005E-01
    3.3094473984000E+10     2.9765023473000E+07     9.9999986031472E-01
    3.3757908224000E+10     3.2356563111000E+07     9.9999986120037E-01
    3.4879294464000E+10     3.6736977503000E+07     9.9999985904003E-01
    3.6655458304000E+10     4.3675116525000E+07     9.9999985800849E-01
    3.7663293184000E+10     4.7611970966000E+07     9.9999985675497E-01
    3.9177007104000E+10     5.3524915119000E+07     9.9999985536588E-01
    3.9998279424000E+10     5.6733009655000E+07     9.9999985291347E-01
    4.1764858624000E+10     6.3633708640000E+07     9.9999985124879E-01
    4.2117662464000E+10     6.5011848435000E+07     9.9999984781791E-01
    4.2274106624000E+10     6.5622958342000E+07     9.9999984882922E-01
    4.4218185984000E+10     7.3217017194000E+07     9.9999984659583E-01
    4.5149373184000E+10     7.6854466636000E+07     9.9999984377543E-01
    4.7697499904000E+10     8.6808085081000E+07     9.9999984158856E-01
    4.8250187264000E+10     8.8967019739000E+07     9.9999984042488E-01
    5.0351768064000E+10     9.7176318429000E+07     9.9999983895938E-01
    5.1873073664000E+10     1.0311891747200E+08     9.9999983890233E-01
    5.4328230144000E+10     1.1270937092700E+08     9.9999983767097E-01
    5.5435314944000E+10     1.1703392022500E+08     9.9999983571827E-01
    5.6783243264000E+10     1.2229926436000E+08     9.9999983408405E-01
    5.8043833344000E+10     1.2722344354300E+08     9.9999983141787E-01
    6.0034649344000E+10     1.3500006723200E+08     9.9999982876103E-01
    6.2733100544000E+10     1.4554089042700E+08     9.9999982638865E-01
    6.4568925184000E+10     1.5271207918200E+08     9.9999982473500E-01
    6.5962380800000E+10     1.5815526422800E+08     9.9999982462235E-01
    7.0164877568000E+10     1.7457126434900E+08     9.9999982312096E-01
    7.2044942080000E+10     1.8191526505000E+08     9.9999982107624E-01
    7.3394164736000E+10     1.8718566510700E+08     9.9999981990749E-01
    7.3947124992000E+10     1.8934566571800E+08     9.9999981862840E-01
    7.5141225984000E+10     1.9401012187200E+08     9.9999981500000E-01 )

\begintext

MGS Frame Definitions 
-----------------------------------------------

The variables below define the MGS spacecraft, subsystems and 
instrument frames within the SPICE Toolkit Frames mechanism.
In order to use "MGS_SPACECRAFT" as the value for the FRAME 
argument defining the reference frame for output geometric 
quantities in calls to
        CKGP
        CKGPAV
        SPKEZ
        SPKEZR
SPICELIB subroutines, or to be able to read CK orientation data
for some MGS subsystem or instrument if these data are referenced
to this frame in the file, these definitions along with the CK file
containing MGS spacecraft orientation must be loaded into the user's
program.

\begindata
 
   FRAME_MGS_SPACECRAFT          = -94000
   FRAME_-94000_NAME             = 'MGS_SPACECRAFT'
   FRAME_-94000_CLASS            =  3
   FRAME_-94000_CLASS_ID         = -94000
   FRAME_-94000_CENTER           = -94

   FRAME_MGS_LEFT_SOLAR_ARRAY    = -94001
   FRAME_-94001_NAME             = 'MGS_LEFT_SOLAR_ARRAY'
   FRAME_-94001_CLASS            =  3
   FRAME_-94001_CLASS_ID         = -94001
   FRAME_-94001_CENTER           = -94

   FRAME_MGS_RIGHT_SOLAR_ARRAY   = -94002
   FRAME_-94002_NAME             = 'MGS_RIGHT_SOLAR_ARRAY'
   FRAME_-94002_CLASS            =  3
   FRAME_-94002_CLASS_ID         = -94002
   FRAME_-94002_CENTER           = -94
+14965 −0

File added.

Preview size limit exceeded, changes collapsed.

+356 −0
Original line number Diff line number Diff line
Object = IsisCube
  Object = Core
    StartByte   = 65537
    Format      = Tile
    TileSamples = 640
    TileLines   = 768

    Group = Dimensions
      Samples = 640
      Lines   = 768
      Bands   = 1
    End_Group

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

  Group = Instrument
    SpacecraftName        = "MARS GLOBAL SURVEYOR"
    InstrumentId          = MOC-WA
    TargetName            = Mars
    StartTime             = 1997-10-20T10:58:37.46
    StopTime              = 1997-10-20T11:03:44.66
    CrosstrackSumming     = 4
    DowntrackSumming      = 4
    FocalPlaneTemperature = 213.1
    GainModeId            = 1A
    LineExposureDuration  = 100.000000 <milliseconds>
    MissionPhaseName      = AB-1
    OffsetModeId          = 5
    SpacecraftClockCount  = 561812335:32
    RationaleDesc         = "OLYMPUS MONS SPECIAL RED WIDE ANGLE"
    FirstLineSample       = 673
  End_Group

  Group = Archive
    DataSetId           = MGS-M-MOC-NA/WA-2-DSDP-L0-V1.0
    ProductId           = AB-1-024/01
    ProducerId          = MGS_MOC_TEAM
    ProductCreationTime = 1999-01-15T20:40:59
    SoftwareName        = "makepds 1.3"
    UploadId            = moc_p024_v1.sasf
    ImageNumber         = 7293-024/01
    ImageKeyId          = 56181-024/01
  End_Group

  Group = BandBin
    FilterName   = RED
    OriginalBand = 1
    Center       = 0.6134 <micrometers>
    Width        = 0.05 <micrometers>
  End_Group

  Group = Kernels
    NaifFrameCode             = -94032
    LeapSecond                = $base/kernels/lsk/naif0012.tls
    TargetAttitudeShape       = $base/kernels/pck/pck00009.tpc
    TargetPosition            = (Table, $base/kernels/spk/de430.bsp,
                                 $base/kernels/spk/mar097.bsp)
    InstrumentPointing        = (Table, $mgs/kernels/ck/mgs_sc_ab1.bc)
    Instrument                = $mgs/kernels/ik/moc20.ti
    SpacecraftClock           = $mgs/kernels/sclk/MGS_SCLKSCET.00061.tsc
    InstrumentPosition        = (Table, $mgs/kernels/spk/mgs_ab1.bsp)
    InstrumentAddendum        = $mgs/kernels/iak/mocAddendum004.ti
    ShapeModel                = $base/dems/molaMarsPlanetaryRadius0005.cub
    InstrumentPositionQuality = Reconstructed
    InstrumentPointingQuality = Reconstructed
    CameraVersion             = 1
    Source                    = isis
  End_Group
End_Object

Object = Label
  Bytes = 65536
End_Object

Object = Table
  Name                = InstrumentPointing
  StartByte           = 559125
  Bytes               = 5056
  Records             = 79
  ByteOrder           = Lsb
  TimeDependentFrames = (-94000, 1)
  ConstantFrames      = (-94032, -94000)
  ConstantRotation    = (0.99987464549874, -0.013867590674599,
                         0.0076408911550023, 0.013725141347892,
                         0.99973667434259, 0.01839028192833,
                         -0.0078939080144882, -0.018283104312584,
                         0.99980168749255)
  CkTableStartTime    = -69382819.360519
  CkTableEndTime      = -69382512.160519
  CkTableOriginalSize = 769
  FrameTypeCode       = 3
  Description         = "Created by spiceinit"
  Kernels             = $mgs/kernels/ck/mgs_sc_ab1.bc

  Group = Field
    Name = J2000Q0
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q1
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q2
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q3
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV1
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV2
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV3
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = ET
    Type = Double
    Size = 1
  End_Group
End_Object

Object = Table
  Name                 = InstrumentPosition
  StartByte            = 564181
  Bytes                = 336
  Records              = 6
  ByteOrder            = Lsb
  CacheType            = HermiteSpline
  SpkTableStartTime    = -69382819.360519
  SpkTableEndTime      = -69382512.160519
  SpkTableOriginalSize = 769.0
  Description          = "Created by spiceinit"
  Kernels              = $mgs/kernels/spk/mgs_ab1.bsp

  Group = Field
    Name = J2000X
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Y
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Z
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000XV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000YV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000ZV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = ET
    Type = Double
    Size = 1
  End_Group
End_Object

Object = Table
  Name                = BodyRotation
  StartByte           = 564517
  Bytes               = 128
  Records             = 2
  ByteOrder           = Lsb
  TimeDependentFrames = (10014, 1)
  CkTableStartTime    = -69382819.360519
  CkTableEndTime      = -69382512.160519
  CkTableOriginalSize = 2
  FrameTypeCode       = 2
  PoleRa              = (317.68143, -0.1061, 0.0)
  PoleDec             = (52.8865, -0.0609, 0.0)
  PrimeMeridian       = (176.63, 350.89198226, 0.0)
  Description         = "Created by spiceinit"
  Kernels             = ($base/kernels/spk/de430.bsp,
                         $base/kernels/spk/mar097.bsp,
                         $base/kernels/pck/pck00009.tpc)
  SolarLongitude      = 201.83158930552

  Group = Field
    Name = J2000Q0
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q1
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q2
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Q3
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV1
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV2
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = AV3
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = ET
    Type = Double
    Size = 1
  End_Group
End_Object

Object = Table
  Name                 = SunPosition
  StartByte            = 564645
  Bytes                = 112
  Records              = 2
  ByteOrder            = Lsb
  CacheType            = Linear
  SpkTableStartTime    = -69382819.360519
  SpkTableEndTime      = -69382512.160519
  SpkTableOriginalSize = 2.0
  Description          = "Created by spiceinit"
  Kernels              = ($base/kernels/spk/de430.bsp,
                          $base/kernels/spk/mar097.bsp)

  Group = Field
    Name = J2000X
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Y
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000Z
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000XV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000YV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = J2000ZV
    Type = Double
    Size = 1
  End_Group

  Group = Field
    Name = ET
    Type = Double
    Size = 1
  End_Group
End_Object

Object = History
  Name      = IsisCube
  StartByte = 564757
  Bytes     = 1386
End_Object

Object = OriginalLabel
  Name      = IsisCube
  StartByte = 557537
  Bytes     = 1588
End_Object

Object = NaifKeywords
  BODY_CODE                          = 499
  BODY499_RADII                      = (3396.19, 3396.19, 3376.2)
  BODY_FRAME_CODE                    = 10014
  INS-94032_FOCAL_LENGTH             = 11.20537656
  INS-94032_PIXEL_PITCH              = 0.007
  CLOCK_ET_-94_561812335:32_COMPUTED = e62b718dca8a90c1
  INS-94032_TRANSX                   = (0.0, 0.0, 0.007)
  INS-94032_TRANSY                   = (0.0, -0.007, 0.0)
  INS-94032_ITRANSS                  = (0.0, 0.0, -142.8571429)
  INS-94032_ITRANSL                  = (0.0, 142.8571429, 0.0)
End_Object
End
+453767 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading