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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Feb 9 09:08:28 PST 2018


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/09dbb535ccb9/
Changeset:   09dbb535ccb9
User:        ngoldbaum
Date:        2018-02-08 19:57:15+00:00
Summary:     Fix incorrect vector field components in cylindrical and spherical coordinates
Affected #:  2 files

diff -r 68a49fbd15c4b1218cb236d092bdd24083ba5729 -r 09dbb535ccb9fc1dd60b08ddfc95f3863bf1a112 yt/fields/tests/test_vector_fields.py
--- /dev/null
+++ b/yt/fields/tests/test_vector_fields.py
@@ -0,0 +1,43 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2016, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import numpy as np
+
+from yt.testing import \
+    assert_allclose_units, \
+    fake_random_ds
+
+def test_vector_component_conversions():
+    ds = fake_random_ds(16)
+
+    ad = ds.all_data()
+
+    vmag = ad['velocity_magnitude']
+    vmag_cart = np.sqrt(
+        ad['velocity_x']**2 +
+        ad['velocity_y']**2 +
+        ad['velocity_z']**2
+    )
+
+    assert_allclose_units(vmag, vmag_cart)
+
+    vmag_cyl = np.sqrt(
+        ad['velocity_cylindrical_radius']**2 +
+        ad['velocity_cylindrical_theta']**2 +
+        ad['velocity_cylindrical_z']**2
+    )
+
+    assert_allclose_units(vmag, vmag_cyl)
+
+    vmag_sph = np.sqrt(
+        ad['velocity_spherical_radius']**2 +
+        ad['velocity_spherical_theta']**2 +
+        ad['velocity_spherical_phi']**2
+    )
+
+    assert_allclose_units(vmag, vmag_sph)

diff -r 68a49fbd15c4b1218cb236d092bdd24083ba5729 -r 09dbb535ccb9fc1dd60b08ddfc95f3863bf1a112 yt/fields/vector_operations.py
--- a/yt/fields/vector_operations.py
+++ b/yt/fields/vector_operations.py
@@ -23,8 +23,7 @@
     get_sph_phi_component, \
     get_cyl_r_component, \
     get_cyl_z_component, \
-    get_cyl_theta_component, \
-    resize_vector
+    get_cyl_theta_component
 
 from yt.funcs import just_one
 
@@ -150,8 +149,8 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        theta = resize_vector(data["index", "spherical_theta"], vectors)
-        phi = resize_vector(data["index", "spherical_phi"], vectors)
+        theta = data["index", "spherical_theta"]
+        phi = data["index", "spherical_phi"]
         return get_sph_theta_component(vectors, theta, phi, normal)
 
     registry.add_field((ftype, "%s_spherical_theta" % basename), sampling_type="cell", 
@@ -170,7 +169,7 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        phi = resize_vector(data["index", "spherical_phi"], vectors)
+        phi = data["index", "spherical_phi"]
         return get_sph_phi_component(vectors, phi, normal)
 
     registry.add_field((ftype, "%s_spherical_phi" % basename), sampling_type="cell", 
@@ -249,7 +248,7 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        theta = resize_vector(data["index", 'cylindrical_theta'], vectors)
+        theta = data["index", 'cylindrical_theta']
         return get_cyl_r_component(vectors, theta, normal)
 
     registry.add_field((ftype, "%s_cylindrical_radius" % basename), sampling_type="cell", 


https://bitbucket.org/yt_analysis/yt/commits/5d623ec12aeb/
Changeset:   5d623ec12aeb
User:        xarthisius
Date:        2018-02-09 17:08:12+00:00
Summary:     Merge pull request #1687 from ngoldbaum/curvilinear-fix

Fix incorrect vector field components in cylindrical and spherical cordinates
Affected #:  2 files

diff -r 148e462cfbf67ea64fa0ca836029a3120d322cf4 -r 5d623ec12aebc9d3815c6b3d59099c30f9db2d27 yt/fields/tests/test_vector_fields.py
--- /dev/null
+++ b/yt/fields/tests/test_vector_fields.py
@@ -0,0 +1,43 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2016, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import numpy as np
+
+from yt.testing import \
+    assert_allclose_units, \
+    fake_random_ds
+
+def test_vector_component_conversions():
+    ds = fake_random_ds(16)
+
+    ad = ds.all_data()
+
+    vmag = ad['velocity_magnitude']
+    vmag_cart = np.sqrt(
+        ad['velocity_x']**2 +
+        ad['velocity_y']**2 +
+        ad['velocity_z']**2
+    )
+
+    assert_allclose_units(vmag, vmag_cart)
+
+    vmag_cyl = np.sqrt(
+        ad['velocity_cylindrical_radius']**2 +
+        ad['velocity_cylindrical_theta']**2 +
+        ad['velocity_cylindrical_z']**2
+    )
+
+    assert_allclose_units(vmag, vmag_cyl)
+
+    vmag_sph = np.sqrt(
+        ad['velocity_spherical_radius']**2 +
+        ad['velocity_spherical_theta']**2 +
+        ad['velocity_spherical_phi']**2
+    )
+
+    assert_allclose_units(vmag, vmag_sph)

diff -r 148e462cfbf67ea64fa0ca836029a3120d322cf4 -r 5d623ec12aebc9d3815c6b3d59099c30f9db2d27 yt/fields/vector_operations.py
--- a/yt/fields/vector_operations.py
+++ b/yt/fields/vector_operations.py
@@ -23,8 +23,7 @@
     get_sph_phi_component, \
     get_cyl_r_component, \
     get_cyl_z_component, \
-    get_cyl_theta_component, \
-    resize_vector
+    get_cyl_theta_component
 
 from yt.funcs import just_one
 
@@ -150,8 +149,8 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        theta = resize_vector(data["index", "spherical_theta"], vectors)
-        phi = resize_vector(data["index", "spherical_phi"], vectors)
+        theta = data["index", "spherical_theta"]
+        phi = data["index", "spherical_phi"]
         return get_sph_theta_component(vectors, theta, phi, normal)
 
     registry.add_field((ftype, "%s_spherical_theta" % basename), sampling_type="cell", 
@@ -170,7 +169,7 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        phi = resize_vector(data["index", "spherical_phi"], vectors)
+        phi = data["index", "spherical_phi"]
         return get_sph_phi_component(vectors, phi, normal)
 
     registry.add_field((ftype, "%s_spherical_phi" % basename), sampling_type="cell", 
@@ -251,7 +250,7 @@
         normal = data.get_field_parameter("normal")
         vectors = obtain_rv_vec(data, (xn, yn, zn),
                                 "bulk_%s" % basename)
-        theta = resize_vector(data["index", 'cylindrical_theta'], vectors)
+        theta = data["index", 'cylindrical_theta']
         return get_cyl_r_component(vectors, theta, normal)
 
     registry.add_field((ftype, "%s_cylindrical_radius" % basename), sampling_type="cell",

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