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.

Cannot use skyfield.api.load.tle .items() function

See original GitHub issue

I came across a slightly odd behaviour when trying to filter the dict of objects loaded using skyfield.api.load.tle.

Let’s say, I want to load the list of active satellites from Celestrak and among them filter for a bunch of Cubesats (let’s say AEROCUBE), I run in trouble:

import skyfield.api as skyapi
loader = skyapi.Loader(r"~/.skyfield-data")
active_satellites_url = "http://celestrak.com/NORAD/elements/active.txt"
satellites = loader.tle(active_satellites_url)

k, v = satellites.items()

results in

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-ec9f8531e0e7> in <module>
----> 1 k, v = satellites.items()

ValueError: too many values to unpack (expected 2)

But it’s listed as a dict and the .keys() and .values() functions work as expected. And .items() does in fact return a dict_items object as expected:

>>> type(satellites)
dict
>>> satellites.keys()
dict_keys([900, 'CALSPHERE 1', 902, 'CALSPHERE 2', 1361, 'LCS 1', 1512, 'TEMPSAT 1', 1520, 'CALSPHERE 4A', 2826, 'OPS 5712 (P/L 160)', 'OPS 5712', 'P/L 160', 2872, 'SURCAL 159', ...
>>> satellites.values()
dict_values([<EarthSatellite 'CALSPHERE 1' number=900 epoch=2020-02-25T19:20:52Z>, <EarthSatellite 'CALSPHERE 1' number=900 epoch=2020-02-25T19:20:52Z>, <EarthSatellite 'CALSPHERE 2' number=902 epoch=2020-02-25T11:56:49Z>, ...
>>> satellites.items()
dict_items([(900, <EarthSatellite 'CALSPHERE 1' number=900 epoch=2020-02-25T19:20:52Z>), ('CALSPHERE 1', <EarthSatellite 'CALSPHERE 1' number=900 epoch=2020-02-25T19:20:52Z>), (902, <EarthSatellite 'CALSPHERE 2' number=902 epoch=2020-02-25T11:56:49Z>), ('CALSPHERE 2', <EarthSatellite 'CALSPHERE 2' number=902 epoch=2020-02-25T11:56:49Z>), ...

If I create a test dict, it works well:

test = {"a": (1,2,3), "b": (2,3,4)}
k, v = test.items()

I am using

  • Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
  • Skyfield 1.17

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
cweickhmanncommented, Mar 27, 2020

Thank you very much! 😃

0reactions
brandon-rhodescommented, Mar 24, 2020

There, that should help! The improved, simplified routine should be available the next time I release Skyfield.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference — Opening Files — Skyfield documentation
Given a URL or local path to an ASCII text file, this loads a series of TLE “Two-Line Element” sets and returns a...
Read more >
How to use the skyfield.api.load function in skyfield - Snyk
To help you get started, we've selected a few skyfield.api.load examples, based on popular ways it is used in public projects.
Read more >
Skyfield, how to use https:// instead of ftp
I found that I had to use the server name urs.earthdata.nasa.gov in the ... e.g. https://cddis.nasa.gov/archive/products/iers/deltat.data.
Read more >
solution or alternative to serialize C++ objects for a satellite ...
I know that they are C++ objects so they cant be serialized, ... from skyfield.api import load, wgs84, EarthSatellite import numpy as np ......
Read more >
Satpy Documentation
value is passed directly to the get_satpos() function. ... tle: Two-Line Element (TLE) set used to compute the satellite's orbit.
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