pymkm.io.data_registry¶
Discovery and loading of default stopping power data files.
This module provides functions to:
Locate .txt files for specific ions and sources (e.g.`mstar_3_12`, geant4_11_3_0, fluka_2020_0)
List available sources and files
Load the elements.json periodic table lookup used throughout pyMKM
All file paths are resolved using importlib.resources, making them portable
within installed packages or local development environments.
- pymkm.io.data_registry.get_available_sources() List[str][source]¶
List all available data sources within the default data registry.
Looks for subdirectories under pymkm.data.defaults corresponding to different source categories.
- Returns:
List of source names (subdirectory names).
- Return type:
list[str]
- Raises:
FileNotFoundError – If the base directory cannot be located.
- pymkm.io.data_registry.get_default_txt_path(source: str, filename: str) str[source]¶
Locate a default .txt file for a given source and filename.
Tries first to resolve the file within the installed package. Falls back to a local relative path (for development use) if needed.
- Parameters:
source (str) – The name of the data subdirectory (e.g., “ions”).
filename (str) – The name of the .txt file to locate.
- Returns:
Absolute path to the located file.
- Return type:
str
- Raises:
FileNotFoundError – If the file cannot be found in either location.
- pymkm.io.data_registry.list_available_defaults(source: str) List[str][source]¶
List all available .txt files under a given source folder.
Looks within pymkm.data.defaults.<source> and returns matching files.
- Parameters:
source (str) – The name of the data source folder.
- Returns:
List of filenames with .txt extension.
- Return type:
list[str]
- Raises:
FileNotFoundError – If the source folder or .txt files cannot be located.
- pymkm.io.data_registry.load_lookup_table() Dict[str, Dict][source]¶
Load the chemical elements lookup table from a JSON file.
Tries to load elements.json from the installed package, with a fallback to a local relative file during development.
- Returns:
Dictionary mapping element symbols to their properties.
- Return type:
dict[str, dict]
- Raises:
FileNotFoundError – If the elements.json file cannot be found.
json.JSONDecodeError – If the file content is not valid JSON.