Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions pycraf/satellite/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down