Esempio n. 1
0
def rise(jd, raList, decList, h0, delta):
    """Return the Julian Day of the rise time of an object.
    
    Parameters:
        jd      : Julian Day number of the day in question, at 0 hr UT
        raList  : a sequence of three right accension values, in radians,
            for (jd-1, jd, jd+1)
        decList : a sequence of three right declination values, in radians,
            for (jd-1, jd, jd+1)
        h0      : the standard altitude in radians
        delta   : desired accuracy in days. Times less than one minute are
            infeasible for rise times because of atmospheric refraction.
            
    Returns:
        Julian Day of the rise time
    
    """
    longitude = astronomia.globals.longitude
    latitude = astronomia.globals.latitude
    THETA0 = sidereal_time_greenwich(jd)
    deltaT_days = deltaT_seconds(jd) / seconds_per_day

    cosH0 = (sin(h0) - sin(latitude) * sin(decList[1])) / (cos(latitude) * cos(decList[1]))
    #
    # future: return some indicator when the object is circumpolar or always
    # below the horizon.
    #
    if cosH0 < -1.0: # circumpolar
        return None
    if cosH0 > 1.0:  # never rises
        return None

    H0 = acos(cosH0)    
    m0 = (raList[1] + longitude - THETA0) / pi2
    m = m0 - H0 / pi2  # this is the only difference between rise() and set()
    if m < 0:
        m += 1
    elif m > 1:
        m -= 1
    if not 0 <= m <= 1:
        raise Error, "m is out of range = " + str(m)
    for bailout in range(20):
        m0 = m
        theta0 = modpi2(THETA0 + _k1 * m)
        n = m + deltaT_days
        if not -1 < n < 1:
            return None # Bug: this is where we drop some events
        ra = interpolate_angle3(n, raList)
        dec = interpolate3(n, decList)
        H = theta0 - longitude - ra
#        if H > pi:
#            H = H - pi2
        H = diff_angle(0.0, H)
        A, h = equ_to_horiz(H, dec)
        dm = (h - h0) / (pi2 * cos(dec) * cos(latitude) * sin(H))
        m += dm
        if abs(m - m0) < delta:
            return jd + m

    raise Error, "bailout"
Esempio n. 2
0
def _riseset(jd, raList, decList, h0, delta, mode,
             longitude=astronomia.globals.longitude,
             latitude=astronomia.globals.latitude):
    # Private function since rise/set so similar

    THETA0 = sidereal_time_greenwich(jd)
    deltaT_days = deltaT_seconds(jd) / seconds_per_day

    cosH0 = (np.sin(h0) - np.sin(latitude)*np.sin(decList[1])) / (
        np.cos(latitude)*np.cos(decList[1]))
    #
    # future: return some indicator when the object is circumpolar or always
    # below the horizon.
    #
    if cosH0 < -1.0:  # circumpolar
        return None
    if cosH0 > 1.0:  # never rises
        return None

    H0 = np.arccos(cosH0)
    m0 = (raList[1] + longitude - THETA0) / pi2
    if mode == 'rise':
        m = m0 - H0 / pi2  # the only difference between rise() and settime()
    elif mode == 'set':
        m = m0 + H0 / pi2  # the only difference between rise() and settime()
    if m < 0:
        m += 1
    elif m > 1:
        m -= 1
    if not 0 <= m <= 1:
        raise Error("m is out of range = " + str(m))
    for bailout in range(20):
        m0 = m
        theta0 = modpi2(THETA0 + _k1 * m)
        n = m + deltaT_days
        if not -1 < n < 1:
            return None  # Bug: this is where we drop some events
        ra = interpolate_angle3(n, raList)
        dec = interpolate3(n, decList)
        H = theta0 - longitude - ra
#        if H > pi:
#            H = H - pi2
        H = diff_angle(0.0, H)
        A, h = equ_to_horiz(H, dec)
        dm = (h - h0) / (pi2 * np.cos(dec) * np.cos(latitude) * np.sin(H))
        m += dm
        if abs(m - m0) < delta:
            return jd + m

    raise Error("bailout")
Esempio n. 3
0
def transit(jd, raList, delta):
    """Return the Julian Day of the transit time of an object.
    
    Parameters:
        jd      : Julian Day number of the day in question, at 0 hr UT
        raList  : a sequence of three right accension values, in radians,
            for (jd-1, jd, jd+1)
        delta   : desired accuracy in days. 
            
    Returns:
        Julian Day of the transit time
    
    """
    #
    # future: report both upper and lower culmination, and transits of objects below
    # the horizon
    #
    longitude = astronomia.globals.longitude
    THETA0 = sidereal_time_greenwich(jd)
    deltaT_days = deltaT_seconds(jd) / seconds_per_day

    m = (raList[1] + longitude - THETA0) / pi2
    if m < 0:
        m += 1
    elif m > 1:
        m -= 1
    if not 0 <= m <= 1:
        raise Error, "m is out of range = " + str(m)
    for bailout in range(20):
        m0 = m
        theta0 = modpi2(THETA0 + _k1 * m)
        n = m + deltaT_days
        if not -1 < n < 1:
            return None  # Bug: this is where we drop some events
        ra = interpolate_angle3(n, raList)
        H = theta0 - longitude - ra
        #        if H > pi:
        #            H = H - pi2
        H = diff_angle(0.0, H)
        dm = -H / pi2
        m += dm
        if abs(m - m0) < delta:
            return jd + m

    raise Error, "bailout"
Esempio n. 4
0
def transit(jd, raList, delta):
    """Return the Julian Day of the transit time of an object.

    Arguments:
      - `jd`      : Julian Day number of the day in question, at 0 hr UT
      - `raList`  : a sequence of three right accension values, in radians, for
        (jd-1, jd, jd+1)
      - `delta`   : desired accuracy in days.

    Returns:
      - Julian Day of the transit time

    """
    #
    # future: report both upper and lower culmination, and transits of objects
    # below the horizon
    #
    longitude = astronomia.globals.longitude
    THETA0 = sidereal_time_greenwich(jd)
    deltaT_days = deltaT_seconds(jd) / seconds_per_day

    m = (raList[1] + longitude - THETA0) / pi2
    if m < 0:
        m += 1
    elif m > 1:
        m -= 1
    if not 0 <= m <= 1:
        raise Error("m is out of range = " + str(m))
    for bailout in range(20):
        m0 = m
        theta0 = modpi2(THETA0 + _k1 * m)
        n = m + deltaT_days
        if not -1 < n < 1:
            return None  # Bug: this is where we drop some events
        ra = interpolate_angle3(n, raList)
        H = theta0 - longitude - ra
#        if H > pi:
#            H = H - pi2
        H = diff_angle(0.0, H)
        dm = -H/pi2
        m += dm
        if abs(m - m0) < delta:
            return jd + m

    raise Error("bailout")
Esempio n. 5
0
def rise(jd, raList, decList, h0, delta):
    """Return the Julian Day of the rise time of an object.
    
    Parameters:
        jd      : Julian Day number of the day in question, at 0 hr UT
        raList  : a sequence of three right accension values, in radians,
            for (jd-1, jd, jd+1)
        decList : a sequence of three right declination values, in radians,
            for (jd-1, jd, jd+1)
        h0      : the standard altitude in radians
        delta   : desired accuracy in days. Times less than one minute are
            infeasible for rise times because of atmospheric refraction.
            
    Returns:
        Julian Day of the rise time
    
    """
    longitude = astronomia.globals.longitude
    latitude = astronomia.globals.latitude
    THETA0 = sidereal_time_greenwich(jd)
    deltaT_days = deltaT_seconds(jd) / seconds_per_day

    cosH0 = (sin(h0) - sin(latitude) * sin(decList[1])) / (cos(latitude) *
                                                           cos(decList[1]))
    #
    # future: return some indicator when the object is circumpolar or always
    # below the horizon.
    #
    if cosH0 < -1.0:  # circumpolar
        return None
    if cosH0 > 1.0:  # never rises
        return None

    H0 = acos(cosH0)
    m0 = (raList[1] + longitude - THETA0) / pi2
    m = m0 - H0 / pi2  # this is the only difference between rise() and set()
    if m < 0:
        m += 1
    elif m > 1:
        m -= 1
    if not 0 <= m <= 1:
        raise Error, "m is out of range = " + str(m)
    for bailout in range(20):
        m0 = m
        theta0 = modpi2(THETA0 + _k1 * m)
        n = m + deltaT_days
        if not -1 < n < 1:
            return None  # Bug: this is where we drop some events
        ra = interpolate_angle3(n, raList)
        dec = interpolate3(n, decList)
        H = theta0 - longitude - ra
        #        if H > pi:
        #            H = H - pi2
        H = diff_angle(0.0, H)
        A, h = equ_to_horiz(H, dec)
        dm = (h - h0) / (pi2 * cos(dec) * cos(latitude) * sin(H))
        m += dm
        if abs(m - m0) < delta:
            return jd + m

    raise Error, "bailout"
Esempio n. 6
0
    def test_interpolate_angle3(self):
        y = interpolate_angle3(0, (359, 0, 1))

        self.assertAlmostEqual(y, 0.0, places=6)