~brandon-rhodes/pyephem/python-3

« back to all changes in this revision

Viewing changes to src/ephem/__init__.py

  • Committer: Brandon Craig Rhodes
  • Date: 2009-04-30 19:43:18 UTC
  • Revision ID: brandon@rhodesmill.org-20090430194318-r6b7yt25jspcyjk8
Merged changes 421 and 422 from the main "pyephem" branch, with one or
two tweaks to make them compatible with Python 3.0.  This brings over
the new next_pass() method for finding when a satellite next appears.

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
    def _compute_transit(self, body, start, sign, offset):
257
257
        """Internal function used to compute transits."""
258
258
 
 
259
        if isinstance(body, EarthSatellite):
 
260
            raise TypeError(
 
261
                'the next and previous transit methods do not'
 
262
                ' support earth satellites because of their speed;'
 
263
                ' please use the higher-resolution next_pass() method'
 
264
                )
 
265
 
259
266
        def f(d):
260
267
            self.date = d
261
268
            body.compute(self)
315
322
    def _riset_helper(self, body, start, rising, previous):
316
323
        """Internal function for finding risings and settings."""
317
324
 
 
325
        if isinstance(body, EarthSatellite):
 
326
            raise TypeError(
 
327
                'the rising and settings methods do not'
 
328
                ' support earth satellites because of their speed;'
 
329
                ' please use the higher-resolution next_pass() method'
 
330
                )
 
331
 
318
332
        def visit_transit():
319
333
            d = (previous and self.previous_transit(body)
320
334
                 or self.next_transit(body)) # if-then
394
408
        """Move to the given body's next setting, returning the date."""
395
409
        return self._riset_helper(body, start, False, False)
396
410
 
 
411
    def next_pass(self, body):
 
412
        """Return the next rising, culmination, and setting of a satellite."""
 
413
 
 
414
        if not isinstance(body, EarthSatellite):
 
415
            raise TypeError(
 
416
                'the next_pass() method is only for use with'
 
417
                ' EarthSatellite objects because of their high speed'
 
418
                )
 
419
 
 
420
        return _libastro._next_pass(self, body)
 
421
 
397
422
# Time conversion.
398
423
 
399
424
def localtime(date):