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.
@@ -1,3 +1,7 @@
1
1
  from .core import get_volumes_from_h5m
2
2
  from .core import get_materials_from_h5m
3
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
@@ -1,5 +1,34 @@
1
- # coding: utf-8
2
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
3
2
  # don't change, don't track in version control
4
- version = '0.4.3'
5
- version_tuple = (0, 4, 3)
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 = None
@@ -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()