maggie 0.2.0__tar.gz
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.
- maggie-0.2.0/LICENSE +21 -0
- maggie-0.2.0/PKG-INFO +216 -0
- maggie-0.2.0/README.md +183 -0
- maggie-0.2.0/pyproject.toml +60 -0
- maggie-0.2.0/setup.cfg +4 -0
- maggie-0.2.0/src/maggie/__init__.py +20 -0
- maggie-0.2.0/src/maggie/__main__.py +8 -0
- maggie-0.2.0/src/maggie/app.py +192 -0
- maggie-0.2.0/src/maggie/constants.py +6 -0
- maggie-0.2.0/src/maggie/core/__init__.py +7 -0
- maggie-0.2.0/src/maggie/core/dims.py +90 -0
- maggie-0.2.0/src/maggie/core/field.py +239 -0
- maggie-0.2.0/src/maggie/core/mesh.py +72 -0
- maggie-0.2.0/src/maggie/core/session.py +262 -0
- maggie-0.2.0/src/maggie/core/views.py +136 -0
- maggie-0.2.0/src/maggie/core/xs.py +175 -0
- maggie-0.2.0/src/maggie/gui/__init__.py +7 -0
- maggie-0.2.0/src/maggie/gui/field_view.py +256 -0
- maggie-0.2.0/src/maggie/gui/load_window.py +432 -0
- maggie-0.2.0/src/maggie/gui/theme.py +16 -0
- maggie-0.2.0/src/maggie/gui/viewer_window.py +55 -0
- maggie-0.2.0/src/maggie/gui/widgets.py +143 -0
- maggie-0.2.0/src/maggie/io/__init__.py +23 -0
- maggie-0.2.0/src/maggie/io/base.py +149 -0
- maggie-0.2.0/src/maggie/io/presets.py +76 -0
- maggie-0.2.0/src/maggie/io/readers/__init__.py +7 -0
- maggie-0.2.0/src/maggie/io/readers/arrays.py +222 -0
- maggie-0.2.0/src/maggie/io/readers/ndiffusion.py +95 -0
- maggie-0.2.0/src/maggie/io/schema.py +207 -0
- maggie-0.2.0/src/maggie/plot.py +233 -0
- maggie-0.2.0/src/maggie.egg-info/PKG-INFO +216 -0
- maggie-0.2.0/src/maggie.egg-info/SOURCES.txt +40 -0
- maggie-0.2.0/src/maggie.egg-info/dependency_links.txt +1 -0
- maggie-0.2.0/src/maggie.egg-info/entry_points.txt +5 -0
- maggie-0.2.0/src/maggie.egg-info/requires.txt +8 -0
- maggie-0.2.0/src/maggie.egg-info/top_level.txt +1 -0
- maggie-0.2.0/tests/test_app.py +11 -0
- maggie-0.2.0/tests/test_field.py +119 -0
- maggie-0.2.0/tests/test_gui.py +115 -0
- maggie-0.2.0/tests/test_plot.py +87 -0
- maggie-0.2.0/tests/test_readers.py +143 -0
- maggie-0.2.0/tests/test_session.py +185 -0
maggie-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Whewell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
maggie-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maggie
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Mesh-Agnostic Graphics for Group-wise Iteration and Evolution
|
|
5
|
+
Author: Ben Whewell
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bwhewe-13/maggie
|
|
8
|
+
Project-URL: Issues, https://github.com/bwhewe-13/maggie/issues
|
|
9
|
+
Project-URL: Releases, https://github.com/bwhewe-13/maggie/releases
|
|
10
|
+
Keywords: neutron transport,neutron diffusion,multigroup,scalar flux,reaction rates,visualization,nuclear engineering
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: PySide6>=6.5
|
|
26
|
+
Requires-Dist: matplotlib>=3.7
|
|
27
|
+
Requires-Dist: numpy>=1.24
|
|
28
|
+
Requires-Dist: h5py>=3.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-qt>=4.2; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# MAGGIE
|
|
35
|
+
Mesh-Agnostic Graphics for Group-wise Iteration and Evolution
|
|
36
|
+
|
|
37
|
+
Load and plot multigroup neutron flux, and the scattering and fission rate
|
|
38
|
+
densities computed from it, from transport and diffusion codes. MAGGIE
|
|
39
|
+
currently reads output from ants, discrete1 and NeutronDiffusion, plus any
|
|
40
|
+
code that saves plain arrays.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install maggie
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
MAGGIE needs Python 3.11-3.14. Standalone executables that need no Python
|
|
49
|
+
are attached to each [GitHub Release](https://github.com/bwhewe-13/maggie/releases)
|
|
50
|
+
(see Download below).
|
|
51
|
+
|
|
52
|
+
Start the viewer with `maggie` (or `python -m maggie`).
|
|
53
|
+
|
|
54
|
+
## Roadmap
|
|
55
|
+
|
|
56
|
+
1. **ants, discrete1, NeutronDiffusion - static.** Load screen, viewer tabs
|
|
57
|
+
for flux and scattering/fission rate densities. *(done)*
|
|
58
|
+
2. **ants, discrete1, NeutronDiffusion - live.** Watch a running solver and
|
|
59
|
+
update the plots as time steps / iterations arrive.
|
|
60
|
+
3. **Other transport codes.** MC/DC, OpenMC, OpenMOC and OpenSN readers will
|
|
61
|
+
be added once steps 1-2 are settled.
|
|
62
|
+
|
|
63
|
+
## Using the app
|
|
64
|
+
|
|
65
|
+
`maggie` opens the **load screen**:
|
|
66
|
+
|
|
67
|
+
- **Problem** - 1D, 2D or 3D.
|
|
68
|
+
- **Flux files** - one or more; several files are separate runs, overlaid on
|
|
69
|
+
1-D plots. Bare arrays (ants, discrete1, NeutronDiffusion `np.save`) need an
|
|
70
|
+
axis order, e.g. `time, x, group`; the list suggests each code's layouts.
|
|
71
|
+
- **Cross sections** (optional) - scattering, fission and a material map
|
|
72
|
+
(ants' `medium_map`). Picking an ants-style `.npz` for one fills the others
|
|
73
|
+
from the same file. Matrices are `sigma[to, from]` unless set otherwise.
|
|
74
|
+
- **Discretizations** - energy, x/y/z and time grids: from the flux file,
|
|
75
|
+
uniform (space and time), or loaded from a file (edges or centres).
|
|
76
|
+
|
|
77
|
+
**Load** opens the **viewer**, with tabs for flux, scattering rate density
|
|
78
|
+
and fission rate density (`R_g = Sigma_g phi_g`, a `[to, from]` matrix summed
|
|
79
|
+
over `to`). Each tab picks the dataset, group (or the sum), time step, a
|
|
80
|
+
spatial or energy-spectrum view, and for 3-D the plane and slice. File > Load
|
|
81
|
+
new data goes back to the load screen with the same choices.
|
|
82
|
+
|
|
83
|
+
Everything on the load screen can be given on the command line:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
maggie flux.npy --dim 1 --axes "time,x,group" \
|
|
87
|
+
--scatter xs.npz:xs_scatter --fission xs.npz:xs_fission --map xs.npz:medium_map \
|
|
88
|
+
--x-grid edges_x.npy --energy-grid edges_g.npy --view # --view skips the load screen
|
|
89
|
+
maggie info result.npz # what MAGGIE finds in a file
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Supported files
|
|
93
|
+
|
|
94
|
+
| Source | Files | What MAGGIE gets |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| ants, discrete1 | bare `.npy`/`.npz` (`np.save(flux)`, `np.savez(flux=..., keff=...)`) | axes from a per-code `preset=` or `dims=`; scalars become attributes, `edges_*` arrays become coords |
|
|
97
|
+
| NeutronDiffusion | `.npz` from `ndiffusion.save_result`, or a bare `np.save(flux)` | `(x\|cell, group)`; 2-D split to `(x, y, group)` given edges |
|
|
98
|
+
| MAGGIE schema | `.npz`, `.h5` written by `maggie.io.write_flux` / `save` | named dims, edges, std, mesh, attrs |
|
|
99
|
+
| any other code | bare `.npy`/`.npz`/`.csv`/`.txt`/`.h5` | axes from `dims=` |
|
|
100
|
+
|
|
101
|
+
The reader is picked from the file contents, not only the extension.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import maggie.io as mio
|
|
105
|
+
|
|
106
|
+
flux = mio.load("flux.npy", preset="ants", layout="1D time-dependent") # -> Field
|
|
107
|
+
flux.dims # ('time', 'x', 'group')
|
|
108
|
+
flux.isel(time=-1).sum("group") # reductions keep coords
|
|
109
|
+
|
|
110
|
+
mio.load("flux.npy", dims="T x I x G") # same, naming the axes directly
|
|
111
|
+
mio.entries("result.npz") # what is in a file (no data read)
|
|
112
|
+
mio.load("result.npz", "flux", edges_x=ex, edges_y=ey) # NeutronDiffusion 2-D
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
From the command line, `maggie info FILE [KEY]` shows which readers
|
|
116
|
+
recognise a file, what it holds, and a summary of the loaded field.
|
|
117
|
+
|
|
118
|
+
### Writing MAGGIE files from a solver
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from maggie.io import write_flux
|
|
122
|
+
|
|
123
|
+
write_flux("slab.h5", flux, dims=("time", "x", "group"),
|
|
124
|
+
x=edges_x, group=edges_g, time=times,
|
|
125
|
+
attrs={"code": "ants", "keff": keff})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Coords are bin edges (length n+1) or centres (length n). Dim names:
|
|
129
|
+
`x y z r theta phi cell region group group_out time angle moment mu azi polar`
|
|
130
|
+
(`I`, `G`, `T` and other short forms are accepted).
|
|
131
|
+
|
|
132
|
+
### Plotting from scripts and notebooks
|
|
133
|
+
|
|
134
|
+
`maggie.plot` draws the viewer's plots with matplotlib alone (no Qt window),
|
|
135
|
+
for notebooks or saving figures:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
import maggie
|
|
139
|
+
from maggie.plot import plot
|
|
140
|
+
|
|
141
|
+
flux = maggie.load("flux.npy", preset="ants", layout="1D time-dependent")
|
|
142
|
+
ax = plot(flux) # last step, summed over groups
|
|
143
|
+
plot(flux, group=3, step=0, log=True) # one group, first step
|
|
144
|
+
plot(flux, kind="spectrum", at={"x": 500}) # energy spectrum at cell 500
|
|
145
|
+
plot({"ants": flux, "discrete1": other}) # overlay runs
|
|
146
|
+
ax.figure.savefig("flux.png")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Two spatial axes give a colour map; for 3-D pick the plane and slice with
|
|
150
|
+
`plane=("x", "z"), at={"y": 10}`.
|
|
151
|
+
|
|
152
|
+
## Download
|
|
153
|
+
|
|
154
|
+
Prebuilt executables for Windows, macOS, and Linux are attached to each
|
|
155
|
+
[GitHub Release](https://github.com/bwhewe-13/maggie/releases) (no Python
|
|
156
|
+
install needed).
|
|
157
|
+
|
|
158
|
+
- **Windows**: unzip and run `maggie.exe`. SmartScreen may warn because the
|
|
159
|
+
exe is unsigned — click "More info" → "Run anyway".
|
|
160
|
+
- **macOS**: unzip and open `maggie.app`. The app is unsigned, so Gatekeeper
|
|
161
|
+
blocks the first launch — right-click → Open, or run
|
|
162
|
+
`xattr -dr com.apple.quarantine maggie.app`. Pick the `arm64` zip for
|
|
163
|
+
Apple Silicon or `x64` for Intel.
|
|
164
|
+
- **Linux**: untar and run `./maggie`.
|
|
165
|
+
|
|
166
|
+
The single-file executables self-extract on launch, so the first start takes a
|
|
167
|
+
few seconds.
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
git clone https://github.com/bwhewe-13/maggie.git && cd maggie
|
|
173
|
+
pip install -e ".[dev]" # plus pytest, pytest-qt
|
|
174
|
+
pytest # headless; GUI tests run offscreen
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Releasing
|
|
178
|
+
|
|
179
|
+
1. Set `version` in `pyproject.toml` (e.g. `0.2.1`) and merge to `main`.
|
|
180
|
+
2. Optional dry run: run the **Release** workflow by hand (Actions > Release
|
|
181
|
+
> Run workflow). It builds the package and tests the installed wheel but
|
|
182
|
+
publishes nothing.
|
|
183
|
+
3. Tag and push: `git tag v0.2.1 && git push origin v0.2.1`. The workflow
|
|
184
|
+
checks the tag matches the version, runs the tests, tests the built wheel,
|
|
185
|
+
publishes to PyPI and attaches executables to a GitHub Release.
|
|
186
|
+
|
|
187
|
+
Publishing uses PyPI trusted publishing: on pypi.org the project has a
|
|
188
|
+
publisher for this repository, workflow `release.yml`, environment `pypi`.
|
|
189
|
+
|
|
190
|
+
## Layout
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
src/maggie/
|
|
194
|
+
core/dims.py canonical dimension names + aliases
|
|
195
|
+
core/field.py Field - named-dim array + coords, std, mesh, attrs (no Qt)
|
|
196
|
+
core/mesh.py UnstructuredMesh (CSR cells)
|
|
197
|
+
core/xs.py cross sections -> reaction rate densities
|
|
198
|
+
core/session.py LoadSpec (load-screen choices) -> Session (datasets + rates)
|
|
199
|
+
core/views.py field -> what one plot shows (group/time/slice selection)
|
|
200
|
+
io/base.py Reader interface, registry, detect/entries/load
|
|
201
|
+
io/schema.py MAGGIE file schema: reader + save/write_flux
|
|
202
|
+
io/presets.py axis layouts for bare arrays from ants/discrete1/ndiffusion
|
|
203
|
+
io/readers/ arrays (bare files + presets), ndiffusion
|
|
204
|
+
gui/load_window.py screen 1: files, cross sections, discretizations
|
|
205
|
+
gui/viewer_window.py screen 2: one tab per quantity
|
|
206
|
+
gui/field_view.py controls + matplotlib plot used by each tab
|
|
207
|
+
plot.py matplotlib plots without Qt (used by the viewer tabs)
|
|
208
|
+
app.py command line, window controller (main())
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Extending
|
|
212
|
+
|
|
213
|
+
- **New file format**: subclass `maggie.io.Reader` in `io/readers/`, decorate
|
|
214
|
+
it with `@register`, and import it in `io/readers/__init__.py`. Implement
|
|
215
|
+
`sniff` (0-100 confidence), `entries` (metadata only), and `read` (-> `Field`).
|
|
216
|
+
- **New bare-array code**: add its layouts to `PRESETS` in `io/presets.py`.
|
maggie-0.2.0/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# MAGGIE
|
|
2
|
+
Mesh-Agnostic Graphics for Group-wise Iteration and Evolution
|
|
3
|
+
|
|
4
|
+
Load and plot multigroup neutron flux, and the scattering and fission rate
|
|
5
|
+
densities computed from it, from transport and diffusion codes. MAGGIE
|
|
6
|
+
currently reads output from ants, discrete1 and NeutronDiffusion, plus any
|
|
7
|
+
code that saves plain arrays.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install maggie
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
MAGGIE needs Python 3.11-3.14. Standalone executables that need no Python
|
|
16
|
+
are attached to each [GitHub Release](https://github.com/bwhewe-13/maggie/releases)
|
|
17
|
+
(see Download below).
|
|
18
|
+
|
|
19
|
+
Start the viewer with `maggie` (or `python -m maggie`).
|
|
20
|
+
|
|
21
|
+
## Roadmap
|
|
22
|
+
|
|
23
|
+
1. **ants, discrete1, NeutronDiffusion - static.** Load screen, viewer tabs
|
|
24
|
+
for flux and scattering/fission rate densities. *(done)*
|
|
25
|
+
2. **ants, discrete1, NeutronDiffusion - live.** Watch a running solver and
|
|
26
|
+
update the plots as time steps / iterations arrive.
|
|
27
|
+
3. **Other transport codes.** MC/DC, OpenMC, OpenMOC and OpenSN readers will
|
|
28
|
+
be added once steps 1-2 are settled.
|
|
29
|
+
|
|
30
|
+
## Using the app
|
|
31
|
+
|
|
32
|
+
`maggie` opens the **load screen**:
|
|
33
|
+
|
|
34
|
+
- **Problem** - 1D, 2D or 3D.
|
|
35
|
+
- **Flux files** - one or more; several files are separate runs, overlaid on
|
|
36
|
+
1-D plots. Bare arrays (ants, discrete1, NeutronDiffusion `np.save`) need an
|
|
37
|
+
axis order, e.g. `time, x, group`; the list suggests each code's layouts.
|
|
38
|
+
- **Cross sections** (optional) - scattering, fission and a material map
|
|
39
|
+
(ants' `medium_map`). Picking an ants-style `.npz` for one fills the others
|
|
40
|
+
from the same file. Matrices are `sigma[to, from]` unless set otherwise.
|
|
41
|
+
- **Discretizations** - energy, x/y/z and time grids: from the flux file,
|
|
42
|
+
uniform (space and time), or loaded from a file (edges or centres).
|
|
43
|
+
|
|
44
|
+
**Load** opens the **viewer**, with tabs for flux, scattering rate density
|
|
45
|
+
and fission rate density (`R_g = Sigma_g phi_g`, a `[to, from]` matrix summed
|
|
46
|
+
over `to`). Each tab picks the dataset, group (or the sum), time step, a
|
|
47
|
+
spatial or energy-spectrum view, and for 3-D the plane and slice. File > Load
|
|
48
|
+
new data goes back to the load screen with the same choices.
|
|
49
|
+
|
|
50
|
+
Everything on the load screen can be given on the command line:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
maggie flux.npy --dim 1 --axes "time,x,group" \
|
|
54
|
+
--scatter xs.npz:xs_scatter --fission xs.npz:xs_fission --map xs.npz:medium_map \
|
|
55
|
+
--x-grid edges_x.npy --energy-grid edges_g.npy --view # --view skips the load screen
|
|
56
|
+
maggie info result.npz # what MAGGIE finds in a file
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Supported files
|
|
60
|
+
|
|
61
|
+
| Source | Files | What MAGGIE gets |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| ants, discrete1 | bare `.npy`/`.npz` (`np.save(flux)`, `np.savez(flux=..., keff=...)`) | axes from a per-code `preset=` or `dims=`; scalars become attributes, `edges_*` arrays become coords |
|
|
64
|
+
| NeutronDiffusion | `.npz` from `ndiffusion.save_result`, or a bare `np.save(flux)` | `(x\|cell, group)`; 2-D split to `(x, y, group)` given edges |
|
|
65
|
+
| MAGGIE schema | `.npz`, `.h5` written by `maggie.io.write_flux` / `save` | named dims, edges, std, mesh, attrs |
|
|
66
|
+
| any other code | bare `.npy`/`.npz`/`.csv`/`.txt`/`.h5` | axes from `dims=` |
|
|
67
|
+
|
|
68
|
+
The reader is picked from the file contents, not only the extension.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import maggie.io as mio
|
|
72
|
+
|
|
73
|
+
flux = mio.load("flux.npy", preset="ants", layout="1D time-dependent") # -> Field
|
|
74
|
+
flux.dims # ('time', 'x', 'group')
|
|
75
|
+
flux.isel(time=-1).sum("group") # reductions keep coords
|
|
76
|
+
|
|
77
|
+
mio.load("flux.npy", dims="T x I x G") # same, naming the axes directly
|
|
78
|
+
mio.entries("result.npz") # what is in a file (no data read)
|
|
79
|
+
mio.load("result.npz", "flux", edges_x=ex, edges_y=ey) # NeutronDiffusion 2-D
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
From the command line, `maggie info FILE [KEY]` shows which readers
|
|
83
|
+
recognise a file, what it holds, and a summary of the loaded field.
|
|
84
|
+
|
|
85
|
+
### Writing MAGGIE files from a solver
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from maggie.io import write_flux
|
|
89
|
+
|
|
90
|
+
write_flux("slab.h5", flux, dims=("time", "x", "group"),
|
|
91
|
+
x=edges_x, group=edges_g, time=times,
|
|
92
|
+
attrs={"code": "ants", "keff": keff})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Coords are bin edges (length n+1) or centres (length n). Dim names:
|
|
96
|
+
`x y z r theta phi cell region group group_out time angle moment mu azi polar`
|
|
97
|
+
(`I`, `G`, `T` and other short forms are accepted).
|
|
98
|
+
|
|
99
|
+
### Plotting from scripts and notebooks
|
|
100
|
+
|
|
101
|
+
`maggie.plot` draws the viewer's plots with matplotlib alone (no Qt window),
|
|
102
|
+
for notebooks or saving figures:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
import maggie
|
|
106
|
+
from maggie.plot import plot
|
|
107
|
+
|
|
108
|
+
flux = maggie.load("flux.npy", preset="ants", layout="1D time-dependent")
|
|
109
|
+
ax = plot(flux) # last step, summed over groups
|
|
110
|
+
plot(flux, group=3, step=0, log=True) # one group, first step
|
|
111
|
+
plot(flux, kind="spectrum", at={"x": 500}) # energy spectrum at cell 500
|
|
112
|
+
plot({"ants": flux, "discrete1": other}) # overlay runs
|
|
113
|
+
ax.figure.savefig("flux.png")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Two spatial axes give a colour map; for 3-D pick the plane and slice with
|
|
117
|
+
`plane=("x", "z"), at={"y": 10}`.
|
|
118
|
+
|
|
119
|
+
## Download
|
|
120
|
+
|
|
121
|
+
Prebuilt executables for Windows, macOS, and Linux are attached to each
|
|
122
|
+
[GitHub Release](https://github.com/bwhewe-13/maggie/releases) (no Python
|
|
123
|
+
install needed).
|
|
124
|
+
|
|
125
|
+
- **Windows**: unzip and run `maggie.exe`. SmartScreen may warn because the
|
|
126
|
+
exe is unsigned — click "More info" → "Run anyway".
|
|
127
|
+
- **macOS**: unzip and open `maggie.app`. The app is unsigned, so Gatekeeper
|
|
128
|
+
blocks the first launch — right-click → Open, or run
|
|
129
|
+
`xattr -dr com.apple.quarantine maggie.app`. Pick the `arm64` zip for
|
|
130
|
+
Apple Silicon or `x64` for Intel.
|
|
131
|
+
- **Linux**: untar and run `./maggie`.
|
|
132
|
+
|
|
133
|
+
The single-file executables self-extract on launch, so the first start takes a
|
|
134
|
+
few seconds.
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
git clone https://github.com/bwhewe-13/maggie.git && cd maggie
|
|
140
|
+
pip install -e ".[dev]" # plus pytest, pytest-qt
|
|
141
|
+
pytest # headless; GUI tests run offscreen
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Releasing
|
|
145
|
+
|
|
146
|
+
1. Set `version` in `pyproject.toml` (e.g. `0.2.1`) and merge to `main`.
|
|
147
|
+
2. Optional dry run: run the **Release** workflow by hand (Actions > Release
|
|
148
|
+
> Run workflow). It builds the package and tests the installed wheel but
|
|
149
|
+
publishes nothing.
|
|
150
|
+
3. Tag and push: `git tag v0.2.1 && git push origin v0.2.1`. The workflow
|
|
151
|
+
checks the tag matches the version, runs the tests, tests the built wheel,
|
|
152
|
+
publishes to PyPI and attaches executables to a GitHub Release.
|
|
153
|
+
|
|
154
|
+
Publishing uses PyPI trusted publishing: on pypi.org the project has a
|
|
155
|
+
publisher for this repository, workflow `release.yml`, environment `pypi`.
|
|
156
|
+
|
|
157
|
+
## Layout
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
src/maggie/
|
|
161
|
+
core/dims.py canonical dimension names + aliases
|
|
162
|
+
core/field.py Field - named-dim array + coords, std, mesh, attrs (no Qt)
|
|
163
|
+
core/mesh.py UnstructuredMesh (CSR cells)
|
|
164
|
+
core/xs.py cross sections -> reaction rate densities
|
|
165
|
+
core/session.py LoadSpec (load-screen choices) -> Session (datasets + rates)
|
|
166
|
+
core/views.py field -> what one plot shows (group/time/slice selection)
|
|
167
|
+
io/base.py Reader interface, registry, detect/entries/load
|
|
168
|
+
io/schema.py MAGGIE file schema: reader + save/write_flux
|
|
169
|
+
io/presets.py axis layouts for bare arrays from ants/discrete1/ndiffusion
|
|
170
|
+
io/readers/ arrays (bare files + presets), ndiffusion
|
|
171
|
+
gui/load_window.py screen 1: files, cross sections, discretizations
|
|
172
|
+
gui/viewer_window.py screen 2: one tab per quantity
|
|
173
|
+
gui/field_view.py controls + matplotlib plot used by each tab
|
|
174
|
+
plot.py matplotlib plots without Qt (used by the viewer tabs)
|
|
175
|
+
app.py command line, window controller (main())
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Extending
|
|
179
|
+
|
|
180
|
+
- **New file format**: subclass `maggie.io.Reader` in `io/readers/`, decorate
|
|
181
|
+
it with `@register`, and import it in `io/readers/__init__.py`. Implement
|
|
182
|
+
`sniff` (0-100 confidence), `entries` (metadata only), and `read` (-> `Field`).
|
|
183
|
+
- **New bare-array code**: add its layouts to `PRESETS` in `io/presets.py`.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "maggie"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Mesh-Agnostic Graphics for Group-wise Iteration and Evolution"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Ben Whewell" }]
|
|
14
|
+
keywords = [
|
|
15
|
+
"neutron transport", "neutron diffusion", "multigroup", "scalar flux",
|
|
16
|
+
"reaction rates", "visualization", "nuclear engineering",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"PySide6>=6.5",
|
|
33
|
+
"matplotlib>=3.7",
|
|
34
|
+
"numpy>=1.24",
|
|
35
|
+
"h5py>=3.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=7.0",
|
|
41
|
+
"pytest-qt>=4.2",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/bwhewe-13/maggie"
|
|
46
|
+
Issues = "https://github.com/bwhewe-13/maggie/issues"
|
|
47
|
+
Releases = "https://github.com/bwhewe-13/maggie/releases"
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
maggie = "maggie.app:main"
|
|
51
|
+
|
|
52
|
+
[project.gui-scripts]
|
|
53
|
+
maggie-gui = "maggie.app:main"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
pythonpath = ["src"]
|
maggie-0.2.0/setup.cfg
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""MAGGIE - Mesh-Agnostic Graphics for Group-wise Iteration and Evolution.
|
|
2
|
+
|
|
3
|
+
Visualizes flux from static and time-dependent transport and diffusion codes.
|
|
4
|
+
|
|
5
|
+
Only the Qt-free surface (data model and IO) is exported here, so
|
|
6
|
+
``import maggie`` never pulls in Qt. The GUI lives in ``maggie.gui``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
10
|
+
|
|
11
|
+
from maggie.core import Field, UnstructuredMesh
|
|
12
|
+
from maggie.io import detect, entries, load, save, write_flux
|
|
13
|
+
|
|
14
|
+
try: # single source of truth: the version in pyproject.toml
|
|
15
|
+
__version__ = version("maggie")
|
|
16
|
+
except PackageNotFoundError: # running from a source tree that is not installed
|
|
17
|
+
__version__ = "0+unknown"
|
|
18
|
+
|
|
19
|
+
__all__ = ["Field", "UnstructuredMesh", "detect", "entries", "load", "save",
|
|
20
|
+
"write_flux", "__version__"]
|