@@ -220,7 +220,7 @@ def __init__(self, line1, line2, name=None, observer=None, skip_tle_check=False)
220220 Name of the target, used for plotting and representing the target
221221 as a string
222222
223- observer : `~astropy.coordinates.EarthLocation`, `~ astroplan.Observer`, optional
223+ observer : `~astroplan.Observer`, optional
224224 The location of observer.
225225 If `None`, the observer is assumed to be at sea level at the equator.
226226
@@ -237,13 +237,16 @@ def __init__(self, line1, line2, name=None, observer=None, skip_tle_check=False)
237237 self .satellite = EarthSatellite (line1 , line2 , name , load .timescale ())
238238
239239 if observer is None :
240- self .observer = wgs84 .latlon (0 , 0 , 0 )
240+ # Prevent circular import and usually not used
241+ from .observer import Observer
242+ self .observer = Observer (latitude = 0 * u .deg , longitude = 0 * u .deg , elevation = 0 * u .m )
241243 else :
242- observer = getattr (observer , 'location' , observer )
243- longitude , latitude , height = observer .to_geodetic ()
244- self .observer = wgs84 .latlon (latitude .to (u .deg ).value ,
245- longitude .to (u .deg ).value ,
246- height .to (u .m ).value )
244+ self .observer = observer
245+
246+ longitude , latitude , height = self .observer .location .to_geodetic ()
247+ self .geographic_position = wgs84 .latlon (latitude .to (u .deg ).value ,
248+ longitude .to (u .deg ).value ,
249+ height .to (u .m ).value )
247250
248251 @classmethod
249252 def from_string (cls , tle_string , name = None , * args , ** kwargs ):
@@ -300,7 +303,7 @@ def _compute_topocentric(self, time=None):
300303 ts = load .timescale ()
301304 t = ts .from_astropy (time )
302305
303- topocentric = (self .satellite - self .observer ).at (t )
306+ topocentric = (self .satellite - self .geographic_position ).at (t )
304307
305308 # Check for invalid TLE data. A non-None usually message means the computation went beyond
306309 # the physically sensible point. Details:
@@ -333,7 +336,13 @@ def coord(self, time=None):
333336 topocentric = self ._compute_topocentric (time )
334337 ra , dec , distance = topocentric .radec ()
335338 # No distance, in SkyCoord, distance is from frame origin, but here, it's from observer.
336- return SkyCoord (ra .hours * u .hourangle , dec .degrees * u .deg , obstime = time , frame = 'icrs' )
339+ return SkyCoord (
340+ ra .hours * u .hourangle ,
341+ dec .degrees * u .deg ,
342+ obstime = time ,
343+ frame = 'icrs' ,
344+ location = self .observer .location ,
345+ )
337346
338347 def altaz (self , time = None ):
339348 """
@@ -350,15 +359,28 @@ def altaz(self, time=None):
350359 SkyCoord object representing the target's altitude and azimuth at the specified time(s)
351360 """
352361 topocentric = self ._compute_topocentric (time )
353- alt , az , distance = topocentric .altaz ()
354-
355- earth_location = EarthLocation (lat = self .observer .latitude .degrees * u .deg ,
356- lon = self .observer .longitude .degrees * u .deg ,
357- height = self .observer .elevation .m * u .m )
358362
359- altaz = AltAz (alt = alt .degrees * u .deg , az = az .degrees * u .deg ,
360- obstime = time , location = earth_location )
361- return SkyCoord (altaz )
363+ temperature_C = None
364+ pressure_mbar = None
365+ if self .observer .temperature is not None :
366+ temperature_C = self .observer .temperature .to_value (u .deg_C )
367+ if self .observer .pressure is not None :
368+ pressure_mbar = self .observer .pressure .to_value (u .mbar )
369+
370+ alt , az , distance = topocentric .altaz (
371+ temperature_C = temperature_C ,
372+ pressure_mbar = pressure_mbar ,
373+ )
374+
375+ # 'relative_humidity' and 'obswl' were not used in coordinate calculation
376+ altaz_frame = AltAz (
377+ location = self .observer .location ,
378+ obstime = time ,
379+ pressure = self .observer .pressure ,
380+ temperature = self .observer .temperature ,
381+ )
382+
383+ return SkyCoord (alt = alt .degrees * u .deg , az = az .degrees * u .deg , frame = altaz_frame )
362384
363385 def __repr__ (self ):
364386 return f'<{ self .__class__ .__name__ } "{ self .name } ">'
0 commit comments