Пример #1
0
def Ls(et, return_marsyear=False):
    """Convert string or SPICE ET to Mars solar longitude. Requires SPICE
    kernels.

    Parameters
    ----------
    et : float or str
        Time to convert, either an ET or a format understood
        by spiceypy.str2et.
    return_marsyear : bool
        Whether to return the Mars Year of the input date.

    Returns
    -------
    Ls : float
        Mars Solar Longitude
    marsyear : int
        Mars Year, if requested.

    """
    et = check_et(et)
    ls = spice.lspcn('MARS', et, 'NONE')
    ls = ls * 180 / np.pi
    if not return_marsyear:
        return ls

    marsyear = np.searchsorted(marsyearbounds_et, et)
    return ls, marsyear
Пример #2
0
    def spice_positions(self, et: float):
        """Calculate MAVEN spacecraft position, Mars solar longitude, and the
        subsolar position for a given ephemeris time.

        Parameters
        ----------
        et
            Input epoch in ephemeris seconds past J2000.

        Returns
        -------
        et : array
            The input ephemeris times. Just givin'em back.
        subsc_lat : array
            Sub-spacecraft latitudes in degrees.
        subsc_lon : array
            Sub-spacecraft longitudes in degrees.
        sc_alt_km : array
            Sub-spacecraft altitudes in kilometers.
        ls : array
            Mars solar longitudes in degrees.
        subsolar_lat : array
            Sub-solar latitudes in degrees.
        subsolar_lon : array
            Sub-solar longitudes in degrees.
        mars_sun_km: array

        """
        spoint, trgepc, srfvec = \
            spice.subpnt('Intercept: ellipsoid', self.__target, et, 'IAU_MARS',
                         self.__abcorr, self.__observer)
        _, _, srvec_sun = \
            spice.subpnt('Intercept: ellipsoid', self.__target, et, 'IAU_MARS',
                         self.__abcorr, 'SUN')
        rpoint, colatpoint, lonpoint = spice.recsph(spoint)
        if lonpoint > np.pi:
            lonpoint -= 2 * np.pi
        subsc_lat = 90 - np.degrees(colatpoint)
        subsc_lon = np.degrees(lonpoint)
        sc_alt_km = np.sqrt(np.sum(srfvec**2))
        mars_sun_km = np.sqrt(np.sum(srvec_sun**2))

        # calculate subsolar position
        sspoint, strgepc, ssrfvec = \
            spice.subslr('Intercept: ellipsoid', self.__target, et, 'IAU_MARS',
                         self.__abcorr, self.__observer)
        srpoint, scolatpoint, slonpoint = spice.recsph(sspoint)
        if slonpoint > np.pi:
            slonpoint -= 2 * np.pi
        subsolar_lat = 90 - np.degrees(scolatpoint)
        subsolar_lon = np.degrees(slonpoint)

        ls = np.degrees(spice.lspcn(self.__target, et, self.__abcorr))

        return et, subsc_lat, subsc_lon, sc_alt_km, ls, subsolar_lat, \
            subsolar_lon, mars_sun_km
Пример #3
0
def spice_positions(et):
    """
    Calculates MAVEN spacecraft position, Mars solar longitude, and subsolar position for a given ephemeris time.

    Parameters
    ----------
    et : float
        Input epoch in ephemeris seconds past J2000.

    Returns
    -------
    et : array
        The input ephemeris times. Just givin'em back.
    subsc_lat : array
        Sub-spacecraft latitudes in degrees.
    subsc_lon : array
        Sub-spacecraft longitudes in degrees.
    sc_alt_km : array
        Sub-spacecraft altitudes in kilometers.
    ls : array
        Mars solar longitudes in degrees.
    subsolar_lat : array
        Sub-solar latitudes in degrees.
    subsolar_lon : array
        Sub-solar longitudes in degrees.
    """

    # do a bunch of SPICE stuff only Justin understands...
    target = 'Mars'
    abcorr = 'LT+S'
    observer = 'MAVEN'
    spoint, trgepc, srfvec = spice.subpnt('Intercept: ellipsoid', target, et, 'IAU_MARS', abcorr, observer)
    rpoint, colatpoint, lonpoint = spice.recsph(spoint)
    if lonpoint > np.pi:
        lonpoint -= 2 * np.pi
    subsc_lat = 90 - np.degrees(colatpoint)
    subsc_lon = np.degrees(lonpoint)
    sc_alt_km = np.sqrt(np.sum(srfvec ** 2))

    # calculate subsolar position
    sspoint, strgepc, ssrfvec = spice.subslr('Intercept: ellipsoid', target, et, 'IAU_MARS', abcorr, observer)
    srpoint, scolatpoint, slonpoint = spice.recsph(sspoint)
    if slonpoint > np.pi:
        slonpoint -= 2 * np.pi
    subsolar_lat = 90 - np.degrees(scolatpoint)
    subsolar_lon = np.degrees(slonpoint)

    # calculate solar longitude
    ls = spice.lspcn(target, et, abcorr)
    ls = np.degrees(ls)

    # return the position information
    return et, subsc_lat, subsc_lon, sc_alt_km, ls, subsolar_lat, subsolar_lon
Пример #4
0
def writeTimeLsToFile():
    """make list of time vs ls"""
    SPICE_TARGET = "MARS"
    SPICE_ABERRATION_CORRECTION = "None"
    
    DATETIME_FORMAT = "%d/%m/%Y %H:%M"
    
    
    from datetime import datetime, timedelta
    
    linesToWrite = []
    datetimeStart = datetime(2018, 3, 1, 0, 0, 0, 0)
    for hoursToAdd in range(0, 24*31*12*3, 6): #3 years
        newDatetime = (datetimeStart + timedelta(hours=hoursToAdd)).strftime(DATETIME_FORMAT)
        ls = sp.lspcn(SPICE_TARGET, sp.utc2et(str(datetimeStart + timedelta(hours=hoursToAdd))), SPICE_ABERRATION_CORRECTION) * sp.dpr()
        linesToWrite.append("%s\t%0.1f" %(newDatetime, ls))
    
    writeOutput("Time_vs_Ls.txt", linesToWrite)
Пример #5
0
    def ls(self, utc, body='Saturn', abcorr='CN+S'):
        """Planetocentric longitude of the sun, as seen from a specified body.

        Related orbital seasonal parameter:

            - Vernal equinox:   Ls =   0º
            - Summer solstice:  Ls =  90º
            - Autumnal equinox: Ls = 180º
            - Winter solstice:  Ls = 270º

        Warning
        -------
        For the moons the solar longitude must be computed
        for the parent body (ie. Saturn for Titan) otherwise
        the output value does not provide the correct orbital
        seasomal location. Generaly this approximation is
        within a fraction of moon's orbit.


        Parameters
        ----------
        utc: str
            Input time in UTC format.
        body: str, optional
            Name of the central body.
        abcorr: str, optional
            Aberration correction.

        Returns
        -------
        float
            Solar longitude (in degrees).

        """
        et = spice.str2et(utc)
        return np.degrees(spice.lspcn(body, et, abcorr))
Пример #6
0
 def f(_t):
     return spiceypy.lspcn(body, _t, correction)
Пример #7
0
def lsubs(et):

    return sp.lspcn("MARS", et, abcorr) * sp.dpr()
Пример #8
0
 def l_s(self):
     return np.rad2deg(spice.lspcn(self.target, self.et, self.corr))
Пример #9
0
 def _get_l_s(self):
     return np.rad2deg(spice.lspcn(self.target, self.et, self.corr))