[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu May 5 14:53:40 PDT 2016
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/796a8ea1be68/
Changeset: 796a8ea1be68
Branch: yt
User: MatthewTurk
Date: 2016-04-30 20:25:52+00:00
Summary: Add a categorize_particles function that returns Oct IDs and info.
Affected #: 1 file
diff -r 2d7b93e59428f2dc6d4cde5030cacc4b113c6ea4 -r 796a8ea1be686fda1273356b752569abc2be1836 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -317,6 +317,36 @@
oinfo.level = level
return cur
+ def locate_positions(self, np.float64_t[:,:] positions):
+ cdef np.float64_t factor = (1 << self.oref)
+ cdef dict all_octs = {}
+ cdef OctInfo oi
+ cdef Oct* o = NULL
+ cdef np.float64_t pos[3]
+ cdef np.ndarray[np.uint8_t, ndim=1] recorded
+ cdef np.ndarray[np.int64_t, ndim=1] oct_id
+ oct_id = np.ones(positions.shape[0], dtype="int64") * -1
+ recorded = np.zeros(self.nocts, dtype="uint8")
+ cdef np.int64_t i, j, k
+ for i in range(positions.shape[0]):
+ for j in range(3):
+ pos[j] = positions[i,j]
+ o = self.get(pos, &oi)
+ if o == NULL:
+ raise RuntimeError
+ if recorded[o.domain_ind] == 0:
+ left_edge = np.asarray(<np.float64_t[:3]>oi.left_edge)
+ dds = np.asarray(<np.float64_t[:3]>oi.dds)
+ right_edge = left_edge + dds*factor
+ all_octs[o.domain_ind] = dict(
+ left_edge = left_edge,
+ right_edge = right_edge,
+ level = oi.level
+ )
+ recorded[o.domain_ind] = 1
+ oct_id[i] = o.domain_ind
+ return oct_id, all_octs
+
def domain_identify(self, SelectorObject selector):
cdef np.ndarray[np.uint8_t, ndim=1] domain_mask
domain_mask = np.zeros(self.num_domains, dtype="uint8")
https://bitbucket.org/yt_analysis/yt/commits/c1b06d90ba89/
Changeset: c1b06d90ba89
Branch: yt
User: MatthewTurk
Date: 2016-05-01 20:49:07+00:00
Summary: Adding a test for position_locator
Affected #: 1 file
diff -r 796a8ea1be686fda1273356b752569abc2be1836 -r c1b06d90ba89efbeafa2bda7847c4d593bd0c13a yt/geometry/tests/test_particle_octree.py
--- a/yt/geometry/tests/test_particle_octree.py
+++ b/yt/geometry/tests/test_particle_octree.py
@@ -209,6 +209,24 @@
i[0](*i[1:])
time.sleep(1)
+def test_position_location():
+ np.random.seed(int(0x4d3d3d3))
+ pos = np.random.normal(0.5, scale=0.05, size=(NPART,3)) * (DRE-DLE) + DLE
+ # Now convert to integers
+ data = {}
+ bbox = []
+ for i, ax in enumerate('xyz'):
+ np.clip(pos[:,i], DLE[i], DRE[i], pos[:,i])
+ bbox.append([DLE[i], DRE[i]])
+ data["particle_position_%s" % ax] = pos[:,i]
+ bbox = np.array(bbox)
+ ds = load_particles(data, 1.0, bbox = bbox, over_refine_factor = 2)
+ oct_id, all_octs = ds.index.oct_handler.locate_positions(pos)
+ for oi in sorted(all_octs):
+ this_oct = pos[oct_id == oi]
+ assert(np.all(this_oct >= all_octs[oi]["left_edge"]))
+ assert(np.all(this_oct <= all_octs[oi]["right_edge"]))
+
os33 = "snapshot_033/snap_033.0.hdf5"
@requires_file(os33)
def test_get_smallest_dx():
https://bitbucket.org/yt_analysis/yt/commits/cde44a02d553/
Changeset: cde44a02d553
Branch: yt
User: MatthewTurk
Date: 2016-05-02 15:40:36+00:00
Summary: Copy the arrays
Affected #: 1 file
diff -r c1b06d90ba89efbeafa2bda7847c4d593bd0c13a -r cde44a02d5534283f922387b6b49df03774189d0 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -335,8 +335,8 @@
if o == NULL:
raise RuntimeError
if recorded[o.domain_ind] == 0:
- left_edge = np.asarray(<np.float64_t[:3]>oi.left_edge)
- dds = np.asarray(<np.float64_t[:3]>oi.dds)
+ left_edge = np.asarray(<np.float64_t[:3]>oi.left_edge).copy()
+ dds = np.asarray(<np.float64_t[:3]>oi.dds).copy()
right_edge = left_edge + dds*factor
all_octs[o.domain_ind] = dict(
left_edge = left_edge,
https://bitbucket.org/yt_analysis/yt/commits/410a6b83d2d4/
Changeset: 410a6b83d2d4
Branch: yt
User: MatthewTurk
Date: 2016-05-05 21:37:51+00:00
Summary: Adding docstring
Affected #: 1 file
diff -r cde44a02d5534283f922387b6b49df03774189d0 -r 410a6b83d2d4551ca40c42c3c1e80facfbae974a yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -318,6 +318,11 @@
return cur
def locate_positions(self, np.float64_t[:,:] positions):
+ """
+ This routine, meant to be called by other internal routines, returns a
+ list of oct IDs and a dictionary of Oct info for all the positions
+ supplied. Positions must be in code_length.
+ """
cdef np.float64_t factor = (1 << self.oref)
cdef dict all_octs = {}
cdef OctInfo oi
https://bitbucket.org/yt_analysis/yt/commits/cb216de0db74/
Changeset: cb216de0db74
Branch: yt
User: chummels
Date: 2016-05-05 21:53:29+00:00
Summary: Merged in MatthewTurk/yt (pull request #2154)
Add a position location method for octrees
Affected #: 2 files
diff -r 2f2c9e84c335e5d4be9c4eac86b1f67aed7e752f -r cb216de0db743757a486ff0e90713812a6fb3e16 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -317,6 +317,41 @@
oinfo.level = level
return cur
+ def locate_positions(self, np.float64_t[:,:] positions):
+ """
+ This routine, meant to be called by other internal routines, returns a
+ list of oct IDs and a dictionary of Oct info for all the positions
+ supplied. Positions must be in code_length.
+ """
+ cdef np.float64_t factor = (1 << self.oref)
+ cdef dict all_octs = {}
+ cdef OctInfo oi
+ cdef Oct* o = NULL
+ cdef np.float64_t pos[3]
+ cdef np.ndarray[np.uint8_t, ndim=1] recorded
+ cdef np.ndarray[np.int64_t, ndim=1] oct_id
+ oct_id = np.ones(positions.shape[0], dtype="int64") * -1
+ recorded = np.zeros(self.nocts, dtype="uint8")
+ cdef np.int64_t i, j, k
+ for i in range(positions.shape[0]):
+ for j in range(3):
+ pos[j] = positions[i,j]
+ o = self.get(pos, &oi)
+ if o == NULL:
+ raise RuntimeError
+ if recorded[o.domain_ind] == 0:
+ left_edge = np.asarray(<np.float64_t[:3]>oi.left_edge).copy()
+ dds = np.asarray(<np.float64_t[:3]>oi.dds).copy()
+ right_edge = left_edge + dds*factor
+ all_octs[o.domain_ind] = dict(
+ left_edge = left_edge,
+ right_edge = right_edge,
+ level = oi.level
+ )
+ recorded[o.domain_ind] = 1
+ oct_id[i] = o.domain_ind
+ return oct_id, all_octs
+
def domain_identify(self, SelectorObject selector):
cdef np.ndarray[np.uint8_t, ndim=1] domain_mask
domain_mask = np.zeros(self.num_domains, dtype="uint8")
diff -r 2f2c9e84c335e5d4be9c4eac86b1f67aed7e752f -r cb216de0db743757a486ff0e90713812a6fb3e16 yt/geometry/tests/test_particle_octree.py
--- a/yt/geometry/tests/test_particle_octree.py
+++ b/yt/geometry/tests/test_particle_octree.py
@@ -209,6 +209,24 @@
i[0](*i[1:])
time.sleep(1)
+def test_position_location():
+ np.random.seed(int(0x4d3d3d3))
+ pos = np.random.normal(0.5, scale=0.05, size=(NPART,3)) * (DRE-DLE) + DLE
+ # Now convert to integers
+ data = {}
+ bbox = []
+ for i, ax in enumerate('xyz'):
+ np.clip(pos[:,i], DLE[i], DRE[i], pos[:,i])
+ bbox.append([DLE[i], DRE[i]])
+ data["particle_position_%s" % ax] = pos[:,i]
+ bbox = np.array(bbox)
+ ds = load_particles(data, 1.0, bbox = bbox, over_refine_factor = 2)
+ oct_id, all_octs = ds.index.oct_handler.locate_positions(pos)
+ for oi in sorted(all_octs):
+ this_oct = pos[oct_id == oi]
+ assert(np.all(this_oct >= all_octs[oi]["left_edge"]))
+ assert(np.all(this_oct <= all_octs[oi]["right_edge"]))
+
os33 = "snapshot_033/snap_033.0.hdf5"
@requires_file(os33)
def test_get_smallest_dx():
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160505/8d5dfa7e/attachment-0002.htm>
More information about the yt-svn
mailing list