Skip to content

Caching Functions

Functions for managing cache directories where Brahe stores downloaded data.

Main Cache Directory

get_brahe_cache_dir builtin

get_brahe_cache_dir() -> str

Get the brahe cache directory path.

The cache directory is determined by the BRAHE_CACHE environment variable. If not set, defaults to ~/.cache/brahe.

The directory is created if it doesn't exist.

Returns:

Name Type Description
str str

The full path to the cache directory.

Raises:

Type Description
IOError

If the cache directory cannot be created or accessed.

Example
1
2
3
4
5
6
7
8
9
import brahe as bh

cache_dir = bh.get_brahe_cache_dir()
print(f"Cache directory: {cache_dir}")

# You can also override with environment variable
import os
os.environ['BRAHE_CACHE'] = '/custom/cache/path'
cache_dir = bh.get_brahe_cache_dir()
Note

The directory will be created on first access if it doesn't exist.

get_brahe_cache_dir_with_subdir builtin

get_brahe_cache_dir_with_subdir(subdirectory: Union[str, None]) -> str

Get the brahe cache directory path with an optional subdirectory.

The cache directory is determined by the BRAHE_CACHE environment variable. If not set, defaults to ~/.cache/brahe. If a subdirectory is provided, it is appended to the cache path.

The directory is created if it doesn't exist.

Parameters:

Name Type Description Default
subdirectory str or None

Optional subdirectory name to append to cache path.

required

Returns:

Name Type Description
str str

The full path to the cache directory (with subdirectory if provided).

Raises:

Type Description
IOError

If the cache directory cannot be created or accessed.

Example
1
2
3
4
5
6
7
8
9
import brahe as bh

# Get main cache directory
cache_dir = bh.get_brahe_cache_dir_with_subdir(None)
print(f"Cache: {cache_dir}")

# Get custom subdirectory
custom_cache = bh.get_brahe_cache_dir_with_subdir("my_data")
print(f"Custom cache: {custom_cache}")
Note

The directory (and subdirectory) will be created on first access if it doesn't exist.

Specialized Cache Directories

get_eop_cache_dir builtin

get_eop_cache_dir() -> str

Get the EOP cache directory path.

Returns the path to the EOP (Earth Orientation Parameters) cache subdirectory. Defaults to ~/.cache/brahe/eop (or $BRAHE_CACHE/eop if environment variable is set).

The directory is created if it doesn't exist.

Returns:

Name Type Description
str str

The full path to the EOP cache directory.

Raises:

Type Description
IOError

If the cache directory cannot be created or accessed.

Example
1
2
3
4
import brahe as bh

eop_cache = bh.get_eop_cache_dir()
print(f"EOP cache: {eop_cache}")
Note

The directory will be created on first access if it doesn't exist.

get_celestrak_cache_dir builtin

get_celestrak_cache_dir() -> str

Get the CelesTrak cache directory path.

Returns the path to the CelesTrak cache subdirectory used for storing downloaded TLE data. Defaults to ~/.cache/brahe/celestrak (or $BRAHE_CACHE/celestrak if environment variable is set).

The directory is created if it doesn't exist.

Returns:

Name Type Description
str str

The full path to the CelesTrak cache directory.

Raises:

Type Description
IOError

If the cache directory cannot be created or accessed.

Example
1
2
3
4
import brahe as bh

celestrak_cache = bh.get_celestrak_cache_dir()
print(f"CelesTrak cache: {celestrak_cache}")
Note

The directory will be created on first access if it doesn't exist.