@@ -52,9 +52,9 @@ def fraction_illuminated(ephemeris, body, t):
5252def find_discrete (start_time , end_time , f , epsilon = EPSILON , num = 12 ):
5353 """Find the times when a function changes value.
5454
55- Searches between ``start_time`` and ``end_time``, which should both
56- be :class:`~skyfield.timelib.Time` objects, for the occasions where
57- the function ``f`` changes from one value to another. Use this to
55+ Search between ``start_time`` and ``end_time``, which should both be
56+ :class:`~skyfield.timelib.Time` objects, for the occasions where the
57+ function ``f`` changes from one value to another. Use this to
5858 search for events like sunrise or moon phases.
5959
6060 A tuple of two arrays is returned. The first array gives the times
@@ -82,7 +82,10 @@ def find_discrete(start_time, end_time, f, epsilon=EPSILON, num=12):
8282 periods = 1.0
8383
8484 jd = linspace (jd0 , jd1 , int (periods * num ))
85+ return _find_discrete (ts , jd , f , epsilon , num )
8586
87+ def _find_discrete (ts , jd , f , epsilon , num ):
88+ """Algorithm core, for callers that already have a `jd` vector."""
8689 end_mask = linspace (0.0 , 1.0 , num )
8790 start_mask = end_mask [::- 1 ]
8891 o = multiply .outer
@@ -268,6 +271,14 @@ def is_sun_up_at(t):
268271 is_sun_up_at .rough_period = 0.5 # twice a day
269272 return is_sun_up_at
270273
274+ TWILIGHTS = {
275+ 0 : 'Night' ,
276+ 1 : 'Astronomical twilight' ,
277+ 2 : 'Nautical twilight' ,
278+ 3 : 'Civil twilight' ,
279+ 4 : 'Day' ,
280+ }
281+
271282def dark_twilight_day (ephemeris , topos ):
272283 """Build a function of time returning whether it is dark, twilight, or day.
273284
0 commit comments