dagmc-geometry-slice-plotter


Namedagmc-geometry-slice-plotter JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryA minimal Python package for creating plots of slices through DAGMC geometry
upload_time2023-03-20 14:38:17
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2021 Fusion Energy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords dagmc geometry plot slice
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)

[![CI with install](https://github.com/fusion-energy/dagmc_geometry_slice_plotter/actions/workflows/ci_with_install.yml/badge.svg?branch=develop)](https://github.com/fusion-energy/dagmc_geometry_slice_plotter/actions/workflows/ci_with_install.yml)

[![PyPI](https://img.shields.io/pypi/v/dagmc-geometry-slice-plotter?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/dagmc-geometry-slice-plotter/)

[![codecov](https://codecov.io/gh/fusion-energy/dagmc_geometry_slice_plotter/branch/main/graph/badge.svg?token=Dm3sNp4q8X)](https://codecov.io/gh/fusion-energy/dagmc_geometry_slice_plotter)

A minimal Python package that produces slice plots through h5m DAGMC geometry files

# Installation

```bash
pip install dagmc_geometry_slice_plotter
```

# Graphical User Interface Usage

Once installed you will be able to launch a browser based GUI from the terminal
with the command ...

```bash
dagmc_geometry_slice_plotter
```

# Python API Usage

These examples assume you have a h5m file called ```dagmc.h5m``` in the same
folder that the Python script is being run from.

The ```plot_axis_slice``` method 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 as ```plane_origin``` has not been specified in this example.

```python
from dagmc_geometry_slice_plotter import plot_axis_slice

plot = plot_axis_slice(
    dagmc_file_or_trimesh_object='dagmc.h5m',
    view_direction='z',
)

plot.show()
```
![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321345-9187aa57-c3bc-4940-ae28-1237df394eba.png)

Create a plot of a slice through the geometry perpendicular to the Z axis,
offset by 200cm and with default settings elsewhere.
```python
from dagmc_geometry_slice_plotter import plot_axis_slice

plot = plot_axis_slice(
    dagmc_file_or_trimesh_object='dagmc.h5m',
    plane_origin=[0, 0, 200],
    view_direction='z'
)

plot.show()
```
![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321353-707bf553-1255-4a87-a3b9-d97aa3ecb67b.png)

The ```plot_slice``` function 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)
```python
from dagmc_geometry_slice_plotter import plot_slice

plot = 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)
```
![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321358-194162d4-8d42-4090-811e-0dd3768a328d.png)

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.
```python
from dagmc_geometry_slice_plotter import plot_slice

plot = 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 slice plot](https://user-images.githubusercontent.com/8583900/138321363-0e7604b3-74eb-44e8-8aa2-9586c008b40d.png)

DAGMC files can also be made using packages like [cad_to_dagmc](https://github.com/fusion-energy/cad_to_dagmc) or [stl_to_h5m](https://github.com/fusion-energy/stl_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 geometry  

# Custom plots

You 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 as 

```python
from dagmc_geometry_slice_plotter import get_slice_coordinates
import matplotlib.pyplot as plt

data = 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:1

for xy in data:
    plt.plot(*xy, color="black", linewidth=1)

plt.savefig("example_7_slice.png")
```

# Related packages

- This package is used by the [openmc_plot](https://github.com/fusion-energy/openmc_plot) Python package which has a web deployed version at [xsplot.com](http://www.xsplot.com)


- This package can also be used together with the [openmc_geometry_plot](https://github.com/fusion-energy/openmc_geometry_plot) Python package to combine outline slice plots of DAGMC geometry with colored areas for materials or cells

- This package can also be used together with the [regular_mesh_plotter](https://github.com/fusion-energy/regular_mesh_plotter) Python package to combine outline
slice plots with regular mesh tally results and produce images like below.

![paramak plot openmc regular mesh tally](https://user-images.githubusercontent.com/8583900/138322007-daf1eb6f-ca42-4d9c-9581-8dbc9da94fe5.png)

![paramak plot openmc regular mesh tally](https://user-images.githubusercontent.com/8583900/138322010-c7ca7ced-1a37-4af5-b7a4-7d5853a2b9bb.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dagmc-geometry-slice-plotter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "dagmc,geometry,plot,slice",
    "author": "",
    "author_email": "Jonathan Shimwell <mail@jshimwell.com>",
    "download_url": "https://files.pythonhosted.org/packages/ed/37/49a0c7d6b81ef588c938a8331c5f4440378b57b0b5440badfd618ab8834b/dagmc_geometry_slice_plotter-0.3.1.tar.gz",
    "platform": null,
    "description": "[![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)\n\n[![CI with install](https://github.com/fusion-energy/dagmc_geometry_slice_plotter/actions/workflows/ci_with_install.yml/badge.svg?branch=develop)](https://github.com/fusion-energy/dagmc_geometry_slice_plotter/actions/workflows/ci_with_install.yml)\n\n[![PyPI](https://img.shields.io/pypi/v/dagmc-geometry-slice-plotter?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/dagmc-geometry-slice-plotter/)\n\n[![codecov](https://codecov.io/gh/fusion-energy/dagmc_geometry_slice_plotter/branch/main/graph/badge.svg?token=Dm3sNp4q8X)](https://codecov.io/gh/fusion-energy/dagmc_geometry_slice_plotter)\n\nA minimal Python package that produces slice plots through h5m DAGMC geometry files\n\n# Installation\n\n```bash\npip install dagmc_geometry_slice_plotter\n```\n\n# Graphical User Interface Usage\n\nOnce installed you will be able to launch a browser based GUI from the terminal\nwith the command ...\n\n```bash\ndagmc_geometry_slice_plotter\n```\n\n# Python API Usage\n\nThese examples assume you have a h5m file called ```dagmc.h5m``` in the same\nfolder that the Python script is being run from.\n\nThe ```plot_axis_slice``` method allows simple axis aligned plots to be made\nwith minimal user effort.\n\nCreate a plot of a slice through the geometry perpendicular to the Z axis and\ndefault settings elsewhere. This will slice through the the center of the\ngeometry as ```plane_origin``` has not been specified in this example.\n\n```python\nfrom dagmc_geometry_slice_plotter import plot_axis_slice\n\nplot = plot_axis_slice(\n    dagmc_file_or_trimesh_object='dagmc.h5m',\n    view_direction='z',\n)\n\nplot.show()\n```\n![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321345-9187aa57-c3bc-4940-ae28-1237df394eba.png)\n\nCreate a plot of a slice through the geometry perpendicular to the Z axis,\noffset by 200cm and with default settings elsewhere.\n```python\nfrom dagmc_geometry_slice_plotter import plot_axis_slice\n\nplot = plot_axis_slice(\n    dagmc_file_or_trimesh_object='dagmc.h5m',\n    plane_origin=[0, 0, 200],\n    view_direction='z'\n)\n\nplot.show()\n```\n![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321353-707bf553-1255-4a87-a3b9-d97aa3ecb67b.png)\n\nThe ```plot_slice``` function allows more control over the plot as it allows\narbitrary plane normals so that off axis slices can be made and allows the plot\nto be rotated.\n\nCreate a plot of a slice through the geometry perpendicular to the Y axis, with\na rotation of 45 degrees and with default settings elsewhere. Also saves the\nplot with a high resolution (DPI)\n```python\nfrom dagmc_geometry_slice_plotter import plot_slice\n\nplot = plot_slice(\n    dagmc_file_or_trimesh_object='dagmc.h5m',\n    plane_normal=[0, 1, 0],\n    rotate_plot=45,\n)\n\nplot.savefig('example_3_slice.png', dpi=600)\n```\n![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321358-194162d4-8d42-4090-811e-0dd3768a328d.png)\n\nSaves a png image of a plot of a slice through the geometry perpendicular to\nthe X axis and and with an offset in the x axis.\n```python\nfrom dagmc_geometry_slice_plotter import plot_slice\n\nplot = plot_slice(\n    dagmc_file_or_trimesh_object='dagmc.h5m',\n    plane_normal = [1, 0, 0],\n    plane_origin=[10, 0, 0],\n    rotate_plot=270,\n)\n\nplot.savefig('example_4_slice.png')\n```\n![dagmc slice plot](https://user-images.githubusercontent.com/8583900/138321363-0e7604b3-74eb-44e8-8aa2-9586c008b40d.png)\n\nDAGMC files can also be made using packages like [cad_to_dagmc](https://github.com/fusion-energy/cad_to_dagmc) or [stl_to_h5m](https://github.com/fusion-energy/stl_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 geometry  \n\n# Custom plots\n\nYou can also use the package to access the the coordinates and lines that make\nup the outline and then plot these lines with your own MatplotLib script or\nother plotting package.\n\nThis example makes use of low level functionality in the package to extract the\ncoordinates and lines then plot them in MatPlotLib. This offers users full\ncustomization of how the plots appear and also allows the plots to be combined\nwith other types of plots such as \n\n```python\nfrom dagmc_geometry_slice_plotter import get_slice_coordinates\nimport matplotlib.pyplot as plt\n\ndata = get_slice_coordinates(\n    dagmc_file_or_trimesh_object=\"dagmc.h5m\",\n    plane_origin=[0, 0, 200],\n    plane_normal=[0, 0, 1],\n)\n\nplt.axes().set_aspect(\"equal\")  # scales the x y axis 1:1\n\nfor xy in data:\n    plt.plot(*xy, color=\"black\", linewidth=1)\n\nplt.savefig(\"example_7_slice.png\")\n```\n\n# Related packages\n\n- This package is used by the [openmc_plot](https://github.com/fusion-energy/openmc_plot) Python package which has a web deployed version at [xsplot.com](http://www.xsplot.com)\n\n\n- This package can also be used together with the [openmc_geometry_plot](https://github.com/fusion-energy/openmc_geometry_plot) Python package to combine outline slice plots of DAGMC geometry with colored areas for materials or cells\n\n- This package can also be used together with the [regular_mesh_plotter](https://github.com/fusion-energy/regular_mesh_plotter) Python package to combine outline\nslice plots with regular mesh tally results and produce images like below.\n\n![paramak plot openmc regular mesh tally](https://user-images.githubusercontent.com/8583900/138322007-daf1eb6f-ca42-4d9c-9581-8dbc9da94fe5.png)\n\n![paramak plot openmc regular mesh tally](https://user-images.githubusercontent.com/8583900/138322010-c7ca7ced-1a37-4af5-b7a4-7d5853a2b9bb.png)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 Fusion Energy  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A minimal Python package for creating plots of slices through DAGMC geometry",
    "version": "0.3.1",
    "split_keywords": [
        "dagmc",
        "geometry",
        "plot",
        "slice"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db888d851b2bbc99d2f4ef75ec995d47d63907a5f5fc9a9ed0feed9174e98c19",
                "md5": "a1661f66aa9751e92da6fc0680ea4dd3",
                "sha256": "b52e208c30704e9185aafa13dd80a1e8580235b1485cd6f0e778a0f567d6f71b"
            },
            "downloads": -1,
            "filename": "dagmc_geometry_slice_plotter-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1661f66aa9751e92da6fc0680ea4dd3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10757,
            "upload_time": "2023-03-20T14:38:16",
            "upload_time_iso_8601": "2023-03-20T14:38:16.020294Z",
            "url": "https://files.pythonhosted.org/packages/db/88/8d851b2bbc99d2f4ef75ec995d47d63907a5f5fc9a9ed0feed9174e98c19/dagmc_geometry_slice_plotter-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed3749a0c7d6b81ef588c938a8331c5f4440378b57b0b5440badfd618ab8834b",
                "md5": "6193b01876f97522ea58b51a87c4078c",
                "sha256": "0723faf6b64d03a893e070fcaff85f948ed0a16e2719feffefe35177ce52f395"
            },
            "downloads": -1,
            "filename": "dagmc_geometry_slice_plotter-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6193b01876f97522ea58b51a87c4078c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1081852,
            "upload_time": "2023-03-20T14:38:17",
            "upload_time_iso_8601": "2023-03-20T14:38:17.291149Z",
            "url": "https://files.pythonhosted.org/packages/ed/37/49a0c7d6b81ef588c938a8331c5f4440378b57b0b5440badfd618ab8834b/dagmc_geometry_slice_plotter-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-20 14:38:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "dagmc-geometry-slice-plotter"
}
        
Elapsed time: 0.28110s