question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Topos errors when calculating visible EarthSatellite

See original GitHub issue

I feel like this is going to be my fault but here we go. I’m working on a python 2.7.x codebase and found AttributeError: 'Topos' object has no attribute 'position' when trying to calculate visible EarthSatellites. I’ve tested again with a clean Python 3.7 environment with the same result though =\

The use case is mapping Iridium NEXT orbits against known positions and times.

If anyone has any pointers or can see where I have flubbed that would be awesome!

Reproduction

Platform: Windows 10 python-3.7.1 jplephem-2.9 numpy-1.16.1 sgp4-1.4 skyfield-1.10

Code

from skyfield.api import Topos, load

ts = load.timescale()
t = ts.utc(2019, 2, 17, 11, 18, 7)
stations_url = 'http://celestrak.com/NORAD/elements/iridium-NEXT.txt'
satellites = load.tle(stations_url)
print(satellites['IRIDIUM 161'])
sat_pos_geocentric = satellites['IRIDIUM 161'].at(t)
print(sat_pos_geocentric.position.km)
subpoint = sat_pos_geocentric.subpoint()
print('Latitude:', subpoint.latitude)
print('Longitude:', subpoint.longitude)
print('Elevation (m):', int(subpoint.elevation.m))
bluffton = Topos('40.8939 N', '83.8917 W')
difference = sat_pos_geocentric - bluffton
print(difference)

Output

$ python skyfield-test.py
EarthSatellite 'IRIDIUM 161' number=43478 epoch=2019-02-23T06:25:35Z
[ 3062.67696436 -4537.7038142   4554.02354446]
Latitude: 39deg 59' 04.2"
Longitude: -12deg 29' 18.0"
Elevation (m): 751740
Traceback (most recent call last):
  File "skyfield-test.py", line 15, in <module>
    difference = sat_pos_geocentric - bluffton
  File "C:\Users\Kahn.non-free\.virtualenvs\inreach-kml-util-4s0grwMn\lib\site-packages\skyfield\positionlib.py", line 63, in __sub__
    p = self.position.au - body.position.au
AttributeError: 'Topos' object has no attribute 'position'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Kahncommented, Feb 25, 2019

Yes, sat is just a string. The debugging that put me on the right track was printing the iterated output.

for sat in satellites:
    print(sat) # Gets a satellite name string like "IRIDIUM 123"
    print(satellites[sat]) # Gets an EarthSatellite by name
1reaction
brandon-rhodescommented, Feb 25, 2019

What do you mean by “you don’t actually have an EarthSatellite”? Is sat a different sort of object?

In any case, I’m glad you figured everything out and got a working script! Thanks for posting the working code, it may help future readers who find this discussion through a web search.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Satellite Imagery
Visible satellite imagery is a depiction of the amount of solar radiation reflected back from the earth and clouds (albedo). Shades of light...
Read more >
Chapter 2 Cloud type identification by satellites
The clouds as seen from the satellite may be classified into high, middle and low level clouds. We should take note that of...
Read more >
Show visible satellite passes · Issue #327 · skyfielders/python ...
One issue I have with this method is to find the visible pass requires first calculating the current pass and then determine if...
Read more >
NASA Visible Earth
No information is available for this page.
Read more >
Newcomers Earth Observation Guide
Most EO satellites are in specific low Earth polar orbits called "Sun-Synchronous Orbits (SSO)", whose altitude and inclination are precisely calculated so that ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found