Can pyephem look more than 360 degrees past a date -
i want code output date of every 30 degrees of planets movement until date of today, reason stops @ 360 degrees. why code stopping here , not going through 390 degrees, 420, 450......etc.
from ephem import venus, date, degrees, newton import datetime v = venus() start_date = '2014/2/2 00:00' v.compute(start_date) ls0 = v.hlon print "venus",start_date, ls0 print "" arc = 0 while true: d = start_date today = datetime.date.today() arc = arc + degrees('30:00:00') if d == today: break def ls(date): v.compute(date) return degrees(v.hlon - ls0).norm def thirty_degrees(date): return ls(date) - degrees(arc) def find_thirty_degrees(start_date): start_date = date(start_date) y0 = ls(start_date) y1 = ls(start_date + 1) rate = y1 - y0 angle_to_go = degrees(degrees(arc) - y0).norm closer_date = start_date + angle_to_go / rate d = newton(thirty_degrees, closer_date, closer_date + 1) return date(d) d = find_thirty_degrees(start_date) print d, ls(d)
results are:
venus 2014/2/2 00:00 146:05:57.6
2014/2/20 11:27:19 30:00:00.0
2014/3/11 01:17:41 60:00:00.0
2014/3/29 18:50:49 90:00:00.0
2014/4/17 15:55:27 120:00:00.0
2014/5/6 15:00:08 150:00:00.0
2014/5/25 14:10:16 179:59:59.9
2014/6/13 12:02:34 210:00:00.0
2014/7/2 07:57:18 240:00:00.0
2014/7/21 01:36:05 270:00:00.0
2014/8/8 16:44:49 300:00:00.0
2014/8/27 05:27:54 330:00:00.0
2014/9/14 16:38:35 359:59:59.5
the reason there 360° in circle, @ point @ 0° point started journey around sky. have start @ 0 , search whole new set of moments when venus @ 30°, 60°, , forth.
note can difficult routine newton()
operate around point 359° switches 0° because transition abrupt. can helpful, when trying detect moment when 0°, instead give newton()
function returns value want + 180°, , ask newton()
find 180° crossing.
Comments
Post a Comment