Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
shell: bash
run: |
apt update
apt install -y libglu1-mesa
apt install -y libglu1-mesa libglib2.0-0 libfontconfig1
-
uses: actions/checkout@v2
-
Expand Down
13 changes: 11 additions & 2 deletions openmc_plotter/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ def _bin_sort_val(bin):
else:
return bin

for bin in sorted(tally_filter.bins, key=_bin_sort_val):
if isinstance(tally_filter, openmc.EnergyFunctionFilter):
bins = [0]
else:
bins = tally_filter.bins

for bin in sorted(bins, key=_bin_sort_val):
item = QTreeWidgetItem(filter_item, [str(bin),])
if not spatial_filters:
item.setFlags(QtCore.Qt.ItemIsUserCheckable)
Expand Down Expand Up @@ -577,7 +582,11 @@ def updateFilters(self):
filter_checked = f_item.checkState(0)
if filter_checked != QtCore.Qt.Unchecked:
selected_bins = []
for idx, b in enumerate(f.bins):
if isinstance(f, openmc.EnergyFunctionFilter):
bins = [0]
else:
bins = f.bins
for idx, b in enumerate(bins):
b = b if not isinstance(b, Iterable) else tuple(b)
bin_checked = self.bin_map[(f, b)].checkState(0)
if bin_checked == QtCore.Qt.Checked:
Expand Down
21 changes: 15 additions & 6 deletions openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from ast import literal_eval
from collections import defaultdict
import copy
import itertools
import threading
from ast import literal_eval

from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox
from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent
Expand Down Expand Up @@ -503,28 +503,37 @@ def _do_op(array, tally_value, ax=0):
# applied to the mesh filter
lower_left = mesh.lower_left
upper_right = mesh.upper_right
width = mesh.width
dimension = mesh.dimension
if hasattr(mesh_filter, 'translation') and mesh_filter.translation is not None:
lower_left += mesh_filter.translation
upper_right += mesh_filter.translation

# For 2D meshes, add an extra z dimension
if len(mesh.dimension) == 2:
lower_left = np.hstack((lower_left, -1e50))
upper_right = np.hstack((upper_right, 1e50))
width = np.hstack((width, 2e50))
dimension = np.hstack((dimension, 1))

# reduce data to the visible slice of the mesh values
k = int((view.origin[ax] - lower_left[ax]) // mesh.width[ax])
k = int((view.origin[ax] - lower_left[ax]) // width[ax])

# setup slice
data_slice = [None, None, None]
data_slice[h_ind] = slice(mesh.dimension[h_ind])
data_slice[v_ind] = slice(mesh.dimension[v_ind])
data_slice[h_ind] = slice(dimension[h_ind])
data_slice[v_ind] = slice(dimension[v_ind])
data_slice[ax] = k

if k < 0 or k > mesh.dimension[ax]:
if k < 0 or k > dimension[ax]:
return (None, None, None, None)

# move mesh axes to the end of the filters
filter_idx = [type(filter) for filter in tally.filters].index(openmc.MeshFilter)
data = np.moveaxis(data, filter_idx, -1)

# reshape data (with zyx ordering for mesh data)
data = data.reshape(data.shape[:-1] + tuple(mesh.dimension[::-1]))
data = data.reshape(data.shape[:-1] + tuple(dimension[::-1]))
data = data[..., data_slice[2], data_slice[1], data_slice[0]]

# sum over the rest of the tally filters
Expand Down
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
qt_api=pyside2
python_files = test*.py
python_classes = NoThanks
filter_warnings = ignore::UserWarning
addopts = -rs
filterwarnings = ignore::UserWarning
addopts = -rs
2 changes: 0 additions & 2 deletions tests/setup_test/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import openmc.lib

from openmc_plotter.main_window import MainWindow, _openmcReload

def test_window(qtbot):
Expand Down