empyrean.initialize¶
- initialize(*, data_dir=None, de440_path=None, gm_path=None, refresh=True)[source]¶
Initialize empyrean with SPICE kernel data.
On first call, loads ephemeris data into a global context. Subsequent calls are no-ops — including their
refresh, so the first call in a process is the one that decides whether the network is reachable.If the B612 Foundation data packages (
naif-de440,jpl-small-bodies-de441-n16,naif-eop-high-prec,naif-eop-historical,naif-eop-predict,mpc-obscodes) are installed and no explicit paths are provided, empyrean stages a symlinked cache under the platform XDG data directory ($XDG_DATA_HOME/empyrean/data/on Linux,~/Library/Application Support/empyrean/data/on macOS,%APPDATA%\empyrean\data\on Windows; honorsEMPYREAN_DATA_DIR) and uses that as the data directory — zero network access required. Falls back todata_dir(default: the same XDG.../empyrean/data/location) plusdownload_data()otherwise.- Parameters:
data_dir (
str|Path|None) – Directory containing kernel files. Overrides B612 detection.de440_path (
str|Path|None) – Explicit path tode440.bsp. Overrides B612 detection.gm_path (
str|Path|None) – Explicit path togm_de440.tpc.refresh (
bool) –Whether initialization may reach the network.
True(default) downloads any required kernel that is missing and re-downloads any whose upstream copy moved.Falseis strict offline: kernels are resolved from the data directory alone and initialization fails, naming every absent file, if any is missing. There is no try-the-network-and-tolerate path and no degrade-to-a-lower-tier path.Passing both
de440_pathandgm_pathloads exactly those two files and never reaches the network on either value, sorefresh=Falseis already satisfied on that branch.Setting the environment variable
EMPYREAN_OFFLINE=1acts as a floor: it downgradesrefresh=TruetoFalseand says so on stderr. It can never turnFalseintoTrue, so an operator asserting “this machine must not reach the network” cannot have that reversed by a library call.
- Raises:
FileNotFoundError – Under
refresh=Falsewhen the data directory is missing a required kernel. The exception carries amissing_data_filesattribute — the list of absent filenames — so a caller can fetch or report exactly that set without re-parsing the message.RuntimeError – Any other initialization failure.
- Return type:
None
Examples
>>> empyrean.initialize(refresh=False) # air-gapped / reproducible run