fullplot 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fullplot/__init__.py +61 -0
- fullplot/cli.py +63 -0
- fullplot/fullplot.py +1647 -0
- fullplot/hdf5.py +48 -0
- fullplot/maps.py +708 -0
- fullplot/themes.py +176 -0
- fullplot-0.0.1.dist-info/METADATA +119 -0
- fullplot-0.0.1.dist-info/RECORD +10 -0
- fullplot-0.0.1.dist-info/WHEEL +4 -0
- fullplot-0.0.1.dist-info/entry_points.txt +3 -0
fullplot/hdf5.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
import h5py
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
HDF5_EXTENSIONS = {".h5", ".hdf5"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def hdf5_path(filename: str | Path) -> Path:
|
|
14
|
+
"""Return an HDF5 path, adding .h5 when the suffix is omitted."""
|
|
15
|
+
path = Path(filename)
|
|
16
|
+
|
|
17
|
+
if path.suffix == "":
|
|
18
|
+
path = path.with_suffix(".h5")
|
|
19
|
+
elif path.suffix.lower() not in HDF5_EXTENSIONS:
|
|
20
|
+
raise ValueError("Use an HDF5 filename with no extension, .h5, or .hdf5.")
|
|
21
|
+
|
|
22
|
+
if path.parent != Path(""):
|
|
23
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
24
|
+
|
|
25
|
+
return path
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def hdf5_filename(filename: str | Path) -> str:
|
|
29
|
+
"""Return an HDF5 filename string, adding .h5 when omitted."""
|
|
30
|
+
return str(hdf5_path(filename))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def safe_group_name(name: Any) -> str:
|
|
34
|
+
"""Return a compact HDF5-safe group/dataset name."""
|
|
35
|
+
text = str(name).strip()
|
|
36
|
+
text = re.sub(r"[\\/\x00]", "_", text)
|
|
37
|
+
text = re.sub(r"\s+", "_", text)
|
|
38
|
+
return text or "unnamed"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def dataset_names(group: h5py.Group, excluded: set[str] | None = None) -> list[str]:
|
|
42
|
+
"""Return direct child dataset names, excluding any requested names."""
|
|
43
|
+
excluded = set() if excluded is None else set(excluded)
|
|
44
|
+
return [
|
|
45
|
+
name
|
|
46
|
+
for name, item in group.items()
|
|
47
|
+
if name not in excluded and isinstance(item, h5py.Dataset)
|
|
48
|
+
]
|