@@ -657,57 +657,10 @@ def _do_op(array, tally_value, ax=0):
657657 # start with reshaped data
658658 data = tally .get_reshaped_data (tally_value )
659659
660- # determine basis indices
661- if view .basis == 'xy' :
662- h_ind = 0
663- v_ind = 1
664- ax = 2
665- elif view .basis == 'yz' :
666- h_ind = 1
667- v_ind = 2
668- ax = 0
669- else :
670- h_ind = 0
671- v_ind = 2
672- ax = 1
673-
674- # adjust corners of the mesh for a translation
675- # applied to the mesh filter
676- lower_left = mesh .lower_left
677- upper_right = mesh .upper_right
678- width = mesh .width
679- dimension = mesh .dimension
680- if hasattr (mesh_filter , 'translation' ) and mesh_filter .translation is not None :
681- lower_left += mesh_filter .translation
682- upper_right += mesh_filter .translation
683-
684- # For 2D meshes, add an extra z dimension
685- if len (mesh .dimension ) == 2 :
686- lower_left = np .hstack ((lower_left , - 1e50 ))
687- upper_right = np .hstack ((upper_right , 1e50 ))
688- width = np .hstack ((width , 2e50 ))
689- dimension = np .hstack ((dimension , 1 ))
690-
691- # reduce data to the visible slice of the mesh values
692- k = int ((view .origin [ax ] - lower_left [ax ]) // width [ax ])
693-
694- # setup slice
695- data_slice = [None , None , None ]
696- data_slice [h_ind ] = slice (dimension [h_ind ])
697- data_slice [v_ind ] = slice (dimension [v_ind ])
698- data_slice [ax ] = k
699-
700- if k < 0 or k > dimension [ax ]:
701- return (None , None , None , None )
702-
703660 # move mesh axes to the end of the filters
704661 filter_idx = [type (filter ) for filter in tally .filters ].index (openmc .MeshFilter )
705662 data = np .moveaxis (data , filter_idx , - 1 )
706663
707- # reshape data (with zyx ordering for mesh data)
708- data = data .reshape (data .shape [:- 1 ] + tuple (dimension [::- 1 ]))
709- data = data [..., data_slice [2 ], data_slice [1 ], data_slice [0 ]]
710-
711664 # sum over the rest of the tally filters
712665 for tally_filter in tally .filters :
713666 if type (tally_filter ) == openmc .MeshFilter :
@@ -747,14 +700,21 @@ def _do_op(array, tally_value, ax=0):
747700 data_min = np .min (data )
748701 data_max = np .max (data )
749702
750- # set image data, reverse y-axis
751- image_data = data [::- 1 , ...]
703+ # Get mesh bins from openmc.lib
704+ mesh_cpp = openmc .lib .meshes [mesh .id ]
705+ mesh_bins = mesh_cpp .get_plot_bins (
706+ origin = view .origin ,
707+ width = (view .width , view .height ),
708+ basis = view .basis ,
709+ pixels = (view .h_res , view .v_res ),
710+ )
752711
753- # return data extents (in cm) for the tally
754- extents = [lower_left [h_ind ], upper_right [h_ind ],
755- lower_left [v_ind ], upper_right [v_ind ]]
712+ # set image data
713+ image_data = np .full_like (self .ids , np .nan , dtype = float )
714+ mask = (mesh_bins >= 0 )
715+ image_data [mask ] = data [mesh_bins [mask ]]
756716
757- return image_data , extents , data_min , data_max
717+ return image_data , None , data_min , data_max
758718
759719 @property
760720 def cell_ids (self ):
0 commit comments