dagmc-h5m-file-inspector 0.5.0__tar.gz → 0.6.0__tar.gz

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.
Files changed (52) hide show
  1. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0}/.github/workflows/ci_with_install.yml +12 -9
  2. dagmc_h5m_file_inspector-0.6.0/PKG-INFO +154 -0
  3. dagmc_h5m_file_inspector-0.6.0/README.md +128 -0
  4. dagmc_h5m_file_inspector-0.6.0/pyproject.toml +48 -0
  5. dagmc_h5m_file_inspector-0.6.0/setup.cfg +4 -0
  6. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector/__init__.py +7 -0
  7. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector/_version.py +34 -0
  8. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector/cli.py +106 -0
  9. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector/core.py +926 -0
  10. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector.egg-info/PKG-INFO +154 -0
  11. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector.egg-info/SOURCES.txt +32 -0
  12. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector.egg-info/entry_points.txt +2 -0
  13. dagmc_h5m_file_inspector-0.6.0/src/dagmc_h5m_file_inspector.egg-info/requires.txt +12 -0
  14. dagmc_h5m_file_inspector-0.6.0/tests/circulartorus.h5m +0 -0
  15. dagmc_h5m_file_inspector-0.6.0/tests/conftest.py +81 -0
  16. dagmc_h5m_file_inspector-0.6.0/tests/cuboid.h5m +0 -0
  17. dagmc_h5m_file_inspector-0.6.0/tests/cylinder.h5m +0 -0
  18. dagmc_h5m_file_inspector-0.6.0/tests/dagmc_separated.h5m +0 -0
  19. dagmc_h5m_file_inspector-0.6.0/tests/ellipticaltorus.h5m +0 -0
  20. dagmc_h5m_file_inspector-0.6.0/tests/nestedcylinder.h5m +0 -0
  21. dagmc_h5m_file_inspector-0.6.0/tests/nestedsphere.h5m +0 -0
  22. dagmc_h5m_file_inspector-0.6.0/tests/oktavian.h5m +0 -0
  23. dagmc_h5m_file_inspector-0.6.0/tests/simpletokamak.h5m +0 -0
  24. dagmc_h5m_file_inspector-0.6.0/tests/sphere.h5m +0 -0
  25. dagmc_h5m_file_inspector-0.6.0/tests/test_python_api_usage.py +644 -0
  26. dagmc_h5m_file_inspector-0.6.0/tests/tetrahedral.h5m +0 -0
  27. dagmc_h5m_file_inspector-0.6.0/tests/two_tetrahedrons.h5m +0 -0
  28. dagmc_h5m_file_inspector-0.6.0/tests/twotouchingcuboids.h5m +0 -0
  29. dagmc_h5m_file_inspector-0.5.0/.github/workflows/anaconda-publish.yml +0 -29
  30. dagmc_h5m_file_inspector-0.5.0/.github/workflows/black.yml +0 -32
  31. dagmc_h5m_file_inspector-0.5.0/PKG-INFO +0 -135
  32. dagmc_h5m_file_inspector-0.5.0/README.md +0 -108
  33. dagmc_h5m_file_inspector-0.5.0/conda/conda_build_config.yaml +0 -7
  34. dagmc_h5m_file_inspector-0.5.0/conda/meta.yaml +0 -49
  35. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector/__init__.py +0 -3
  36. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector/_version.py +0 -5
  37. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector/core.py +0 -142
  38. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector/inspect-dagmc-h5m-file +0 -89
  39. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector.egg-info/PKG-INFO +0 -135
  40. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector.egg-info/SOURCES.txt +0 -24
  41. dagmc_h5m_file_inspector-0.5.0/dagmc_h5m_file_inspector.egg-info/requires.txt +0 -5
  42. dagmc_h5m_file_inspector-0.5.0/pyproject.toml +0 -10
  43. dagmc_h5m_file_inspector-0.5.0/setup.cfg +0 -43
  44. dagmc_h5m_file_inspector-0.5.0/setup.py +0 -4
  45. dagmc_h5m_file_inspector-0.5.0/tests/test_command_line_usage.py +0 -124
  46. dagmc_h5m_file_inspector-0.5.0/tests/test_python_api_usage.py +0 -167
  47. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0}/.github/workflows/python-publish.yml +0 -0
  48. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0}/.gitignore +0 -0
  49. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0}/CITATION.cff +0 -0
  50. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0}/LICENSE.txt +0 -0
  51. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0/src}/dagmc_h5m_file_inspector.egg-info/dependency_links.txt +0 -0
  52. {dagmc_h5m_file_inspector-0.5.0 → dagmc_h5m_file_inspector-0.6.0/src}/dagmc_h5m_file_inspector.egg-info/top_level.txt +0 -0
@@ -3,7 +3,7 @@
3
3
  # within that image the pytest test suite is run
4
4
 
5
5
 
6
- name: CI with install
6
+ name: CI with pip install
7
7
 
8
8
  on:
9
9
  pull_request:
@@ -14,21 +14,24 @@ on:
14
14
  jobs:
15
15
  testing:
16
16
  runs-on: ubuntu-latest
17
- container:
18
- image: continuumio/miniconda3
19
17
  steps:
20
18
  - name: Checkout repository
21
- uses: actions/checkout@v2
22
-
19
+ uses: actions/checkout@v6
20
+
21
+ - name: Install system dependencies
22
+ run: |
23
+ sudo apt-get update
24
+ sudo apt-get install -y libglu1-mesa libgl1
25
+
23
26
  - name: install package
24
27
  run: |
25
- conda install -c conda-forge moab
26
- pip install pytest
27
- python setup.py install
28
+ python -m pip install --extra-index-url https://shimwell.github.io/wheels moab
29
+ pip install git+https://github.com/svalinn/pydagmc
30
+ python -m pip install .[tests]
28
31
 
29
32
  - name: Run test_utils
30
33
  run: |
31
- pytest tests
34
+ python -m pytest
32
35
 
33
36
  - name: Upload to codecov
34
37
  uses: codecov/codecov-action@v2
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: dagmc_h5m_file_inspector
3
+ Version: 0.6.0
4
+ Summary: Extracts information from DAGMC h5m files including volumes number, material tags
5
+ Author-email: The dagmc_h5m_file_inspector Development Team <mail@jshimwell.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/fusion-energy/dagmc_h5m_file_inspector
8
+ Project-URL: Source, https://github.com/fusion-energy/dagmc_h5m_file_inspector
9
+ Project-URL: Tracker, https://github.com/fusion-energy/dagmc_h5m_file_inspector/issues
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE.txt
15
+ Requires-Dist: h5py
16
+ Requires-Dist: numpy
17
+ Provides-Extra: pymoab
18
+ Requires-Dist: pymoab; extra == "pymoab"
19
+ Provides-Extra: tests
20
+ Requires-Dist: pytest>=5.4.3; extra == "tests"
21
+ Requires-Dist: requests; extra == "tests"
22
+ Requires-Dist: pytest-cov; extra == "tests"
23
+ Requires-Dist: cad-to-dagmc; extra == "tests"
24
+ Requires-Dist: cadquery; extra == "tests"
25
+ Dynamic: license-file
26
+
27
+
28
+ [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
29
+
30
+ [![CI with install](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/ci_with_install.yml)
31
+
32
+ [![codecov](https://codecov.io/gh/fusion-energy/dagmc_h5m_file_inspector/branch/main/graph/badge.svg)](https://codecov.io/gh/fusion-energy/dagmc_h5m_file_inspector)
33
+
34
+ [![Upload Python Package](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/python-publish.yml/badge.svg?branch=main)](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/python-publish.yml)
35
+ [![PyPI](https://img.shields.io/pypi/v/dagmc_h5m_file_inspector?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/dagmc_h5m_file_inspector/)
36
+
37
+ # dagmc-h5m-file-inspector
38
+
39
+ A minimal Python package that inspects DAGMC h5m files to extract volume IDs,
40
+ material tags, bounding boxes, and geometric volumes.
41
+
42
+
43
+ # Installation
44
+
45
+ ```bash
46
+ pip install dagmc-h5m-file-inspector
47
+ ```
48
+
49
+ The package uses h5py as the default backend. Optionally, pymoab can be used
50
+ as an alternative backend if installed.
51
+
52
+
53
+ # Python API Usage
54
+
55
+ ## Finding volume IDs
56
+
57
+ ```python
58
+ import dagmc_h5m_file_inspector as di
59
+
60
+ di.get_volumes_from_h5m("dagmc.h5m")
61
+
62
+ >>> [1, 2]
63
+ ```
64
+
65
+ ## Finding material tags
66
+
67
+ ```python
68
+ import dagmc_h5m_file_inspector as di
69
+
70
+ di.get_materials_from_h5m("dagmc.h5m")
71
+
72
+ >>> ['big_box', 'small_box']
73
+ ```
74
+
75
+ ## Finding volume IDs with their materials
76
+
77
+ ```python
78
+ import dagmc_h5m_file_inspector as di
79
+
80
+ di.get_volumes_and_materials_from_h5m("dagmc.h5m")
81
+
82
+ >>> {1: 'small_box', 2: 'big_box'}
83
+ ```
84
+
85
+ ## Getting the bounding box
86
+
87
+ ```python
88
+ import dagmc_h5m_file_inspector as di
89
+
90
+ lower_left, upper_right = di.get_bounding_box_from_h5m("dagmc.h5m")
91
+
92
+ >>> lower_left
93
+ array([-5., -10., -10.])
94
+
95
+ >>> upper_right
96
+ array([25., 10., 10.])
97
+ ```
98
+
99
+ ## Getting geometric volume sizes by cell ID
100
+
101
+ ```python
102
+ import dagmc_h5m_file_inspector as di
103
+
104
+ di.get_volumes_sizes_from_h5m_by_cell_id("dagmc.h5m")
105
+
106
+ >>> {1: 1000.0, 2: 8000.0}
107
+ ```
108
+
109
+ ## Getting geometric volume sizes by material name
110
+
111
+ ```python
112
+ import dagmc_h5m_file_inspector as di
113
+
114
+ di.get_volumes_sizes_from_h5m_by_material_name("dagmc.h5m")
115
+
116
+ >>> {'small_box': 1000.0, 'big_box': 8000.0}
117
+ ```
118
+
119
+ ## Setting OpenMC material volumes from DAGMC geometry
120
+
121
+ This function reads the DAGMC file, matches materials by name, and sets the
122
+ `volume` attribute on the corresponding OpenMC Material objects.
123
+
124
+ ```python
125
+ import openmc
126
+ import dagmc_h5m_file_inspector as di
127
+
128
+ # Create OpenMC materials with names matching the DAGMC file
129
+ small_box = openmc.Material(name='small_box')
130
+ big_box = openmc.Material(name='big_box')
131
+ materials = openmc.Materials([small_box, big_box])
132
+
133
+ # Set volumes from DAGMC geometry
134
+ di.set_openmc_material_volumes_from_h5m(materials, "dagmc.h5m")
135
+
136
+ >>> small_box.volume
137
+ 1000.0
138
+
139
+ >>> big_box.volume
140
+ 8000.0
141
+ ```
142
+
143
+ ## Using the pymoab backend
144
+
145
+ All functions support an optional `backend` parameter. The default is `"h5py"`,
146
+ but `"pymoab"` can be used if pymoab is installed:
147
+
148
+ ```python
149
+ import dagmc_h5m_file_inspector as di
150
+
151
+ di.get_volumes_from_h5m("dagmc.h5m", backend="pymoab")
152
+
153
+ >>> [1, 2]
154
+ ```
@@ -0,0 +1,128 @@
1
+
2
+ [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
3
+
4
+ [![CI with install](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/ci_with_install.yml)
5
+
6
+ [![codecov](https://codecov.io/gh/fusion-energy/dagmc_h5m_file_inspector/branch/main/graph/badge.svg)](https://codecov.io/gh/fusion-energy/dagmc_h5m_file_inspector)
7
+
8
+ [![Upload Python Package](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/python-publish.yml/badge.svg?branch=main)](https://github.com/fusion-energy/dagmc_h5m_file_inspector/actions/workflows/python-publish.yml)
9
+ [![PyPI](https://img.shields.io/pypi/v/dagmc_h5m_file_inspector?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/dagmc_h5m_file_inspector/)
10
+
11
+ # dagmc-h5m-file-inspector
12
+
13
+ A minimal Python package that inspects DAGMC h5m files to extract volume IDs,
14
+ material tags, bounding boxes, and geometric volumes.
15
+
16
+
17
+ # Installation
18
+
19
+ ```bash
20
+ pip install dagmc-h5m-file-inspector
21
+ ```
22
+
23
+ The package uses h5py as the default backend. Optionally, pymoab can be used
24
+ as an alternative backend if installed.
25
+
26
+
27
+ # Python API Usage
28
+
29
+ ## Finding volume IDs
30
+
31
+ ```python
32
+ import dagmc_h5m_file_inspector as di
33
+
34
+ di.get_volumes_from_h5m("dagmc.h5m")
35
+
36
+ >>> [1, 2]
37
+ ```
38
+
39
+ ## Finding material tags
40
+
41
+ ```python
42
+ import dagmc_h5m_file_inspector as di
43
+
44
+ di.get_materials_from_h5m("dagmc.h5m")
45
+
46
+ >>> ['big_box', 'small_box']
47
+ ```
48
+
49
+ ## Finding volume IDs with their materials
50
+
51
+ ```python
52
+ import dagmc_h5m_file_inspector as di
53
+
54
+ di.get_volumes_and_materials_from_h5m("dagmc.h5m")
55
+
56
+ >>> {1: 'small_box', 2: 'big_box'}
57
+ ```
58
+
59
+ ## Getting the bounding box
60
+
61
+ ```python
62
+ import dagmc_h5m_file_inspector as di
63
+
64
+ lower_left, upper_right = di.get_bounding_box_from_h5m("dagmc.h5m")
65
+
66
+ >>> lower_left
67
+ array([-5., -10., -10.])
68
+
69
+ >>> upper_right
70
+ array([25., 10., 10.])
71
+ ```
72
+
73
+ ## Getting geometric volume sizes by cell ID
74
+
75
+ ```python
76
+ import dagmc_h5m_file_inspector as di
77
+
78
+ di.get_volumes_sizes_from_h5m_by_cell_id("dagmc.h5m")
79
+
80
+ >>> {1: 1000.0, 2: 8000.0}
81
+ ```
82
+
83
+ ## Getting geometric volume sizes by material name
84
+
85
+ ```python
86
+ import dagmc_h5m_file_inspector as di
87
+
88
+ di.get_volumes_sizes_from_h5m_by_material_name("dagmc.h5m")
89
+
90
+ >>> {'small_box': 1000.0, 'big_box': 8000.0}
91
+ ```
92
+
93
+ ## Setting OpenMC material volumes from DAGMC geometry
94
+
95
+ This function reads the DAGMC file, matches materials by name, and sets the
96
+ `volume` attribute on the corresponding OpenMC Material objects.
97
+
98
+ ```python
99
+ import openmc
100
+ import dagmc_h5m_file_inspector as di
101
+
102
+ # Create OpenMC materials with names matching the DAGMC file
103
+ small_box = openmc.Material(name='small_box')
104
+ big_box = openmc.Material(name='big_box')
105
+ materials = openmc.Materials([small_box, big_box])
106
+
107
+ # Set volumes from DAGMC geometry
108
+ di.set_openmc_material_volumes_from_h5m(materials, "dagmc.h5m")
109
+
110
+ >>> small_box.volume
111
+ 1000.0
112
+
113
+ >>> big_box.volume
114
+ 8000.0
115
+ ```
116
+
117
+ ## Using the pymoab backend
118
+
119
+ All functions support an optional `backend` parameter. The default is `"h5py"`,
120
+ but `"pymoab"` can be used if pymoab is installed:
121
+
122
+ ```python
123
+ import dagmc_h5m_file_inspector as di
124
+
125
+ di.get_volumes_from_h5m("dagmc.h5m", backend="pymoab")
126
+
127
+ >>> [1, 2]
128
+ ```
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0", "setuptools_scm[toml] >= 6.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dagmc_h5m_file_inspector"
7
+ dynamic = ["version"]
8
+ description = "Extracts information from DAGMC h5m files including volumes number, material tags"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ { name = "The dagmc_h5m_file_inspector Development Team", email = "mail@jshimwell.com" },
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "h5py",
21
+ "numpy",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/fusion-energy/dagmc_h5m_file_inspector"
26
+ Source = "https://github.com/fusion-energy/dagmc_h5m_file_inspector"
27
+ Tracker = "https://github.com/fusion-energy/dagmc_h5m_file_inspector/issues"
28
+
29
+ [project.scripts]
30
+ inspect-dagmc-h5m-file = "dagmc_h5m_file_inspector.cli:main"
31
+
32
+ [project.optional-dependencies]
33
+ pymoab = [
34
+ "pymoab",
35
+ ]
36
+ tests = [
37
+ "pytest >= 5.4.3",
38
+ "requests",
39
+ "pytest-cov",
40
+ "cad-to-dagmc",
41
+ "cadquery",
42
+ ]
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+
47
+ [tool.setuptools_scm]
48
+ write_to = "src/dagmc_h5m_file_inspector/_version.py"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from .core import get_volumes_from_h5m
2
+ from .core import get_materials_from_h5m
3
+ from .core import get_volumes_and_materials_from_h5m
4
+ from .core import get_bounding_box_from_h5m
5
+ from .core import get_volumes_sizes_from_h5m_by_cell_id
6
+ from .core import get_volumes_sizes_from_h5m_by_material_name
7
+ from .core import set_openmc_material_volumes_from_h5m
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.6.0'
32
+ __version_tuple__ = version_tuple = (0, 6, 0)
33
+
34
+ __commit_id__ = commit_id = 'gb273ac487'
@@ -0,0 +1,106 @@
1
+ import argparse
2
+ import json
3
+ import pprint
4
+
5
+ from dagmc_h5m_file_inspector import (
6
+ get_volumes_from_h5m,
7
+ get_materials_from_h5m,
8
+ get_volumes_and_materials_from_h5m,
9
+ )
10
+
11
+
12
+ def main():
13
+ parser = argparse.ArgumentParser()
14
+
15
+ parser.add_argument(
16
+ "-i",
17
+ "--input",
18
+ type=str,
19
+ help="The filename of the h5m file",
20
+ required=True,
21
+ )
22
+
23
+ parser.add_argument(
24
+ "-v",
25
+ "--volumes",
26
+ help="Returns volume ids from a h5m file",
27
+ required=False,
28
+ action="store_true",
29
+ )
30
+
31
+ parser.add_argument(
32
+ "-m",
33
+ "--materials",
34
+ help="Returns materials tags from a h5m file",
35
+ required=False,
36
+ action="store_true",
37
+ )
38
+
39
+ parser.add_argument(
40
+ "-b",
41
+ "--both",
42
+ help="Returns volume ids with materials tags from a h5m file",
43
+ required=False,
44
+ action="store_true",
45
+ )
46
+
47
+ parser.add_argument(
48
+ "-o",
49
+ "--output",
50
+ type=str,
51
+ default="inspector_results.txt",
52
+ help="Returns volume ids with materials tags from a h5m file",
53
+ required=False,
54
+ )
55
+
56
+ parser.add_argument(
57
+ "--backend",
58
+ type=str,
59
+ choices=["h5py", "pymoab"],
60
+ default="h5py",
61
+ help="Backend to use for reading h5m files (default: h5py)",
62
+ required=False,
63
+ )
64
+
65
+ args = parser.parse_args()
66
+
67
+ volumes = None
68
+ if args.volumes:
69
+ volumes = get_volumes_from_h5m(filename=args.input, backend=args.backend)
70
+ print(f"\nVolume IDs ={volumes}")
71
+
72
+ materials = None
73
+ if args.materials:
74
+ materials = get_materials_from_h5m(filename=args.input, backend=args.backend)
75
+ print(f"\nMaterial tags ={materials}")
76
+
77
+ both = None
78
+ if args.both:
79
+ both = get_volumes_and_materials_from_h5m(filename=args.input, backend=args.backend)
80
+ pp = pprint.PrettyPrinter(indent=4)
81
+ print("\nVolume IDs and material tags=")
82
+ pp.pprint(both)
83
+
84
+ if args.volumes is False and args.materials is False and args.both is False:
85
+ print(
86
+ f"\nNo inspection of {args.input} carried out as outputs were not "
87
+ "specified. Output options include -v, --volume, -m, --materials"
88
+ ", -b, --both"
89
+ )
90
+ elif args.output:
91
+ with open(args.output, "w") as output_file:
92
+ text_to_write = {}
93
+ if volumes is not None:
94
+ text_to_write["volumes"] = volumes
95
+ if materials is not None:
96
+ text_to_write["materials"] = materials
97
+ if both is not None:
98
+ text_to_write["both"] = both
99
+ print(f"writing file {args.output}")
100
+ json.dump(text_to_write, output_file, indent=4)
101
+
102
+ print("\n")
103
+
104
+
105
+ if __name__ == "__main__":
106
+ main()