def test_sidereal(self): N = sidereal_time_greenwich(cal_to_jd(2004, 1, 1)) testval = (6*3600 + 39*60 + 58.60298794778828)/43200*math.pi np.testing.assert_array_almost_equal(N, testval, decimal=4) N = sidereal_time_greenwich(cal_to_jd(2004, 1, [1, 2])) testval1 = (6*3600 + 43*60 + 55.15832794114431)/43200*math.pi np.testing.assert_array_almost_equal(N, [testval, testval1], decimal=4)
def get_planets(): planet_names = ('Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune') d = datetime.utcnow() jd = cal_to_jde(d.year, d.month, d.day, d.hour, d.minute, d.second) dt = jd + deltaT_seconds(jd) / seconds_per_day st = sidereal_time_greenwich(jd) deltaPsi = 0.0 epsilon = obliquity(dt) delta = days_per_second planets = [] # this is in ecliptic coordinates lon = sun.apparent_longitude_low(dt, sun.longitude_radius_low(dt)[0]) ra, dec = ecl_to_equ(lon, 0.0, epsilon) planets.append(equ_to_geo(ra, dec, st)) lon, lat = elp2000.dimension3(dt)[:2] ra, dec = ecl_to_equ(lon, lat, epsilon) planets.append(equ_to_geo(ra, dec, st)) for planet in planet_names: ra, dec = geocentric_planet(dt, planet, deltaPsi, epsilon, days_per_second) planets.append(equ_to_geo(ra, dec, st)) return planets
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"
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")
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"
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")