From fc777a0aa5e476dff334957beb1bcbbc44890a43 Mon Sep 17 00:00:00 2001 From: Matthew Turk Date: Tue, 16 Jun 2020 09:32:14 -0500 Subject: [PATCH 1/3] Don't allow edges to extend beyond domain for SPH region sources. --- yt/geometry/coordinates/cartesian_coordinates.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yt/geometry/coordinates/cartesian_coordinates.py b/yt/geometry/coordinates/cartesian_coordinates.py index ff44427d4d8..642be056694 100644 --- a/yt/geometry/coordinates/cartesian_coordinates.py +++ b/yt/geometry/coordinates/cartesian_coordinates.py @@ -284,10 +284,13 @@ 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] + le[xa] = max(bounds[0], self.ds.domain_left_edge[xa]) + le[ya] = max(bounds[2], self.ds.domain_left_edge[ya]) + re[xa] = min(bounds[1], self.ds.domain_right_edge[xa]) + re[ya] = min(bounds[3], self.ds.domain_right_edge[ya]) + # 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 From 88219bd67af145acaf085aafb2c5aeae246ae700 Mon Sep 17 00:00:00 2001 From: Matthew Turk Date: Thu, 18 Jun 2020 10:19:50 -0500 Subject: [PATCH 2/3] Only do the bounds limiting for non-periodic datasets --- yt/geometry/coordinates/cartesian_coordinates.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/yt/geometry/coordinates/cartesian_coordinates.py b/yt/geometry/coordinates/cartesian_coordinates.py index 642be056694..0f7964a3f2a 100644 --- a/yt/geometry/coordinates/cartesian_coordinates.py +++ b/yt/geometry/coordinates/cartesian_coordinates.py @@ -286,10 +286,18 @@ def _ortho_pixelize(self, data_source, field, bounds, size, antialias, le, re = data_source.data_source.get_bbox() xa = self.x_axis[dim] ya = self.y_axis[dim] - le[xa] = max(bounds[0], self.ds.domain_left_edge[xa]) - le[ya] = max(bounds[2], self.ds.domain_left_edge[ya]) - re[xa] = min(bounds[1], self.ds.domain_right_edge[xa]) - re[ya] = min(bounds[3], self.ds.domain_right_edge[ya]) + 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, From 7a9f39acd3ad128def4afa649d2a31977aae431d Mon Sep 17 00:00:00 2001 From: Matthew Turk Date: Thu, 18 Jun 2020 11:13:00 -0500 Subject: [PATCH 3/3] adding comment --- yt/geometry/coordinates/cartesian_coordinates.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yt/geometry/coordinates/cartesian_coordinates.py b/yt/geometry/coordinates/cartesian_coordinates.py index 0f7964a3f2a..40e3364e780 100644 --- a/yt/geometry/coordinates/cartesian_coordinates.py +++ b/yt/geometry/coordinates/cartesian_coordinates.py @@ -286,6 +286,8 @@ def _ortho_pixelize(self, data_source, field, bounds, size, antialias, le, re = data_source.data_source.get_bbox() 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])