[yt-svn] commit/yt: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jul 16 09:01:21 PDT 2016
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/adf065d7343d/
Changeset: adf065d7343d
Branch: yt
User: MatthewTurk
Date: 2016-07-01 21:01:54+00:00
Summary: Adding a morton_index field
Affected #: 1 file
diff -r 428dd2f17465075a90ab4ebf40db69e4f619f7ab -r adf065d7343dafbf8fef2846845304cf51a3194d yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -33,6 +33,9 @@
get_cyl_z, get_sph_r, \
get_sph_theta, get_sph_phi
+from yt.utilities.lib.geometry_utils import \
+ compute_morton
+
@register_field_plugin
def setup_geometric_fields(registry, ftype="gas", slice_info=None):
unit_system = registry.ds.unit_system
@@ -100,6 +103,22 @@
units="",
display_field=False)
+ def _morton_index(field, data):
+ """A float64 view on a uint64 field that is the morton index of the
+ cell-centers."""
+ eps = np.finfo("f8").eps
+ uq = data.ds.domain_left_edge.uq
+ LE = data.ds.domain_left_edge - eps * uq
+ RE = data.ds.domain_right_edge + eps * uq
+ # .ravel() only copies if it needs to
+ morton = compute_morton(data["index", "x"].ravel(),
+ data["index", "y"].ravel(),
+ data["index", "z"].ravel(), LE, RE)
+ morton.shape = data["index", "x"].shape
+ return morton.view("f8")
+ registry.add_field(("index", "morton_index"), function=_morton_index,
+ units = "")
+
def _spherical_radius(field, data):
"""The spherical radius component of the positions of the mesh cells.
https://bitbucket.org/yt_analysis/yt/commits/10353cc5f3c0/
Changeset: 10353cc5f3c0
Branch: yt
User: MatthewTurk
Date: 2016-07-01 21:05:36+00:00
Summary: Adding a uniqueness test for morton index field
Affected #: 1 file
diff -r adf065d7343dafbf8fef2846845304cf51a3194d -r 10353cc5f3c068a3ae60f66f79480cc97ad5f796 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -3,6 +3,7 @@
from yt import \
load
from yt.testing import \
+ fake_amr_ds, \
fake_random_ds, \
fake_particle_ds, \
assert_almost_equal, \
@@ -337,6 +338,12 @@
ds.field_info['all', 'particle_mass_alias']
+def test_morton_index():
+ ds = fake_amr_ds()
+ mi = ds.r["index", "morton_index"]
+ mi2 = mi.view("uint64")
+ assert_equal(np.unique(mi2).size, mi2.size)
+
if __name__ == "__main__":
setup()
for t in test_all_fields():
https://bitbucket.org/yt_analysis/yt/commits/ca5aa36eabcc/
Changeset: ca5aa36eabcc
Branch: yt
User: MatthewTurk
Date: 2016-07-01 21:22:43+00:00
Summary: Noting about the view, adding a sort test.
Affected #: 2 files
diff -r 10353cc5f3c068a3ae60f66f79480cc97ad5f796 -r ca5aa36eabccaa569a41bc83ede3f5312a2131ba yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -104,8 +104,13 @@
display_field=False)
def _morton_index(field, data):
- """A float64 view on a uint64 field that is the morton index of the
- cell-centers."""
+ """This is the morton index, which is properly a uint64 field. Because
+ we make some assumptions that the fields returned by derived fields are
+ float64, this returns a "view" on the data that is float64. To get
+ back the original uint64, you need to call .view("uint64") on it;
+ however, it should be true that if you sort the uint64, you will get
+ the same order as if you sort the float64 view.
+ """
eps = np.finfo("f8").eps
uq = data.ds.domain_left_edge.uq
LE = data.ds.domain_left_edge - eps * uq
diff -r 10353cc5f3c068a3ae60f66f79480cc97ad5f796 -r ca5aa36eabccaa569a41bc83ede3f5312a2131ba yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -343,6 +343,9 @@
mi = ds.r["index", "morton_index"]
mi2 = mi.view("uint64")
assert_equal(np.unique(mi2).size, mi2.size)
+ a1 = np.argsort(mi)
+ a2 = np.argsort(mi2)
+ assert_array_equal(a1, a2)
if __name__ == "__main__":
setup()
https://bitbucket.org/yt_analysis/yt/commits/b58837b96e9d/
Changeset: b58837b96e9d
Branch: yt
User: xarthisius
Date: 2016-07-16 16:00:49+00:00
Summary: Merged in MatthewTurk/yt (pull request #2259)
[Not a new feature I promise] Adding a morton_index derived field
Affected #: 2 files
diff -r acc390b0a7fec1cb38db9030a9f0e22eac2dcbc2 -r b58837b96e9d93e200ec564f11db913ec4c515e0 yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -32,6 +32,9 @@
get_cyl_z, get_sph_r, \
get_sph_theta, get_sph_phi
+from yt.utilities.lib.geometry_utils import \
+ compute_morton
+
@register_field_plugin
def setup_geometric_fields(registry, ftype="gas", slice_info=None):
unit_system = registry.ds.unit_system
@@ -111,6 +114,27 @@
units="",
display_field=False)
+ def _morton_index(field, data):
+ """This is the morton index, which is properly a uint64 field. Because
+ we make some assumptions that the fields returned by derived fields are
+ float64, this returns a "view" on the data that is float64. To get
+ back the original uint64, you need to call .view("uint64") on it;
+ however, it should be true that if you sort the uint64, you will get
+ the same order as if you sort the float64 view.
+ """
+ eps = np.finfo("f8").eps
+ uq = data.ds.domain_left_edge.uq
+ LE = data.ds.domain_left_edge - eps * uq
+ RE = data.ds.domain_right_edge + eps * uq
+ # .ravel() only copies if it needs to
+ morton = compute_morton(data["index", "x"].ravel(),
+ data["index", "y"].ravel(),
+ data["index", "z"].ravel(), LE, RE)
+ morton.shape = data["index", "x"].shape
+ return morton.view("f8")
+ registry.add_field(("index", "morton_index"), function=_morton_index,
+ units = "")
+
def _spherical_radius(field, data):
"""The spherical radius component of the positions of the mesh cells.
diff -r acc390b0a7fec1cb38db9030a9f0e22eac2dcbc2 -r b58837b96e9d93e200ec564f11db913ec4c515e0 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -3,6 +3,7 @@
from yt import \
load
from yt.testing import \
+ fake_amr_ds, \
fake_random_ds, \
fake_particle_ds, \
assert_almost_equal, \
@@ -337,6 +338,15 @@
ds.field_info['all', 'particle_mass_alias']
+def test_morton_index():
+ ds = fake_amr_ds()
+ mi = ds.r["index", "morton_index"]
+ mi2 = mi.view("uint64")
+ assert_equal(np.unique(mi2).size, mi2.size)
+ a1 = np.argsort(mi)
+ a2 = np.argsort(mi2)
+ assert_array_equal(a1, a2)
+
if __name__ == "__main__":
setup()
for t in test_all_fields():
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