skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.39k stars 209 forks source link

Document new JSON and CSV formats for satellite data #763

Closed CelesTrak closed 1 month ago

CelesTrak commented 2 years ago

Now that CelesTrak is a non-profit, we have been redirecting all traffic going to other CelesTrak domains (e.g., .com, .net, .space) to celestrak.org (not www.celestrak.org). If your software does not handle the standard HTTP 301 response (Moved Permanently), you should change any references to other CelesTrak domains (typically celestrak.com or www.celestrak.com) to celestrak.org. While using HTTPS is not required, it is highly recommended, to prevent potential future issues.

Also, please note that CelesTrak does not update any data more often than every 2 hours. Processes that check hundreds or thousands of times each day for a specific file or files use limited resources needed to support about a quarter million unique users we see on CelesTrak every day. For orbital data, the 18 SDS data is only updated ~3 times each day (and not all data gets updated each time). The same is true for CelesTrak's SupGP orbital data. Please consider limiting checks to 3-4 times a day to help us all out. Adding checks to limit repeated attempts on an unexpected result (e.g., the HTTP 301 response) can also help us make the most of our resources.

CelesTrak also now supports alternative formats to the TLE format, including CSV and JSON. These are not only easier and more efficient to parse than TLE data, but they also support larger NORAD catalog numbers (and 4-digit years). The current public catalog will run out of 5-digit catalog numbers at 70000 (not 100000), since 70000-99999 are used as 'working space' by 18 SDS. We have already used 3,113 catalog numbers (as of 2022 Jul 15) since going over 50000 on 2021 Dec 13 and increases in things like Starlink launches are likely to accelerate. If you would like more information on these formats, please see our article, "A New Way to Obtain GP Data (aka TLEs)" at https://celestrak.org/NORAD/documentation/gp-data-formats.php.

Our Best,

CelesTrak

brandon-rhodes commented 1 year ago

Thank you for letting us know about the domain name change! Our documentation included several links to celestrak.com and now users will be able to visit those links without incurring an extra redirect.

And we do plan to document how more modern satellite formats can be used with Skyfield; in fact, I'll re-open this issue to remind me to write that up.

CelesTrak commented 1 year ago

CelesTrak is migrating from TLE format to GP format. The number of objects on Orbit has now exceeded the 5-digit allocation for catalogue numbers. We have been working to update SGP4 to work with GP data instead of TLEs.

Thus, be mindful of the data types for the links on celestrak.org.

brandon-rhodes commented 1 year ago

Let's leave this issue open, then, until I can sit down and update the documentation page:

https://rhodesmill.org/skyfield/earth-satellites.html

—to show the GP format in addition to the old TLE format. Thanks for the reminder.

juniperfdel commented 6 months ago

I found this while looking for solutions to move away from the TLE format while using skyfield - after seeing that none exist; I wrote up the following workaround:

Edit: To use the csv format instead replace "xml" with "csv" in the url and "parse_xml" with "parse_csv"

from pathlib import Path
from urllib.request import urlopen

from sgp4 import omm
from sgp4.api import Satrec
from skyfield.api import EarthSatellite, load

ts = load.timescale()
active = Path("active.xml")

if not active.exists():
    data = urlopen(
        "https://celestrak.org/NORAD/elements/gp.php?GROUP=active&FORMAT=xml"
    )
    active.write_bytes(data.read())

sats = []
with open(active) as f:
    for fields in omm.parse_xml(f):
        sat = Satrec()
        omm.initialize(sat, fields)
        sats.append(EarthSatellite.from_satrec(sat, ts))

print(sats)
juniperfdel commented 4 months ago

To follow up on my previous comment, here is a MWE of how I fully implemented it in my project with TLE support as well - https://gist.github.com/juniperfdel/b06d75bc465907e640aa27b758dfd157

brandon-rhodes commented 1 month ago

I have just released a new version 1.49, which includes support and documentation for the new JSON and CSV formats:

https://rhodesmill.org/skyfield/installation.html#v1-49-2024-june-13

Enjoy!