|
1 | | -from RadFiled3D.RadFiled3D import FieldStore, HistogramVoxel |
| 1 | +from RadFiled3D.RadFiled3D import FieldShape |
2 | 2 | from plotly import graph_objects as go |
3 | 3 | import numpy |
4 | 4 | import sys |
5 | 5 | from RadFiled3D.metadata.v1 import Metadata |
| 6 | +from RadFiled3D.utils import FieldStore |
6 | 7 |
|
7 | 8 |
|
8 | 9 | # This file demonstrates how to load a radiation field files metadata and which information can be extracted from it. |
9 | 10 |
|
10 | 11 | radiation_file = sys.argv[1] |
11 | 12 |
|
12 | | -metadata: Metadata = FieldStore.load_metadata(radiation_file) |
13 | | -energy_eV = metadata.get_header().simulation.tube.max_energy_eV |
| 13 | +metadata: Metadata = FieldStore.peek_metadata(radiation_file) |
| 14 | +metadata = FieldStore.load_metadata(radiation_file) |
| 15 | +energy_eV = metadata.simulation.tube.max_energy_eV |
14 | 16 | print(f"Energy: {energy_eV / 1e3} keV") |
15 | | -direction = metadata.get_header().simulation.tube.radiation_direction |
| 17 | +direction = metadata.simulation.tube.radiation_direction |
16 | 18 | print(f"Direction: {direction}") |
17 | | -origin = metadata.get_header().simulation.tube.radiation_origin |
| 19 | +origin = metadata.simulation.tube.radiation_origin |
18 | 20 | print(f"Origin: {origin}") |
19 | | -geometry = metadata.get_header().simulation.geometry |
| 21 | +geometry = metadata.simulation.geometry |
20 | 22 | print(f"Geometry: {geometry}") |
21 | | -particles = metadata.get_header().simulation.primary_particle_count |
| 23 | +particles = metadata.simulation.primary_particle_count |
22 | 24 | print(f"Particles: {particles}") |
23 | 25 | dyn_data_keys = metadata.get_dynamic_metadata_keys() |
24 | 26 | print(f"Dynamic metadata keys: {dyn_data_keys}") |
25 | 27 | simulation_duration_s = metadata.get_dynamic_metadata("simulation_duration_s").get_data() |
26 | 28 | print(f"Simulation duration: {simulation_duration_s} s") |
27 | | -tube_spectrum: HistogramVoxel = metadata.get_dynamic_metadata("tube_spectrum") |
28 | | -print(f"Tube spectrum: {tube_spectrum.get_histogram()}") |
| 29 | +tube_spectrum = metadata.simulation.tube.spectrum |
| 30 | +print(f"Tube spectrum: {tube_spectrum}") |
| 31 | +shape_type = metadata.simulation.tube.field_shape |
| 32 | +print(f"Field shape type: {shape_type}") |
| 33 | +if shape_type == FieldShape.CONE: |
| 34 | + opening_angle_deg = metadata.simulation.tube.opening_angle_deg |
| 35 | + print(f"Opening angle: {opening_angle_deg} deg") |
| 36 | +elif shape_type == FieldShape.RECTANGLE: |
| 37 | + extends_at_origin = metadata.simulation.tube.field_rect_dimensions_m |
| 38 | + print(f"Field extends at origin: {extends_at_origin} m") |
| 39 | +elif shape_type == FieldShape.ELLIPSIS: |
| 40 | + ellipsis_opening_angles = metadata.simulation.tube.field_ellipsis_opening_angles_deg |
| 41 | + print(f"Field ellipsis opening angles: {ellipsis_opening_angles} deg") |
| 42 | +else: |
| 43 | + print("Unknown field shape type") |
29 | 44 |
|
30 | 45 |
|
31 | 46 | # plot tube spectrum |
|
0 commit comments