Skip to content

Commit

Permalink
Merge pull request #62 from pshriwise/mesh_translation
Browse files Browse the repository at this point in the history
Adding support for plotting meshes with translations applied.
  • Loading branch information
paulromano authored Jun 24, 2021
2 parents 2bf35dd + 9fdc17d commit bf03181
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions openmc_plotter/plotmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ def _create_tally_mesh_image(self, tally, tally_value, scores, nuclides, view=No
cv = self.currentView

sp = self.statepoint
mesh = tally.find_filter(openmc.MeshFilter).mesh
mesh_filter = tally.find_filter(openmc.MeshFilter)
mesh = mesh_filter.mesh

def _do_op(array, tally_value, ax=0):
if tally_value == 'mean':
Expand All @@ -496,8 +497,16 @@ def _do_op(array, tally_value, ax=0):
v_ind = 2
ax = 1

# adjust corners of the mesh for a translation
# applied to the mesh filter
lower_left = mesh.lower_left
upper_right = mesh.upper_right
if hasattr(mesh_filter, 'translation') and mesh_filter.translation is not None:
lower_left += mesh_filter.translation
upper_right += mesh_filter.translation

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

# setup slice
data_slice = [None, None, None]
Expand Down Expand Up @@ -559,8 +568,8 @@ def _do_op(array, tally_value, ax=0):
image_data = data[::-1, ...]

# return data extents (in cm) for the tally
extents = [mesh.lower_left[h_ind], mesh.upper_right[h_ind],
mesh.lower_left[v_ind], mesh.upper_right[v_ind]]
extents = [lower_left[h_ind], upper_right[h_ind],
lower_left[v_ind], upper_right[v_ind]]

return image_data, extents, data_min, data_max

Expand Down

0 comments on commit bf03181

Please sign in to comment.