Commit 199d9b23 authored by paarongiroux's avatar paarongiroux Committed by Jesse Mapel
Browse files

Updated numpy docstrings (#190)

* updated docstrings in mixins and concrete drivers

* more docstrings

* more descriptive doc changes
parent 9cc59a96
Loading
Loading
Loading
Loading
+75 −6
Original line number Diff line number Diff line
@@ -55,10 +55,22 @@ class Driver(ABC):

    @abc.abstractproperty
    def detector_start_line(self):
        """
        Returns
        -------
        : int
          Detector line corresponding to the first image line
        """
        pass

    @abc.abstractproperty
    def detector_start_sample(self):
        """
        Returns
        -------
        : int
          Detector sample corresponding to the first image sample
        """
        pass

    @abc.abstractproperty
@@ -83,10 +95,22 @@ class Driver(ABC):

    @abc.abstractproperty
    def platform_name(self):
        """
        Returns
        -------
        : str
          Name of the platform that the sensor is on
        """
        pass

    @abc.abstractproperty
    def sensor_name(self):
        """
        Returns
        -------
        : str
          Name of the sensor
        """
        pass

    @abc.abstractproperty
@@ -111,10 +135,22 @@ class Driver(ABC):

    @abc.abstractproperty
    def detector_center_line(self):
        """
        Returns
        -------
        : int
          The detector line of the principle point
        """
        pass

    @abc.abstractproperty
    def detector_center_sample(self):
        """
        Returns
        -------
        : int
          The detector sample of the principle point
        """
        pass

    @abc.abstractproperty
@@ -123,13 +159,18 @@ class Driver(ABC):
        Returns
        -------
        : (positions, velocities, times)
          a tuple containing a list of positions, a list of velocities, and a list of timess
          a tuple containing a list of positions, a list of velocities, and a list of times
        """
        pass

    @abc.abstractproperty
    #Get the frame chain between two frames and the frame types for all returned frames
    def frame_chain(self):
        """
        Returns
        -------
        FrameNode
            The root node of the frame tree. This will always be the J2000 reference frame.
        """
        pass

    @abc.abstractproperty
@@ -194,18 +235,46 @@ class Driver(ABC):

    @abc.abstractproperty
    def focal2pixel_lines(self):
        """
        Returns
        -------
        : list
          3 element list containing affine transformation coefficient.
          The elements are as follows: constant, x coefficent, y coeffecient
        """
        pass

    @abc.abstractproperty
    def focal2pixel_samples(self):
        """
        Returns
        -------
        : list
          3 element list containing affine transformation coefficients.
          The elements are as follows: constant, x coefficent, y coeffecient
        """
        pass

    @abc.abstractproperty
    def pixel2focal_x(self):
        """
        Returns
        -------
        : list
          3 element list containing coefficience for the pixels to focal plane
          transformation. The elements are as follows: constant, sample, line
        """
        pass

    @abc.abstractproperty
    def pixel2focal_y(self):
        """
        Returns
        -------
        : : list
          3 element list containing coefficience for the pixels to focal plane
          transformation. The elements are as follows: constant, sample, line
        """
        pass

    @abc.abstractproperty
@@ -213,8 +282,8 @@ class Driver(ABC):
        """
          Returns
        -------
        : str
          Start time of the image in UTC YYYY-MM-DDThh:mm:ss[.fff]
        : double
          The start time of the image in ephemeris seconds past the J2000 epoch.
        """
        pass

@@ -223,7 +292,7 @@ class Driver(ABC):
        """
          Returns
        -------
        : str
          Stop time of the image in UTC YYYY-MM-DDThh:mm:ss[.fff]
        : double
          The stop time of the image in ephemeris seconds past the J2000 epoch.
        """
        pass
+109 −3
Original line number Diff line number Diff line
@@ -283,6 +283,11 @@ class IsisSpice(IsisLabel):
        """
        ISIS Table containing the rotation between the J2000 reference frame
        and the instrument reference frame.

        Returns
        -------
        : dict
          Instrument pointing table
        """
        if not hasattr(self, "_inst_pointing_table"):
            for table in self.label.getlist('Table'):
@@ -297,6 +302,11 @@ class IsisSpice(IsisLabel):
        """
        ISIS Table containing the rotation between the J2000 reference frame
        and the target body reference frame.

        Returns
        -------
        : dict
          Body orientation table
        """
        if not hasattr(self, "_body_orientation_table"):
            for table in self.label.getlist('Table'):
@@ -311,6 +321,11 @@ class IsisSpice(IsisLabel):
        """
        ISIS Table containing the location of the instrument relative to the
        target body in the J2000 reference frame.

        Returns
        -------
        : dict
          Instrument position table
        """
        if not hasattr(self, "_inst_position_table"):
            for table in self.label.getlist('Table'):
@@ -325,6 +340,11 @@ class IsisSpice(IsisLabel):
        """
        ISIS Table containing the location of the sun relative to the
        target body in the J2000 reference frame.

        Returns
        -------
        : dict
          Sun position table
        """
        if not hasattr(self, "_sun_position_table"):
            for table in self.label.getlist('Table'):
@@ -352,6 +372,9 @@ class IsisSpice(IsisLabel):
    def number_of_quaternions(self):
        """
        The number of instrument rotation quaternions
        Expects inst_position_table to be defined. This should be a dict
        containing the rotation between the J2000 reference frame
        and the instrument reference frame.

        Returns
        -------
@@ -365,6 +388,9 @@ class IsisSpice(IsisLabel):
        """
        The number of instrument position states. These may
        be just positions or positions and vbelocities.
        Expects inst_position_table to be defined. This should be a dict
        containing the rotation between the J2000 reference frame
        and the instrument reference frame.

        Returns
        -------
@@ -378,6 +404,8 @@ class IsisSpice(IsisLabel):
        """
        The hex encoded image start time computed from the
        spacecraft clock count
        Expects naif_keywords to be defined. This should be a dict containing
        Naif keyworkds from the label.

        Returns
        -------
@@ -397,6 +425,8 @@ class IsisSpice(IsisLabel):
    def ephemeris_start_time(self):
        """
        The image start time in ephemeris time
        Expects sclock_hex_string to be defined. This should be a string
        containing the hex start time of the image

        Returns
        -------
@@ -409,6 +439,8 @@ class IsisSpice(IsisLabel):
    def detector_center_sample(self):
        """
        The center of the CCD in detector pixels
        Expects ikid to be defined. this should be the integer Naif ID code for
        the instrument.

        Returns
        -------
@@ -421,6 +453,8 @@ class IsisSpice(IsisLabel):
    def detector_center_line(self):
        """
        The center of the CCD in detector pixels
        Expects ikid to be defined. this should be the integer Naif ID code for
        the instrument.

        Returns
        -------
@@ -449,6 +483,8 @@ class IsisSpice(IsisLabel):
        """
        The Kernels group from the ISIS cube label.
        This is where the original SPICE kernels are listed.
        Expects cube_label to be defined. This should be a PVLModule containing
        the ISIS cube label.

        Returns
        -------
@@ -463,6 +499,8 @@ class IsisSpice(IsisLabel):
    def ikid(self):
        """
        The NAIF id for the instrument
        Expects kernels_group to be defined. This should be a PVLModule
        containing the kernels group.

        Returns
        -------
@@ -480,6 +518,10 @@ class IsisSpice(IsisLabel):
        """
        The line component of the affine transformation
        from focal plane coordinates to centered ccd pixels
        Expects naif_keywords to be defined. This should be a dict containing
        Naif keyworkds from the label.
        Expects ikid to be defined. This should be the integer Naif ID code
        for the instrument.

        Returns
        -------
@@ -494,6 +536,10 @@ class IsisSpice(IsisLabel):
        """
        The sample component of the affine transformation
        from focal plane coordinates to centered ccd pixels
        Expects naif_keywords to be defined. This should be a dict containing
        Naif keyworkds from the label.
        Expects ikid to be defined. This should be the integer Naif ID code
        for the instrument.

        Returns
        -------
@@ -507,6 +553,10 @@ class IsisSpice(IsisLabel):
    def focal_length(self):
        """
        The focal length of the instrument
        Expects naif_keywords to be defined. This should be a dict containing
        Naif keyworkds from the label.
        Expects ikid to be defined. This should be the integer Naif ID code
        for the instrument.

        Returns
        -------
@@ -519,6 +569,8 @@ class IsisSpice(IsisLabel):
    def _body_radii(self):
        """
        The triaxial radii of the target body
        Expects naif_keywords to be defined. This should be a dict containing
        Naif keyworkds from the label.

        Returns
        -------
@@ -536,6 +588,8 @@ class IsisSpice(IsisLabel):
        """
        The radius of the target body at its widest
        diameter
        Expects body_radii to be defined. This should be a list containing
        the body radii in kilometers.

        Returns
        -------
@@ -549,6 +603,8 @@ class IsisSpice(IsisLabel):
        """
        The radius of the target body perpendicular to its
        widest diameter
        Expects body_radii to be defined. This should be a list containing
        the body radii in kilometers.

        Returns
        -------
@@ -562,6 +618,9 @@ class IsisSpice(IsisLabel):
        """
        List of time dependent reference frames between the
        target body reference frame and the J2000 frame.
        Expects body_orientation_table to be defined. This is a dict
        containing information about the rotation from J2000 to the body
        fixed reference frame.

        Returns
        -------
@@ -578,6 +637,8 @@ class IsisSpice(IsisLabel):
    def reference_frame(self):
        """
        The NAIF ID for the target body reference frame
        Expects body_time_dependent_frames to be defined. This should be a
        list containing time dependent frames.

        Returns
        -------
@@ -590,6 +651,9 @@ class IsisSpice(IsisLabel):
    def _sun_position(self):
        """
        The sun position
        Expects sun_position_table to be defined. This should be a
        dictionary that contains information about the location of the sun
        relative to the center of the target body.

        Returns
        -------
@@ -604,6 +668,9 @@ class IsisSpice(IsisLabel):
    def _sun_velocity(self):
        """
        The sun velocity
        Expects sun_position_table to be defined. This should be a
        dictionary that contains information about the location of the sun
        relative to the center of the target body.

        Returns
        -------
@@ -616,6 +683,17 @@ class IsisSpice(IsisLabel):
    @property
    def _sensor_position(self):
        """
        Sensor position
        Expects inst_position_table to be defined. This should be a
        dictionary that contains information about the location of the
        sensor relative to the center of the target body.
        Expects number_of_ephemerides to be defined. This should be an integer
        containing the number of instrument position states.

        Returns
        -------
        : (positions, velocities, times)
          a tuple containing a list of positions, a list of velocities, and a list of times
        """
        inst_positions_times = np.linspace(self.inst_position_table["Times"][0],
                                           self.inst_position_table["Times"][-1],
@@ -647,6 +725,11 @@ class IsisSpice(IsisLabel):
    def _sensor_velocity(self):
        """
        The sensor velocity
        Expects inst_position_table to be defined. This should be a
        dictionary that contains information about the location of the
        sensor relative to the center of the target body.
        Expects number_of_ephemerides to be defined. This should be an integer
        containing the number of instrument position states.

        Returns
        -------
@@ -679,8 +762,12 @@ class IsisSpice(IsisLabel):
    @property
    def _sensor_orientation(self):
        """
        The rotation from J2000 to the sensor reference
        frame
        The rotation from J2000 to the sensor reference frame
        Expects inst_position_table to be defined. This should be a
        dictionary that contains information about the location of the
        sensor relative to the center of the target body.
        Expects number_of_quatiernions. This should be an integer
        containing the number of instrument rotation quaternions

        Returns
        -------
@@ -707,6 +794,9 @@ class IsisSpice(IsisLabel):
        """
        The rotation from J2000 to the target body
        reference frame
        Expects body_orientation_table to be defined. This should be a
        dictionary that contains information about the rotation from J2000
        to the body fixed reference frame.

        Returns
        -------
@@ -734,6 +824,16 @@ class IsisSpice(IsisLabel):

    @property
    def odtk(self):
        """
        Returns optical distortion coefficients
        Expects ikid to be defined. This should be the integer Naif ID code
        for the instrument

        Returns
        -------
        : list
          optical distortion coefficients
        """
        return self.label["NaifKeywords"]["INS{}_OD_K".format(self.ikid)]

    @property
@@ -743,7 +843,13 @@ class IsisSpice(IsisLabel):
        Mt is the time dependant portion of the rotation from j2000 to body fixed
        Mc is contant portion of the rotation from J2000 to body fixed.

        This represents the rotation to get positions from J2000 to body fixed,
        This represents the rotation to get positions from J2000 to body fixed.

        Expects body_orientation_table to be defined. This should be a
        dictionary that contains information about the rotation from J2000
        to the body fixed reference frame.
        Expects number_of_ephemerides to be defined. This should be an integer
        containing the number of instrument position states.
        """
        body_rot_times = self.body_orientation_table["Times"]
        body_timed_rots = self.body_orientation_table["Rotations"]
+209 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ class NaifSpice():
    @property
    def odtx(self):
        """
        Returns the x coefficient for the optical distortion model
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list
@@ -39,6 +42,9 @@ class NaifSpice():
    @property
    def odty(self):
        """
        Returns the y coefficient for the optical distortion model.
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list
@@ -49,6 +55,9 @@ class NaifSpice():
    @property
    def odtk(self):
        """
        The coefficients for the radial distortion model
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list
@@ -59,6 +68,10 @@ class NaifSpice():
    @property
    def ikid(self):
        """
        Returns the Naif ID code for the instrument
        Expects the instrument_id to be defined. This must be a string containing
        the short name of the instrument.

        Returns
        -------
        : int
@@ -68,48 +81,139 @@ class NaifSpice():

    @property
    def spacecraft_id(self):
        """
        Returns the Naif ID code for the spacecraft
        Expects the spacecraft_name to be defined. This must be a string containing
        the name of the spacecraft.

        Returns
        -------
        : int
          Naif ID code for the spacecraft
        """
        return spice.bods2c(self.spacecraft_name)

    @property
    def target_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
        """
        return spice.bods2c(self.target_name)

    @property
    def target_frame_id(self):
        """
        Returns the Naif ID code for the target reference frame
        Expects the target_id to be defined. This must be the integer Naif ID code
        for the target body.

        Returns
        -------
        : int
          Naif ID code for the target frame
        """
        frame_info = spice.cidfrm(self.target_id)
        return frame_info[0]

    @property
    def sensor_frame_id(self):
        """
        Returns the Naif ID code for the sensor reference frame
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : int
          Naif ID code for the sensor frame
        """
        return self.ikid

    @property
    def focal2pixel_lines(self):
        """
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list<double>
          focal plane to detector lines
        """
        return list(spice.gdpool('INS{}_ITRANSL'.format(self.ikid), 0, 3))

    @property
    def focal2pixel_samples(self):
        """
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list<double>
          focal plane to detector samples
        """
        return list(spice.gdpool('INS{}_ITRANSS'.format(self.ikid), 0, 3))

    @property
    def pixel2focal_x(self):
        """
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list<double>
        detector to focal plane x
        """
        return list(spice.gdpool('INS{}_TRANSX'.format(self.ikid), 0, 3))

    @property
    def pixel2focal_y(self):
        """
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : list<double>
        detector to focal plane y
        """
        return list(spice.gdpool('INS{}_TRANSY'.format(self.ikid), 0, 3))

    @property
    def focal_length(self):
        """
        Returns the focal length of the sensor
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : float
          focal length
        """
        return float(spice.gdpool('INS{}_FOCAL_LENGTH'.format(self.ikid), 0, 1)[0])

    @property
    def pixel_size(self):
        """
        Expects ikid to be defined. This must be the integer Naif id code of the instrument

        Returns
        -------
        : float pixel size
        """
        return spice.gdpool('INS{}_PIXEL_SIZE'.format(self.ikid), 0, 1)[0] * 0.001

    @property
    def target_body_radii(self):
        """
        Returns a list containing the radii of the target body
        Expects target_name to be defined. This must be a string containing the name
        of the target body

        Returns
        -------
        : list<double>
@@ -120,10 +224,33 @@ class NaifSpice():

    @property
    def reference_frame(self):
        """
        Returns a string containing the name of the target reference frame
        Expects target_name to be defined. This must be a string containing the name
        of the target body

        Returns
        -------
        : str
        String name of the target reference frame
        """
        return 'IAU_{}'.format(self.target_name)

    @property
    def sun_position(self):
        """
        Returns a tuple with information detailing the sun position at the time
        of the image. Expects center_ephemeris_time to be defined. This must be
        a floating point number containing the average of the start and end ephemeris time.
        Expects reference frame to be defined. This must be a sring containing the name of
        the target reference frame. Expects target_name to be defined. This must be
        a string containing the name of the target body.

        Returns
        -------
        : (sun_positions, sun_velocities)
          a tuple containing a list of sun positions, a list of sun velocities
        """
        sun_state, _ = spice.spkezr("SUN",
                                     self.center_ephemeris_time,
                                     self.reference_frame,
@@ -134,6 +261,20 @@ class NaifSpice():

    @property
    def sensor_position(self):
        """
        Returns a tuple with information detailing the position of the sensor at the time
        of the image. Expects ephemeris_time to be defined. This must be a floating point number
        containing the ephemeris time. Expects spacecraft_name to be defined. This must be a
        string containing the name of the spacecraft containing the sensor. Expects
        reference_frame to be defined. This must be a sring containing the name of
        the target reference frame. Expects target_name to be defined. This must be
        a string containing the name of the target body.

        Returns
        -------
        : (positions, velocities, times)
          a tuple containing a list of positions, a list of velocities, and a list of times
        """
        if not hasattr(self, '_position'):
            ephem = self.ephemeris_time
            pos = []
@@ -218,6 +359,18 @@ class NaifSpice():

    @property
    def sensor_orientation(self):
        """
        Returns quaternions describing the sensor orientation. Expects ephemeris_time
        to be defined. This must be a floating point number containing the
        ephemeris time. Expects instrument_id to be defined. This must be a string
        containing the short name of the instrument. Expects reference frame to be defined.
        This must be a sring containing the name of the target reference frame.

        Returns
        -------
        : list
          Quaternions describing the orientation of the sensor
        """
        if not hasattr(self, '_orientation'):
            ephem = self.ephemeris_time

@@ -235,10 +388,32 @@ class NaifSpice():

    @property
    def ephemeris_start_time(self):
        """
        Returns the starting ephemeris time of the image. Expects spacecraft_id to
        be defined. This must be the integer Naif Id code for the spacecraft. Expects
        spacecraft_clock_start_count to be defined. This must be a string
        containing the start clock count of the spacecraft

        Returns
        -------
        : double
          Starting ephemeris time of the image
        """
        return spice.scs2e(self.spacecraft_id, self.spacecraft_clock_start_count)

    @property
    def ephemeris_stop_time(self):
        """
        Returns the ephemeris stop time of the image. Expects spacecraft_id to
        be defined. This must be the integer Naif Id code for the spacecraft.
        Expects spacecraft_clock_stop_count to be defined. This must be a string
        containing the stop clock count of the spacecraft

        Returns
        -------
        : double
          Ephemeris stop time of the image
        """
        if self.spacecraft_clock_stop_count:
            return spice.scs2e(self.spacecraft_id, self.spacecraft_clock_stop_count)
        else:
@@ -246,18 +421,52 @@ class NaifSpice():

    @property
    def center_ephemeris_time(self):
        """
        Returns the average of the start and stop ephemeris times. Expects
        ephemeris start and stop times to be defined. These should be double precision
        numbers containing the ephemeris start and stop times of the image.

        Returns
        -------
        : double
          Center ephemeris time for an image
        """
        return (self.ephemeris_start_time + self.ephemeris_stop_time)/2

    @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{}_BORESIGHT_SAMPLE'.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{}_BORESIGHT_LINE'.format(self.ikid), 0, 1)[0])

    @property
    def isis_naif_keywords(self):
        """
        Returns
        -------
        : dict
          Dictionary of keywords and values that ISIS creates and attaches to the label
        """
        naif_keywords = dict()

        naif_keywords['BODY{}_RADII'.format(self.target_id)] = self.target_body_radii
+27 −0

File changed.

Preview size limit exceeded, changes collapsed.

+63 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading