Skyfield: Home • Table of Contents • API Reference
Loader(directory, verbose=True, expire=False)¶
A tool for downloading and opening astronomical data files.
Loader that saves data files to the current working
directory can be imported directly from the Skyfield API:
from skyfield.api import load
But users can also create a
Loader of their own, if there is
another directory they want data files saved to, or if they want to
specify different options. The directory is created automatically
if it does not yet exist:
from skyfield.api import Loader load = Loader('~/skyfield-data')
The options are:
False, then the loader will not print a progress bar to the screen each time it downloads a file. (If the standard output is not a TTY, then no progress bar is printed anyway.)
Loader is created, it can be called like a function to
open, or else to download and open, a file whose name it recognizes:
planets = load('de405.bsp')
Each loader also supports an attribute and a few methods.
The directory where this loader looks when trying to open a file, and where it downloads files that have not been downloaded yet.
Return the path to
filename in this loader’s directory.
Return the URL Skyfield will try downloading for a given filename.
tle_file(url, reload=False, filename=None, ts=None, skip_names=False)¶
Load and parse a TLE file, returning a list of Earth satellites.
open() method for the
meaning of the
parse_tle_file() function for the meaning of the
open(url, mode='rb', reload=False, filename=None, backup=False)¶
Open a file, downloading it first if it does not yet exist.
Unlike when you call a loader directly like
my_loader.open() method does not attempt to parse or
interpret the file; it simply returns an open file object.
url can be either an external URL, or else the path to a
file on the current filesystem. A relative path will be assumed
to be relative to the base directory of this loader object.
If a URL was provided and the
reload parameter is true, then
any existing file will be removed before the download starts.
filename parameter lets you specify an alternative local
filename instead of having the filename extracted from the final
component of the URL.
Open or download three time scale files, returning a
delta_t — Lets you override the standard ∆T tables by
providing your own ∆T offset in seconds. For details, see
Setting a Custom Value For ∆T.
builtin — Set this to
False to download new copies of
the three official files that supply recent ∆T measurements and
the current schedule of UTC leap seconds. By default, Skyfield
uses copies of the three files that it ships with and installs
alongside its code. For details, see
Downloading new timescale files.
Open a file on your local drive, using its extension to guess its type.
This routine only works on
.bsp ephemeris files right now, but
will gain support for additional file types in the future.
from skyfield.api import load_file planets = load_file('~/Downloads/de421.bsp')
parse_tle_file(lines, ts=None, skip_names=False)¶
Parse lines of TLE satellite data, yielding a sequence of satellites.
Given a sequence
lines of byte strings (which can be an open
binary file, which acts like a sequence of lines in Python), this
routine yields an
EarthSatellite for each
pair of adjacent lines that start with
"1 " and
"2 " and
have 69 or more characters each. If the line preceding a TLE is not
part of another TLE, it is used as the satellite’s
If you pass a
ts timescale, Skyfield will use it to build the
.epoch date attribute on each satellite; otherwise a timescale
derived from Skyfield’s built-in leap second files will be used.
If for a particular file you see random lines of text being
interpreted as satellite names, set
Skyfield will not try to store satellite names.
See Earth Satellites for details. An exception is raised if the attempt to parse a pair of candidate lines as TLE lines fails.