Skip to content

Commit

Permalink
Merge pull request #2644 from matthewturk/edge_correction_sph
Browse files Browse the repository at this point in the history
Don't allow edges to extend beyond domain for SPH region sources.
  • Loading branch information
munkm authored Jun 19, 2020
2 parents ec9a562 + 7a9f39a commit 59f9432
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions yt/geometry/coordinates/cartesian_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,23 @@ def _ortho_pixelize(self, data_source, field, bounds, size, antialias,
if isinstance(data_source, YTParticleProj):
weight = data_source.weight_field
le, re = data_source.data_source.get_bbox()
le[self.x_axis[dim]] = bounds[0]
le[self.y_axis[dim]] = bounds[2]
re[self.x_axis[dim]] = bounds[1]
re[self.y_axis[dim]] = bounds[3]
xa = self.x_axis[dim]
ya = self.y_axis[dim]
# If we're not periodic, we need to clip to the boundary edges
# or we get errors about extending off the edge of the region.
if not self.ds.periodicity[xa]:
le[xa] = max(bounds[0], self.ds.domain_left_edge[xa])
re[xa] = min(bounds[1], self.ds.domain_right_edge[xa])
else:
le[xa] = bounds[0]
re[xa] = bounds[1]
if not self.ds.periodicity[ya]:
le[ya] = max(bounds[2], self.ds.domain_left_edge[ya])
re[ya] = min(bounds[3], self.ds.domain_right_edge[ya])
else:
le[ya] = bounds[2]
re[ya] = bounds[3]
# We actually need to clip these
proj_reg = data_source.ds.region(
left_edge=le, right_edge=re, center=data_source.center,
data_source=data_source.data_source
Expand Down

0 comments on commit 59f9432

Please sign in to comment.