diff --git a/pycraf/satellite/satellite.py b/pycraf/satellite/satellite.py index 68bdb0838..1fe59fd43 100644 --- a/pycraf/satellite/satellite.py +++ b/pycraf/satellite/satellite.py @@ -44,13 +44,24 @@ def get_sat(tle_string): try: import sgp4 - from sgp4.earth_gravity import wgs72 - from sgp4.io import twoline2rv, Satellite except ImportError: raise ImportError( 'The "sgp4" package is necessary to use this function.' ) + try: + from sgp4.io import Satellite + except ImportError: + try: + from sgp4.model import Satellite + except ImportError: + raise ImportError( + "Can't import sgp4 Satellite object." + ) + + from sgp4.earth_gravity import wgs72 + from sgp4.io import twoline2rv + tle_string_list = tle_string.split('\n') satname = tle_string_list[0] if satname[0:2] == '0 ': # remove leading 0 if present @@ -267,15 +278,23 @@ def azel_from_sat(self, satellite_or_tle, obstime): assert isinstance(obstime, time.Time), ( 'obstime must be an astropy.time.Time object!' ) - try: import sgp4 - from sgp4.io import Satellite except ImportError: raise ImportError( 'The "sgp4" package is necessary to use this Class.' ) + try: + from sgp4.io import Satellite + except ImportError: + try: + from sgp4.model import Satellite + except ImportError: + raise ImportError( + "Can't import sgp4 Satellite object." + ) + if not isinstance(satellite_or_tle, Satellite): _, satellite = get_sat(satellite_or_tle) else: