[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon May 15 13:15:26 PDT 2017


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/4f3e2903fabb/
Changeset:   4f3e2903fabb
User:        ngoldbaum
Date:        2017-05-01 14:59:58+00:00
Summary:     Account for periodic boundary conditions in the halo callback
Affected #:  1 file

diff -r c8eac6c2ed9d64f40c75c56bac3568b22f7d9bce -r 4f3e2903fabb9818c3cd0b9aa7699a1c8835997a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -152,11 +152,11 @@
 
         # We need a special case for when we are only given one coordinate.
         if ccoord.shape == (2,):
-            return (np.mod((ccoord[0]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
-                    np.mod((ccoord[1]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
+            return ((ccoord[0]-x0)/(x1-x0)*(xx1-xx0) + xx0,
+                    (ccoord[1]-y0)/(y1-y0)*(yy1-yy0) + yy0)
         else:
-            return (np.mod((ccoord[0][:]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
-                    np.mod((ccoord[1][:]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
+            return ((ccoord[0][:]-x0)/(x1-x0)*(xx1-xx0) + xx0,
+                    (ccoord[1][:]-y0)/(y1-y0)*(yy1-yy0) + yy0)
 
     def sanitize_coord_system(self, plot, coord, coord_system):
         """
@@ -1442,7 +1442,25 @@
         px = halo_data[field_x][:].in_units(units)
         py = halo_data[field_y][:].in_units(units)
 
-        px, py = self.convert_to_plot(plot,[px,py])
+        xplotcenter = (plot.xlim[0] + plot.xlim[1])/2
+        yplotcenter = (plot.ylim[0] + plot.ylim[1])/2
+
+        xdomaincenter = plot.ds.domain_center[xax]
+        ydomaincenter = plot.ds.domain_center[yax]
+
+        xoffset = xplotcenter - xdomaincenter
+        yoffset = yplotcenter - ydomaincenter
+
+        xdw = plot.ds.domain_width[xax].to(units)
+        ydw = plot.ds.domain_width[yax].to(units)
+
+        modpx = np.mod(px - xoffset, xdw) + xoffset
+        modpy = np.mod(py - yoffset, ydw) + yoffset
+
+        px[modpx != px] = modpx[modpx != px]
+        py[modpy != py] = modpy[modpy != py]
+
+        px, py = self.convert_to_plot(plot, [px, py])
 
         # Convert halo radii to a radius in pixels
         radius = halo_data[self.radius_field][:].in_units(units)


https://bitbucket.org/yt_analysis/yt/commits/4781b57a6aec/
Changeset:   4781b57a6aec
User:        ngoldbaum
Date:        2017-05-15 20:15:14+00:00
Summary:     Merge pull request #1351 from ngoldbaum/halo-callback

Account for periodic boundary conditions in the halo callback
Affected #:  1 file

diff -r 2f68d487b8661ea407ef740b60acc22063f85e18 -r 4781b57a6aecacf0200584103bfc0c96961efd38 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -151,11 +151,11 @@
 
         # We need a special case for when we are only given one coordinate.
         if ccoord.shape == (2,):
-            return (np.mod((ccoord[0]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
-                    np.mod((ccoord[1]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
+            return ((ccoord[0]-x0)/(x1-x0)*(xx1-xx0) + xx0,
+                    (ccoord[1]-y0)/(y1-y0)*(yy1-yy0) + yy0)
         else:
-            return (np.mod((ccoord[0][:]-x0)/(x1-x0), 1.0)*(xx1-xx0) + xx0,
-                    np.mod((ccoord[1][:]-y0)/(y1-y0), 1.0)*(yy1-yy0) + yy0)
+            return ((ccoord[0][:]-x0)/(x1-x0)*(xx1-xx0) + xx0,
+                    (ccoord[1][:]-y0)/(y1-y0)*(yy1-yy0) + yy0)
 
     def sanitize_coord_system(self, plot, coord, coord_system):
         """
@@ -1437,7 +1437,25 @@
         px = halo_data[field_x][:].in_units(units)
         py = halo_data[field_y][:].in_units(units)
 
-        px, py = self.convert_to_plot(plot,[px,py])
+        xplotcenter = (plot.xlim[0] + plot.xlim[1])/2
+        yplotcenter = (plot.ylim[0] + plot.ylim[1])/2
+
+        xdomaincenter = plot.ds.domain_center[xax]
+        ydomaincenter = plot.ds.domain_center[yax]
+
+        xoffset = xplotcenter - xdomaincenter
+        yoffset = yplotcenter - ydomaincenter
+
+        xdw = plot.ds.domain_width[xax].to(units)
+        ydw = plot.ds.domain_width[yax].to(units)
+
+        modpx = np.mod(px - xoffset, xdw) + xoffset
+        modpy = np.mod(py - yoffset, ydw) + yoffset
+
+        px[modpx != px] = modpx[modpx != px]
+        py[modpy != py] = modpy[modpy != py]
+
+        px, py = self.convert_to_plot(plot, [px, py])
 
         # Convert halo radii to a radius in pixels
         radius = halo_data[self.radius_field][:].in_units(units)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list