Package: dagmc-geometry-slice-plotter
A minimal Python package that produces slice plots through h5m DAGMC geometry filesInstallationpipinstalldagmc_geometry_slice_plotterGraphical User Interface UsageOnce installed you will be able to launch a browser based GUI from the terminal
with the command ...dagmc_geometry_slice_plotterPython API UsageThese examples assume you have a h5m file calleddagmc.h5min the same
folder that the Python script is being run from.Theplot_axis_slicemethod allows simple axis aligned plots to be made
with minimal user effort.Create a plot of a slice through the geometry perpendicular to the Z axis and
default settings elsewhere. This will slice through the the center of the
geometry asplane_originhas not been specified in this example.fromdagmc_geometry_slice_plotterimportplot_axis_sliceplot=plot_axis_slice(dagmc_file_or_trimesh_object='dagmc.h5m',view_direction='z',)plot.show()Create a plot of a slice through the geometry perpendicular to the Z axis,
offset by 200cm and with default settings elsewhere.fromdagmc_geometry_slice_plotterimportplot_axis_sliceplot=plot_axis_slice(dagmc_file_or_trimesh_object='dagmc.h5m',plane_origin=[0,0,200],view_direction='z')plot.show()Theplot_slicefunction allows more control over the plot as it allows
arbitrary plane normals so that off axis slices can be made and allows the plot
to be rotated.Create a plot of a slice through the geometry perpendicular to the Y axis, with
a rotation of 45 degrees and with default settings elsewhere. Also saves the
plot with a high resolution (DPI)fromdagmc_geometry_slice_plotterimportplot_sliceplot=plot_slice(dagmc_file_or_trimesh_object='dagmc.h5m',plane_normal=[0,1,0],rotate_plot=45,)plot.savefig('example_3_slice.png',dpi=600)Saves a png image of a plot of a slice through the geometry perpendicular to
the X axis and and with an offset in the x axis.fromdagmc_geometry_slice_plotterimportplot_sliceplot=plot_slice(dagmc_file_or_trimesh_object='dagmc.h5m',plane_normal=[1,0,0],plane_origin=[10,0,0],rotate_plot=270,)plot.savefig('example_4_slice.png')DAGMC files can also be made using packages likecad_to_dagmcorstl_to_h5m. This example uses CadQuery to make an STL file then converts the STL file to a DAGMC h5m file and plots a slice through the geometryCustom plotsYou can also use the package to access the the coordinates and lines that make
up the outline and then plot these lines with your own MatplotLib script or
other plotting package.This example makes use of low level functionality in the package to extract the
coordinates and lines then plot them in MatPlotLib. This offers users full
customization of how the plots appear and also allows the plots to be combined
with other types of plots such asfromdagmc_geometry_slice_plotterimportget_slice_coordinatesimportmatplotlib.pyplotaspltdata=get_slice_coordinates(dagmc_file_or_trimesh_object="dagmc.h5m",plane_origin=[0,0,200],plane_normal=[0,0,1],)plt.axes().set_aspect("equal")# scales the x y axis 1:1forxyindata:plt.plot(*xy,color="black",linewidth=1)plt.savefig("example_7_slice.png")Related packagesThis package is used by theopenmc_plotPython package which has a web deployed version atxsplot.comThis package can also be used together with theopenmc_geometry_plotPython package to combine outline slice plots of DAGMC geometry with colored areas for materials or cellsThis package can also be used together with theregular_mesh_plotterPython package to combine outline
slice plots with regular mesh tally results and produce images like below.