d = longitude_difference(t)
while d > 0:
    t += ephem.minute
sat.compute(t)
d = longitude_difference(t)
while d < 0:
    t += ephem.minute
sat.compute(t)
d = longitude_difference(t)
tn = ephem.newton(longitude_difference, t - ephem.minute, t)
print('When did ISS cross this longitude?', target_long)
print('At this specific date and time:', ephem.date(tn))
sat.compute(tn)
print('To double-check, at that time, sublong =', sat.sublong)
Using pyephem to calculate when a satellite crosses a Longitude