Skip to content

Commit 1d3764b

Browse files
committed
Add checkbox for mesh volume normalization
1 parent b9d9f94 commit 1d3764b

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

openmc_plotter/docks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ def __init__(self, model, main_window, field, colormaps=None):
826826
zero_connector = partial(main_window.toggleTallyMaskZero)
827827
self.maskZeroBox.stateChanged.connect(zero_connector)
828828

829+
# Volume normalization check box
830+
self.volumeNormBox = QCheckBox()
831+
volume_connector = partial(main_window.toggleTallyVolumeNorm)
832+
self.volumeNormBox.stateChanged.connect(volume_connector)
833+
829834
# Clip data to min/max check box
830835
self.clipDataBox = QCheckBox()
831836
clip_connector = partial(main_window.toggleTallyDataClip)
@@ -849,6 +854,7 @@ def __init__(self, model, main_window, field, colormaps=None):
849854
self.layout.addRow("Log Scale: ", self.scaleBox)
850855
self.layout.addRow("Clip Data: ", self.clipDataBox)
851856
self.layout.addRow("Mask Zeros: ", self.maskZeroBox)
857+
self.layout.addRow("Volume normalize: ", self.volumeNormBox)
852858
self.layout.addRow("Contours: ", self.contoursBox)
853859
self.layout.addRow("Contour Levels:", self.contourLevelsLine)
854860
self.setLayout(self.layout)

openmc_plotter/main_window.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ def toggleTallyMaskZero(self, state):
951951
av = self.model.activeView
952952
av.tallyMaskZeroValues = bool(state)
953953

954+
def toggleTallyVolumeNorm(self, state):
955+
av = self.model.activeView
956+
av.tallyVolumeNorm = bool(state)
957+
954958
def editTallyAlpha(self, value, apply=False):
955959
av = self.model.activeView
956960
av.tallyDataAlpha = value

openmc_plotter/plotmodel.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,6 @@ def _do_op(array, tally_value, ax=0):
696696
selected_scores.append(idx)
697697
data = _do_op(data[np.array(selected_scores)], tally_value)
698698

699-
# get dataset's min/max
700-
data_min = np.min(data)
701-
data_max = np.max(data)
702-
703699
# Account for mesh filter translation
704700
if mesh_filter.translation is not None:
705701
t = mesh_filter.translation
@@ -716,11 +712,19 @@ def _do_op(array, tally_value, ax=0):
716712
pixels=(view.h_res, view.v_res),
717713
)
718714

715+
# Apply volume normalization
716+
if view.tallyVolumeNorm:
717+
data /= mesh_cpp.volumes
718+
719719
# set image data
720720
image_data = np.full_like(self.ids, np.nan, dtype=float)
721721
mask = (mesh_bins >= 0)
722722
image_data[mask] = data[mesh_bins[mask]]
723723

724+
# get dataset's min/max
725+
data_min = np.min(data)
726+
data_max = np.max(data)
727+
724728
return image_data, None, data_min, data_max
725729

726730
@property
@@ -911,6 +915,7 @@ def __init__(self):
911915
self.tallyDataMax = np.inf
912916
self.tallyDataLogScale = False
913917
self.tallyMaskZeroValues = False
918+
self.tallyVolumeNorm = False
914919
self.clipTallyData = False
915920
self.tallyValue = "Mean"
916921
self.tallyContours = False

0 commit comments

Comments
 (0)