module: data#
Data file utilities for pyDARTdiags examples.
This module provides functions to locate, download, and cache example files used in pyDARTdiags examples. The data files are cached in the users home directory under ~/.pydartdiags/data.
- data.get_data_cache_dir()#
Get the cache directory for downloaded data files.
- data.get_example_data(filename, auto_download=True)#
Get path to a data file, checking multiple locations.
- Searches for data files in the following order:
Development location (../../data from package GitHub repo)
Environment variable PYDARTDIAGS_DATA
User cache directory (~/.pydartdiags/data)
Downloads from Zenodo if auto_download=True
- Parameters:
filename (str) β Name of the data file to locate
auto_download (bool, optional) β If True, automatically download from Zenodo if not found locally. Default is True.
- Returns:
Absolute path to the data file
- Return type:
str
- Raises:
FileNotFoundError β If the file is not found and auto_download=False
Examples
data_file = get_example_data("obs_seq.final.lorenz_96")
- data.download_all_data(force=False)#
Download all example data files from Zenodo.
Downloads and extracts the complete data archive to the userβs cache directory (~/.pydartdiags/data).
- Parameters:
force (bool, optional) β If True, re-download even if data already exists. Default is False.
Examples
from pydartdiags.data import download_all_data download_all_data()
- data.list_available_data()#
List all available data files.
- Returns:
List of available data file names
- Return type:
list of str
Examples
from pydartdiags.data import list_available_data files = list_available_data() print(files)
- data.clear_cache()#
Remove all downloaded data from the cache directory.
Examples
from pydartdiags.data import clear_cache clear_cache()