2

I have a directionnal antenna on Earth and I would like to know where it points to in ra,dec coordinates. I'd like to use the new skyfield library for that, as pyephem is not developped anymore.

It is easy to compute my topos position on Earth:

planets = load('de421.bsp')
earth = planets['earth']
paris = earth + Topos('48.839059 N', '2.310147 E')

But then I can't figure out how to indicate an az,alt couple from this point. I've seen the from_altaz method but I can't manage to make it work.

If I try it from a topos:

antenna = paris.from_altaz(alt_degrees=41.1,az_degrees=180)
Traceback (most recent call last):
  File "./compute.py", line 13, in <module>
    antenna = paris.from_altaz(alt_degrees=41.1,az_degrees=180)
AttributeError: 'VectorSum' object has no attribute 'from_altaz'

How can I manage to do that?

rfkortekaas
  • 6,049
  • 2
  • 27
  • 34
nixx
  • 31
  • 3

1 Answers1

3

The from_altaz function you try to use is from the position_lib. As this is for both fixed and moving objects (which differ through time) it's a function of time. So you need to specify the time to the observer with the .at function.

from skyfield import api

ts = api.load.timescale()
planets = api.load('de421.bsp')
earth = planets['earth']

antenna = earth + api.Topos('48.839059 N', '2.310147 E')

t = ts.now()
direction = antenna.at(t).from_altaz(alt_degrees=41.1, az_degrees=180)

ra, dec, distance = direction.radec()
print(ra)
print(dec)

This results in:

04h 43m 26.56s
-00deg 05' 39.5

rfkortekaas
  • 6,049
  • 2
  • 27
  • 34