dagmc-h5m-file-inspector 0.4.3__py3-none-any.whl → 0.6.0__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.
@@ -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,10 @@
1
+ dagmc_h5m_file_inspector/__init__.py,sha256=XjtzcKpewbDKzZLaGmnsaAmi49YOr1OwdLWxsgDYkWI,350
2
+ dagmc_h5m_file_inspector/_version.py,sha256=MAYWefOLb6kbIRub18WSzK6ggSjz1LNLy9aDRlX9Ea4,704
3
+ dagmc_h5m_file_inspector/cli.py,sha256=4vzu4ogkGNwwjy-TguFCDbyscZUrZ80LY2DOqn_Ytr8,2803
4
+ dagmc_h5m_file_inspector/core.py,sha256=Uf6a9xl-2on8gIPuRXrm1ZbO3jXXdFTmKaxwSBHLAcs,30732
5
+ dagmc_h5m_file_inspector-0.6.0.dist-info/licenses/LICENSE.txt,sha256=UXVi860HD1Sxktd5fnU_1rn9Y77JxHF_jM1muoihSJc,1070
6
+ dagmc_h5m_file_inspector-0.6.0.dist-info/METADATA,sha256=ZCgD_zAHwcbwjub64VMcwbh_Dd7fDR2nwHMHHUsMPP0,4355
7
+ dagmc_h5m_file_inspector-0.6.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
8
+ dagmc_h5m_file_inspector-0.6.0.dist-info/entry_points.txt,sha256=Ae_DrADNifqSNi5IWc19B7HM8qSO6pjTfjWRD0HR8fM,77
9
+ dagmc_h5m_file_inspector-0.6.0.dist-info/top_level.txt,sha256=Cc4PPWyoZDecf8ylWv_giWxZmFZx1I7m68uq7-ZZUUM,25
10
+ dagmc_h5m_file_inspector-0.6.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ inspect-dagmc-h5m-file = dagmc_h5m_file_inspector.cli:main
@@ -1,89 +0,0 @@
1
-
2
- #!/usr/bin/python
3
-
4
- import argparse
5
- import json
6
- import pprint
7
- from pathlib import Path
8
-
9
- from dagmc_h5m_file_inspector import get_volumes_from_h5m, get_materials_from_h5m, get_volumes_and_materials_from_h5m
10
-
11
-
12
- if __name__ == '__main__':
13
-
14
- parser = argparse.ArgumentParser()
15
-
16
- parser.add_argument(
17
- '-i', '--input',
18
- type=str,
19
- help='The filename of the h5m file',
20
- required=True
21
- )
22
-
23
- parser.add_argument(
24
- '-v', '--volumes',
25
- help='Returns volume ids from a h5m file',
26
- required=False,
27
- action='store_true'
28
- )
29
-
30
- parser.add_argument(
31
- '-m', '--materials',
32
- help='Returns materials tags from a h5m file',
33
- required=False,
34
- action='store_true'
35
- )
36
-
37
- parser.add_argument(
38
- '-b', '--both',
39
- help='Returns volume ids with materials tags from a h5m file',
40
- required=False,
41
- action='store_true'
42
- )
43
-
44
- parser.add_argument(
45
- '-o', '--output',
46
- type=str,
47
- default='inspector_results.txt',
48
- help='Returns volume ids with materials tags from a h5m file',
49
- required=False,
50
- )
51
-
52
- args = parser.parse_args()
53
-
54
- volumes = None
55
- if args.volumes:
56
- volumes = get_volumes_from_h5m(filename = args.input)
57
- print(f'\nVolume IDs ={volumes}')
58
-
59
- materials = None
60
- if args.materials:
61
- materials = get_materials_from_h5m(filename = args.input)
62
- print(f'\nMaterial tags ={materials}')
63
-
64
- both = None
65
- if args.both:
66
- both = get_volumes_and_materials_from_h5m(filename = args.input)
67
- pp = pprint.PrettyPrinter(indent=4)
68
- print('\nVolume IDs and material tags=')
69
- pp.pprint(both)
70
-
71
-
72
- if args.volumes == False and args.materials == False and args.both == False:
73
- print(f'\nNo inspection of {args.input} carried out as outputs were not '
74
- 'specified. Output options include -v, --volume, -m, --materials'
75
- ', -b, --both')
76
- elif args.output:
77
- with open(args.output, 'w') as output_file:
78
- text_to_write = {}
79
- if volumes is not None:
80
- text_to_write['volumes']=volumes
81
- if materials is not None:
82
- text_to_write['materials']=materials
83
- if both is not None:
84
- text_to_write['both']=both
85
- print(f'writing file {args.output}')
86
- json.dump(text_to_write, output_file, indent=4)
87
-
88
-
89
- print(f'\n')
@@ -1,138 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dagmc-h5m-file-inspector
3
- Version: 0.4.3
4
- Summary: Extracts information from DAGMC h5m files including volumes number, material tags
5
- Home-page: https://github.com/fusion-energy/dagmc_h5m_file_inspector
6
- Author: The dagmc_h5m_file_inspector Development Team
7
- Author-email: mail@jshimwell.com
8
- License: MIT
9
- Project-URL: Source, https://github.com/fusion-energy/dagmc_h5m_file_inspector
10
- Project-URL: Tracker, https://github.com/fusion-energy/dagmc_h5m_file_inspector/issues
11
- Platform: UNKNOWN
12
- Classifier: Natural Language :: English
13
- Classifier: Topic :: Scientific/Engineering
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: 3.7
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: License :: OSI Approved :: MIT License
20
- Classifier: Operating System :: OS Independent
21
- Requires-Python: >=3.6
22
- Description-Content-Type: text/markdown
23
- License-File: LICENSE.txt
24
- Provides-Extra: tests
25
- Requires-Dist: pytest (>=5.4.3) ; extra == 'tests'
26
- Requires-Dist: requests ; extra == 'tests'
27
- Requires-Dist: pytest-cov ; extra == 'tests'
28
-
29
-
30
- [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
31
-
32
- [![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)
33
-
34
- [![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)
35
-
36
- [![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)
37
- [![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/)
38
-
39
- # dagmc-h5m-file-inspector
40
-
41
- A minimal Python package that finds the volume ids and the material tags in a
42
- DAGMC h5m file.
43
-
44
-
45
- # Installation (Conda)
46
-
47
- The dagmc-h5m-file-inspector package can be installed with a single conda
48
- install terminal command.
49
-
50
- ```bash
51
- conda install -c fusion-energy -c conda-forge dagmc_h5m_file_inspector
52
- ```
53
-
54
- # Installation (Conda + Pip)
55
-
56
- The dagmc-h5m-file-inspector package requires pymoab which can be installed
57
- alongside Moab with a conda install command. Moab is not avialable on pip,
58
- however it can be installed with Conda.
59
-
60
- ```bash
61
- conda install -c conda-forge moab
62
-
63
- pip install dagmc-h5m-file-inspector
64
- ```
65
-
66
-
67
- # Python API Usage
68
-
69
- Finding the volume IDs in a DAGMC h5m file.
70
-
71
- ```python
72
- import dagmc_h5m_file_inspector as di
73
-
74
- di.get_volumes_from_h5m("dagmc.h5m")
75
-
76
- >>> [1, 2]
77
- ```
78
-
79
- Finding the material tags in a DAGMC h5m file.
80
-
81
- ```python
82
- import dagmc_h5m_file_inspector as di
83
-
84
- di.get_materials_from_h5m("dagmc.h5m")
85
-
86
- >>> ['steel', 'graveyard']
87
- ```
88
-
89
- Finding the volume IDs with their materials present in a DAGMC h5m file.
90
-
91
- ```python
92
- import dagmc_h5m_file_inspector as di
93
-
94
- di.get_volumes_and_materials_from_h5m("dagmc.h5m")
95
-
96
- >>> {1: 'steel', 2: 'graveyard'}
97
- ```
98
-
99
- # Command line tool usage
100
-
101
- The options for the command line tool can be obtained with ```inspect-dagmc-h5m-file --help```
102
-
103
- Print the volume IDs present in a dagmc h5m file to the terminal
104
-
105
- ```
106
- inspect-dagmc-h5m-file -i dagmc.h5m -v
107
- >>> Volume IDs =[1, 2]
108
- ```
109
-
110
- Print the material tags present in a dagmc h5m file to the terminal
111
-
112
- ```bash
113
- inspect-dagmc-h5m-file -i dagmc.h5m -m
114
- >>> Material tags =['steel', 'graveyard']
115
- ```
116
-
117
- Print the volume IDs and materials present in a dagmc h5m file to the terminal
118
-
119
- ```bash
120
- inspect-dagmc-h5m-file -i dagmc.h5m -b
121
- >>> Volume IDs and material tags=
122
- { 1: 'steel',
123
- 2: 'graveyard'}
124
- ```
125
-
126
- Write the volume IDs and materials present in a dagmc h5m file to a txt file
127
-
128
- ```bash
129
- inspect-dagmc-h5m-file -i dagmc.h5m -b -o output.txt
130
- >>> writing file output.txt
131
- ```
132
-
133
-
134
- # Aknowledgements
135
-
136
- This package is based on a [Python script](https://gist.github.com/gonuke/c36e327e399c7a685cd315c738121c9a) by @gonuke
137
-
138
-
@@ -1,9 +0,0 @@
1
- dagmc_h5m_file_inspector/__init__.py,sha256=dOGqFI0aZYEll86_fIbBLTLQ7Ds-OiLfdDlyc5ujZwI,133
2
- dagmc_h5m_file_inspector/_version.py,sha256=qx7r5dCvqUZNACmroQpBhx84w6eihr1TEOgKC1H7IbY,142
3
- dagmc_h5m_file_inspector/core.py,sha256=qOqsbDkp4LcminKQMItzW6gnChFSVlq971zU5WIjJIc,4032
4
- dagmc_h5m_file_inspector-0.4.3.data/scripts/inspect-dagmc-h5m-file,sha256=uzUfqnru8-8oxZMYEs5UvUAoRIu46GaREkiA6HKhXN4,2462
5
- dagmc_h5m_file_inspector-0.4.3.dist-info/LICENSE.txt,sha256=UXVi860HD1Sxktd5fnU_1rn9Y77JxHF_jM1muoihSJc,1070
6
- dagmc_h5m_file_inspector-0.4.3.dist-info/METADATA,sha256=B-4IIeoCNvhtgzK2y2ay9Pfnyt91Rv5JBPzaQQ-4uFQ,4266
7
- dagmc_h5m_file_inspector-0.4.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
8
- dagmc_h5m_file_inspector-0.4.3.dist-info/top_level.txt,sha256=Cc4PPWyoZDecf8ylWv_giWxZmFZx1I7m68uq7-ZZUUM,25
9
- dagmc_h5m_file_inspector-0.4.3.dist-info/RECORD,,