curryer.kernels.classes

classes

@author: Brandon Stone

Attributes

Classes

TypedDataDescriptor

Data descriptor that enforces typing through casting.

AbstractKernelProperties

Kernel properties abstraction.

AbstractKernelWriter

Write to a SPICE kernel.

Module Contents

curryer.kernels.classes.logger
class curryer.kernels.classes.TypedDataDescriptor(*, default, dtype)

Data descriptor that enforces typing through casting.

_default
_dtype
__set_name__(owner, name)
__get__(instance, owner)
__set__(instance, value)
class curryer.kernels.classes.AbstractKernelProperties

Kernel properties abstraction.

SUPPORTED_INPUT_DATA_TYPES: ClassVar = None
input_data_type: enum.Enum
input_gap_threshold: str = None
leapsecond_kernel: str = None
version: int = 1
author: str = 'LASP'
mappings: dict = None
relative_dir: pathlib.Path = None
__post_init__()
_update_paths(attr_names)
abstractmethod to_dict()

Convert properties to a dict.

class curryer.kernels.classes.AbstractKernelWriter(properties: AbstractKernelProperties, bin_dir: str = None, parent_dir: str = None)

Write to a SPICE kernel.

KTYPE = None
FILE_EXT = None
properties
bin_dir = None
parent_dir = None
input_file = None
setup_file = None
_temp_kernel_files = []
__call__(input_data: pandas.DataFrame, filename, overwrite=False, append=False)

Prepare and then create a kernel file.

abstractmethod prepare_input_data(input_data: pandas.DataFrame) list[pandas.DataFrame]

Prepare an accessor that will provide input data for the kernel.

_chunk_table_by_gaps(table: pandas.DataFrame, index_dt_type='utc')

Chunk a table by the input_gap_threshold (if any).

abstractmethod write_input_data(fobj_or_str, input_data: pandas.DataFrame)

Write input data.

_safe_write_input_data(input_data: pandas.DataFrame)

Context to write the input data to a CSV file.

A temporary file is used if one wasn’t defined; it’s deleted on exit.

Parameters:

input_data (pd.DataFrame) – Data frame to use as the input data source.

Yields:

str – Path to the input data file (CSV format). Either self.input_file, if it was a str, or a temporary file if it was None.

_auto_shorten_kernel_paths(config, max_length=80)

Auto-shorten kernel file paths that exceed SPICE’s string length limit.

Uses a two-strategy approach: try symlinks first, then try file copying if symlinks fail. Both strategies are enabled by default, but copying can be disabled.

Parameters:
  • config (dict) – Kernel configuration dictionary

  • max_length (int) – Maximum allowed path length (default: 80 for SPICE)

Returns:

Modified config with shortened paths

Return type:

dict

Notes

Created temporary files (symlinks or copies) are tracked in self._temp_kernel_files for automatic cleanup after kernel generation.

_cleanup_temp_kernel_files()

Clean up temporary kernel files created during path shortening.

These are kernel files that were copied to /tmp to avoid the 80-character path limit. They need to exist during kernel generation but should be cleaned up afterward to avoid accumulating in /tmp.

Notes

This method is called automatically in the finally block of write_kernel() to ensure cleanup happens even if kernel generation fails. Errors during cleanup are logged but do not interrupt the process.

prepare_setup_config()

Prepare the kernel file’s setup configuration (pseudo kernel).

_safe_write_setup_config(setup_txt)

Context to write the setup configuration to a text file.

A temporary file is used if one wasn’t defined; it’s deleted on exit.

Parameters:

setup_txt (str) – Setup configuration text.

Yields:

str – Path to the setup file. Either self.setup_file, if it was a str, or a temporary file if it was None.

_backup_file(filename)

Context to create a temporary backup of a file (if it exists). The original file is restored if an exception occurs. The temporary backup is deleted when the context exits.

static _check_write_behavior(kernel_file, overwrite=False, append=False)

Check if file exists and if writer should overwrite vs. append. Required because the SPICE utils have different behavior.

_get_bin(name)

Get the path to an executable.

abstractmethod _write_kernel(setup_file, input_file, kernel_file, append=False)

Write to the kernel.

write_kernel(filename, input_data, setup_txt, overwrite=False, append=False)

Create a new kernel or append to an existing one (config setting).