libera_utils.libera_spice.kernel_manager.KernelManager#
- class libera_utils.libera_spice.kernel_manager.KernelManager(temp_dir_base: str | Path | None = None, download_naif_url: str = 'https://naif.jpl.nasa.gov/pub/naif/generic_kernels/', use_test_naif_url: bool = False, use_high_precision_earth: bool = True, cache_timeout_days: int = 7)#
Bases:
objectManages SPICE kernel loading and lifecycle for Libera geolocation calculations.
- Parameters:
Methods
Method to verify all known kernels are furnished by SPICE.
load_libera_dynamic_kernels(...[, ...])Load dynamic kernels from a directory.
load_naif_kernels([cache_time_out])Load NAIF generic kernels into SPICE.
Load Libera static kernels into SPICE.
Unload all SPICE kernels and clean up resources.
- __init__(temp_dir_base: str | Path | None = None, download_naif_url: str = 'https://naif.jpl.nasa.gov/pub/naif/generic_kernels/', use_test_naif_url: bool = False, use_high_precision_earth: bool = True, cache_timeout_days: int = 7)#
Initialize the kernel manager with no kernels furnished.
Methods
Method to verify all known kernels are furnished by SPICE.
load_libera_dynamic_kernels(...[, ...])Load dynamic kernels from a directory.
load_naif_kernels([cache_time_out])Load NAIF generic kernels into SPICE.
Load Libera static kernels into SPICE.
Unload all SPICE kernels and clean up resources.
- _create_temporary_static_kernels() Path#
Curryer uses json based kernel configuration files to generate SPICE kernels. These configuration files need to be processed into actual SPICE kernel files before they can be loaded. This method creates a temporary directory, copies the necessary configuration files, and generates the static kernels into that directory.
This method will start by furnishing the naif kernels to ensure the leap second kernel is available, as it is required for static kernel generation.
- Returns:
Path to the created temporary directory containing static kernels.
- Return type:
Path
- Raises:
RuntimeError – If kernel creation fails or path exceeds length limit.
- _delete_temporary_static_kernels() None#
Delete the temporary static kernels directory.
Safely removes the directory and all contents. Logs warnings but doesn’t raise exceptions to allow cleanup to proceed.
- ensure_known_kernels_are_furnished() None#
Method to verify all known kernels are furnished by SPICE.
- Raises:
RuntimeError – If kernels are not properly loaded.
- load_libera_dynamic_kernels(dynamic_kernel_directory: str | AnyPath, needs_static_kernels: bool = True, needs_naif_kernels: bool = True) None#
Load dynamic kernels from a directory. This will load both static and NAIF kernels if they have not already been loaded.
Dynamic kernels contain time-varying data like spacecraft or instrument position and attitude for a given observation period.
- Parameters:
dynamic_kernel_directory (str | AnyPath | None) – Path to directory containing all kernel files. All files must be present in this directory, subdirectories will not be searched.
needs_static_kernels (bool) – Whether to ensure static kernels are loaded before loading dynamic kernels (default: True).
needs_naif_kernels (bool) – Whether to ensure NAIF kernels are loaded before loading dynamic kernels (default: True).
- Raises:
FileNotFoundError – If kernel directories are empty or invalid.
- load_naif_kernels(cache_time_out: int | None = None) None#
Load NAIF generic kernels into SPICE. This method will first look in the generic kernel directory, and if no local versions of the needed kernels are found, it will download them from the NAIF server and cache them locally.
These include leap seconds, planetary ephemeris, and Earth orientation data.
- Raises:
FileNotFoundError – If kernel files cannot be found at expected paths.
RuntimeError – If kernel loading fails.
- load_static_kernels() None#
Load Libera static kernels into SPICE.
Static kernels include instrument orientation and configuration data that doesn’t change with time. This only needs to be called once.
- Raises:
FileNotFoundError – If kernel files cannot be found at expected paths.
RuntimeError – If kernel loading fails or paths exceed length limits.