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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Feb 28 12:27:52 PST 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/6131cbc5c116/
changeset:   6131cbc5c116
branch:      yt
user:        ngoldbaum
date:        2013-02-28 07:51:58
summary:     Making the Radius fields more memory efficient.
affected #:  1 file

diff -r ccfe34e70803932ff921e6020a7972f8bcdcef49 -r 6131cbc5c1168248d68e2c55591810424948a6d2 yt/data_objects/universal_fields.py
--- a/yt/data_objects/universal_fields.py
+++ b/yt/data_objects/universal_fields.py
@@ -791,22 +791,23 @@
          units=r"\rm{g}\/\rm{cm}^2/\rm{s}", particle_type=True,
          validators=[ValidateParameter('center')])
 
-def get_radius(positions, data):
-    c = data.get_field_parameter("center")
-    n_tup = tuple([1 for i in range(positions.ndim-1)])
-    center = np.tile(np.reshape(c, (positions.shape[0],)+n_tup),(1,)+positions.shape[1:])
-    periodicity = data.pf.periodicity
-    if any(periodicity):
-        period = data.pf.domain_right_edge - data.pf.domain_left_edge
-        return periodic_dist(positions, center, period, periodicity)
-    else:
-        return euclidean_dist(positions, center)
+def get_radius(data, field_prefix):
+    center = data.get_field_parameter("center")
+    DW = data.pf.domain_right_edge - data.pf.domain_left_edge
+    radius = np.zeros(data[field_prefix+"x"].shape, dtype='float64')
+    for i, ax in enumerate('xyz'):
+        r = np.abs(data[field_prefix+"%s" % ax] - center[i])
+        if data.pf.periodicity[i] == True:
+            radius += np.minimum(r, np.abs(DW[i]-r))**2.0
+        else:
+            radius += r**2.0
+    np.sqrt(radius, radius)
+    return radius
+
 def _ParticleRadius(field, data):
-    positions = np.array([data["particle_position_%s" % ax] for ax in 'xyz'])
-    return get_radius(positions, data)
+    return get_radius(data, "particle_position_")
 def _Radius(field, data):
-    positions = np.array([data['x'], data['y'], data['z']])
-    return get_radius(positions, data)
+    return get_radius(data, "")
 
 def _ConvertRadiusCGS(data):
     return data.convert("cm")


https://bitbucket.org/yt_analysis/yt/commits/6174094bfe73/
changeset:   6174094bfe73
branch:      yt
user:        ngoldbaum
date:        2013-02-28 20:06:30
summary:     Updating Radius to more fully leverage numpy in-place operations.
affected #:  1 file

diff -r 6131cbc5c1168248d68e2c55591810424948a6d2 -r 6174094bfe738f1b39a44dd70ccbdcc168727653 yt/data_objects/universal_fields.py
--- a/yt/data_objects/universal_fields.py
+++ b/yt/data_objects/universal_fields.py
@@ -795,12 +795,16 @@
     center = data.get_field_parameter("center")
     DW = data.pf.domain_right_edge - data.pf.domain_left_edge
     radius = np.zeros(data[field_prefix+"x"].shape, dtype='float64')
+    r = radius
+    if any(data.pf.periodicity):
+        rdw = radius
     for i, ax in enumerate('xyz'):
-        r = np.abs(data[field_prefix+"%s" % ax] - center[i])
+        np.subtract(data["%s%s" % (field_prefix, ax)], center[i], r)
+        np.abs(r, r)
         if data.pf.periodicity[i] == True:
-            radius += np.minimum(r, np.abs(DW[i]-r))**2.0
-        else:
-            radius += r**2.0
+            np.subtract(DW[i], r, rdw)
+            np.minimum(r, rdw, r)
+        np.power(r, 2.0, r)
     np.sqrt(radius, radius)
     return radius
 


https://bitbucket.org/yt_analysis/yt/commits/972598e86077/
changeset:   972598e86077
branch:      yt
user:        ngoldbaum
date:        2013-02-28 20:59:43
summary:     Using deep copies, fixing a dumb error.
affected #:  1 file

diff -r 6174094bfe738f1b39a44dd70ccbdcc168727653 -r 972598e86077a32186d861107b2a7dbdca439a99 yt/data_objects/universal_fields.py
--- a/yt/data_objects/universal_fields.py
+++ b/yt/data_objects/universal_fields.py
@@ -795,16 +795,17 @@
     center = data.get_field_parameter("center")
     DW = data.pf.domain_right_edge - data.pf.domain_left_edge
     radius = np.zeros(data[field_prefix+"x"].shape, dtype='float64')
-    r = radius
+    r = radius.copy()
     if any(data.pf.periodicity):
-        rdw = radius
+        rdw = radius.copy()
     for i, ax in enumerate('xyz'):
         np.subtract(data["%s%s" % (field_prefix, ax)], center[i], r)
-        np.abs(r, r)
         if data.pf.periodicity[i] == True:
             np.subtract(DW[i], r, rdw)
+            np.abs(r, r)
             np.minimum(r, rdw, r)
         np.power(r, 2.0, r)
+        np.add(radius, r, radius)
     np.sqrt(radius, radius)
     return radius

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