[Yt-svn] yt: 5 new changesets

hg at spacepope.org hg at spacepope.org
Mon Jun 7 20:45:42 PDT 2010


hg Repository: yt
details:   yt/rev/5bf24345615e
changeset: 1759:5bf24345615e
user:      sskory
date:
Mon Jun 07 16:24:21 2010 -0400
description:
[svn r1744] Renaming and changing all mentions of MergerTree.py->merger_tree.py and HaloMassFcn.py->halo_mass_function.py.

hg Repository: yt
details:   yt/rev/4924a31d95fb
changeset: 1760:4924a31d95fb
user:      mturk
date:
Mon Jun 07 16:33:18 2010 -0400
description:
[svn r1745] Renaming clump.py to clump_handling.py.

hg Repository: yt
details:   yt/rev/d803e02a89d8
changeset: 1761:d803e02a89d8
user:      britton
date:
Mon Jun 07 16:34:06 2010 -0400
description:
[svn r1746] Caught one more file needing naming convention change.

hg Repository: yt
details:   yt/rev/f4c03d6a485f
changeset: 1762:f4c03d6a485f
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Jun 07 23:43:07 2010 -0400
description:
Merging.  Hopefully ... got rid of all case change problems.

hg Repository: yt
details:   yt/rev/7e381df9ded8
changeset: 1763:7e381df9ded8
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Jun 07 23:45:30 2010 -0400
description:
Merge

diffstat:

 .hgignore                                             |     3 +
 scripts/fbranch                                       |     5 +-
 scripts/fbury                                         |     5 +-
 scripts/fdigup                                        |     5 +-
 scripts/fido                                          |     5 +-
 scripts/fimport                                       |     5 +-
 yt/_amr_utils/FixedInterpolator.c                     |    26 +-
 yt/_amr_utils/FixedInterpolator.h                     |     2 +
 yt/_amr_utils/Octree.pyx                              |   280 +
 yt/_amr_utils/QuadTree.pyx                            |   257 +
 yt/_amr_utils/VolumeIntegrator.pyx                    |    43 +-
 yt/_amr_utils/png_writer.pyx                          |     4 +-
 yt/amr_utils.c                                        |  5451 ++++++++++++++++------
 yt/amr_utils.pyx                                      |     1 +
 yt/arraytypes.py                                      |    11 +
 yt/extensions/DualEPS.py                              |   699 ++
 yt/extensions/HaloMassFcn.py                          |   726 ---
 yt/extensions/MergerTree.py                           |   890 ---
 yt/extensions/halo_mass_function.py                   |   736 +++
 yt/extensions/kdtree/fKD.f90                          |   173 +-
 yt/extensions/kdtree/fKD.v                            |    42 +-
 yt/extensions/kdtree/fKD_source.f90                   |    10 +-
 yt/extensions/lightcone/__init__.py                   |     2 +-
 yt/extensions/merger_tree.py                          |   893 +++
 yt/extensions/opengl_widgets/calculateRay.vertex.glsl |    63 +
 yt/extensions/opengl_widgets/colormap.fragment.glsl   |    12 +
 yt/extensions/opengl_widgets/framebuffer.vertex.glsl  |    12 +
 yt/extensions/opengl_widgets/mip.fragment.glsl        |   135 +
 yt/extensions/opengl_widgets/mip_viewer.py            |   450 +
 yt/extensions/opengl_widgets/rendering_contexts.py    |    88 +
 yt/extensions/volume_rendering/multi_texture.py       |   302 +
 yt/fido/share_data.py                                 |    83 +
 yt/lagos/BaseDataTypes.py                             |     1 -
 yt/lagos/Clump.py                                     |   290 -
 yt/lagos/HaloFinding.py                               |   137 +-
 yt/lagos/OutputTypes.py                               |    19 +-
 yt/lagos/StructureFunctionGenerator.py                |   750 ---
 yt/lagos/TwoPointFunctions.py                         |   796 +++
 yt/lagos/__init__.py                                  |     4 +-
 yt/lagos/clump.py                                     |   290 -
 yt/lagos/clump_handling.py                            |   290 +
 yt/lagos/parallelHOP/parallelHOP.py                   |     9 +-
 yt/mods.py                                            |     2 +-
 yt/raven/PlotTypes.py                                 |     6 +-
 yt/raven/plot_collection.py                           |  1133 ++++-
 yt/reason/plot_editors.py                             |    10 +-
 yt/reason/reason_v2.py                                |     5 +-
 yt/reason/tvtk_interface.py                           |     5 +-
 48 files changed, 10438 insertions(+), 4728 deletions(-)

diffs (truncated from 24019 to 300 lines):

diff -r ea258e3dfc95 -r 7e381df9ded8 .hgignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Mon Jun 07 23:45:30 2010 -0400
@@ -0,0 +1,3 @@
+syntax: glob
+*.pyc
+.*.swp
diff -r ea258e3dfc95 -r 7e381df9ded8 scripts/fbranch
--- a/scripts/fbranch	Mon Jun 07 14:38:23 2010 -0400
+++ b/scripts/fbranch	Mon Jun 07 23:45:30 2010 -0400
@@ -1,1 +1,4 @@
-basic.py
\ No newline at end of file
+#!python2.5
+import yt.fido
+
+yt.fido.runAction()
diff -r ea258e3dfc95 -r 7e381df9ded8 scripts/fbury
--- a/scripts/fbury	Mon Jun 07 14:38:23 2010 -0400
+++ b/scripts/fbury	Mon Jun 07 23:45:30 2010 -0400
@@ -1,1 +1,4 @@
-basic.py
\ No newline at end of file
+#!python2.5
+import yt.fido
+
+yt.fido.runAction()
diff -r ea258e3dfc95 -r 7e381df9ded8 scripts/fdigup
--- a/scripts/fdigup	Mon Jun 07 14:38:23 2010 -0400
+++ b/scripts/fdigup	Mon Jun 07 23:45:30 2010 -0400
@@ -1,1 +1,4 @@
-basic.py
\ No newline at end of file
+#!python2.5
+import yt.fido
+
+yt.fido.runAction()
diff -r ea258e3dfc95 -r 7e381df9ded8 scripts/fido
--- a/scripts/fido	Mon Jun 07 14:38:23 2010 -0400
+++ b/scripts/fido	Mon Jun 07 23:45:30 2010 -0400
@@ -1,1 +1,4 @@
-basic.py
\ No newline at end of file
+#!python2.5
+from yt.mods import *
+
+fido.runAction()
diff -r ea258e3dfc95 -r 7e381df9ded8 scripts/fimport
--- a/scripts/fimport	Mon Jun 07 14:38:23 2010 -0400
+++ b/scripts/fimport	Mon Jun 07 23:45:30 2010 -0400
@@ -1,1 +1,4 @@
-basic.py
\ No newline at end of file
+#!python2.5
+from yt.mods import *
+
+fido.runAction()
diff -r ea258e3dfc95 -r 7e381df9ded8 yt/_amr_utils/FixedInterpolator.c
--- a/yt/_amr_utils/FixedInterpolator.c	Mon Jun 07 14:38:23 2010 -0400
+++ b/yt/_amr_utils/FixedInterpolator.c	Mon Jun 07 23:45:30 2010 -0400
@@ -28,8 +28,9 @@
 
 #define VINDEX(A,B,C) data[((((A)+ci[0])*(ds[1]+1)+((B)+ci[1]))*(ds[2]+1)+ci[2]+(C))]
 //  (((C*ds[1])+B)*ds[0]+A)
+#define OINDEX(A,B,C) data[(A)*(ds[1]+1)*(ds[2]+1)+(B)*ds[2]+(B)+(C)]
 
-npy_float64 fast_interpolate(int *ds, int *ci, npy_float64 *dp,
+npy_float64 fast_interpolate(int ds[3], int ci[3], npy_float64 dp[3],
                              npy_float64 *data)
 {
     int i;
@@ -48,7 +49,28 @@
     return dv;
 }
 
-npy_float64 trilinear_interpolate(int *ds, int *ci, npy_float64 *dp,
+npy_float64 offset_interpolate(int ds[3], npy_float64 dp[3], npy_float64 *data)
+{
+    int i;
+    npy_float64 dv, vz[4];
+
+    dv = 1.0 - dp[2];
+    vz[0] = dv*OINDEX(0,0,0) + dp[2]*OINDEX(0,0,1);
+    vz[1] = dv*OINDEX(0,1,0) + dp[2]*OINDEX(0,1,1);
+    vz[2] = dv*OINDEX(1,0,0) + dp[2]*OINDEX(1,0,1);
+    vz[3] = dv*OINDEX(1,1,0) + dp[2]*OINDEX(1,1,1);
+
+    dv = 1.0 - dp[1];
+    vz[0] = dv*vz[0] + dp[1]*vz[1];
+    vz[1] = dv*vz[2] + dp[1]*vz[3];
+
+    dv = 1.0 - dp[0];
+    vz[0] = dv*vz[0] + dp[0]*vz[1];
+
+    return vz[0];
+}
+
+npy_float64 trilinear_interpolate(int ds[3], int ci[3], npy_float64 dp[3],
 				  npy_float64 *data)
 {
     /* dims is one less than the dimensions of the array */
diff -r ea258e3dfc95 -r 7e381df9ded8 yt/_amr_utils/FixedInterpolator.h
--- a/yt/_amr_utils/FixedInterpolator.h	Mon Jun 07 14:38:23 2010 -0400
+++ b/yt/_amr_utils/FixedInterpolator.h	Mon Jun 07 23:45:30 2010 -0400
@@ -36,6 +36,8 @@
 npy_float64 fast_interpolate(int ds[3], int ci[3], npy_float64 dp[3],
                              npy_float64 *data);
 
+npy_float64 offset_interpolate(int ds[3], npy_float64 dp[3], npy_float64 *data);
+
 npy_float64 trilinear_interpolate(int ds[3], int ci[3], npy_float64 dp[3],
 				  npy_float64 *data);
 
diff -r ea258e3dfc95 -r 7e381df9ded8 yt/_amr_utils/Octree.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/_amr_utils/Octree.pyx	Mon Jun 07 23:45:30 2010 -0400
@@ -0,0 +1,280 @@
+"""
+A refine-by-two AMR-specific octree
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: UCSD
+Homepage: http://yt.enzotools.org/
+License:
+  Copyright (C) 2010 Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+
+import numpy as np
+cimport numpy as np
+# Double up here for def'd functions
+cimport numpy as cnp
+cimport cython
+
+from stdlib cimport malloc, free, abs
+
+cdef extern from "stdlib.h":
+    # NOTE that size_t might not be int
+    void *alloca(int)
+
+cdef struct OctreeNode:
+    np.float64_t *val
+    np.float64_t weight_val
+    np.int64_t pos[3]
+    int level
+    int nvals
+    OctreeNode *children[2][2][2]
+
+cdef void OTN_add_value(OctreeNode *self,
+        np.float64_t *val, np.float64_t weight_val):
+    cdef int i
+    for i in range(self.nvals):
+        self.val[i] += val[i]
+    self.weight_val += weight_val
+
+cdef void OTN_refine(OctreeNode *self):
+    cdef int i, j, i1, j1
+    cdef np.int64_t npos[3]
+    cdef OctreeNode *node
+    for i in range(2):
+        npos[0] = self.pos[0] * 2 + i
+        for j in range(2):
+            npos[1] = self.pos[1] * 2 + j
+            # We have to be careful with allocation...
+            for k in range(2):
+                npos[2] = self.pos[2] * 2 + k
+                self.children[i][j][k] = OTN_initialize(
+                            npos,
+                            self.nvals, self.val, self.weight_val,
+                            self.level + 1)
+    for i in range(self.nvals): self.val[i] = 0.0
+    self.weight_val = 0.0
+
+cdef OctreeNode *OTN_initialize(np.int64_t pos[3], int nvals,
+                        np.float64_t *val, np.float64_t weight_val,
+                        int level):
+    cdef OctreeNode *node
+    cdef int i, j
+    node = <OctreeNode *> malloc(sizeof(OctreeNode))
+    node.pos[0] = pos[0]
+    node.pos[1] = pos[1]
+    node.pos[2] = pos[2]
+    node.nvals = nvals
+    node.val = <np.float64_t *> malloc(
+                nvals * sizeof(np.float64_t))
+    for i in range(nvals):
+        node.val[i] = val[i]
+    node.weight_val = weight_val
+    for i in range(2):
+        for j in range(2):
+            for k in range(2):
+                node.children[i][j][k] = NULL
+    node.level = level
+    return node
+
+cdef void OTN_free(OctreeNode *node):
+    cdef int i, j
+    for i in range(2):
+        for j in range(2):
+            for k in range(2):
+                if node.children[i][j][k] == NULL: continue
+                OTN_free(node.children[i][j][k])
+    free(node.val)
+    free(node)
+
+cdef class Octree:
+    cdef int nvals
+    cdef np.int64_t po2[80]
+    cdef OctreeNode ****root_nodes
+    cdef np.int64_t top_grid_dims[3]
+
+    def __cinit__(self, np.ndarray[np.int64_t, ndim=1] top_grid_dims,
+                  int nvals):
+        cdef int i, j
+        cdef OctreeNode *node
+        cdef np.int64_t pos[3]
+        cdef np.float64_t *vals = <np.float64_t *> alloca(
+                sizeof(np.float64_t)*nvals)
+        cdef np.float64_t weight_val = 0.0
+        self.nvals = nvals
+        for i in range(nvals): vals[i] = 0.0
+
+        self.top_grid_dims[0] = top_grid_dims[0]
+        self.top_grid_dims[1] = top_grid_dims[1]
+        self.top_grid_dims[2] = top_grid_dims[2]
+
+        # This wouldn't be necessary if we did bitshifting...
+        for i in range(80):
+            self.po2[i] = 2**i
+        # Cython doesn't seem to like sizeof(OctreeNode ***)
+        self.root_nodes = <OctreeNode ****> \
+            malloc(sizeof(void*) * top_grid_dims[0])
+
+        # We initialize our root values to 0.0.
+        for i in range(top_grid_dims[0]):
+            pos[0] = i
+            self.root_nodes[i] = <OctreeNode ***> \
+                malloc(sizeof(OctreeNode **) * top_grid_dims[1])
+            for j in range(top_grid_dims[1]):
+                pos[1] = j
+                self.root_nodes[i][j] = <OctreeNode **> \
+                    malloc(sizeof(OctreeNode *) * top_grid_dims[1])
+                for k in range(top_grid_dims[2]):
+                    pos[2] = k
+                    self.root_nodes[i][j][k] = OTN_initialize(
+                        pos, nvals, vals, weight_val, 0)
+
+    cdef void add_to_position(self,
+                 int level, np.int64_t pos[3],
+                 np.float64_t *val,
+                 np.float64_t weight_val):
+        cdef int i, j
+        cdef OctreeNode *node
+        node = self.find_on_root_level(pos, level)
+        cdef np.int64_t fac
+        for L in range(level):
+            if node.children[0][0][0] == NULL:
+                OTN_refine(node)
+            # Maybe we should use bitwise operators?
+            fac = self.po2[level - L - 1]
+            i = (pos[0] >= fac*(2*node.pos[0]+1))
+            j = (pos[1] >= fac*(2*node.pos[1]+1))
+            k = (pos[2] >= fac*(2*node.pos[2]+1))
+            node = node.children[i][j][k]
+        OTN_add_value(node, val, weight_val)
+            
+    cdef OctreeNode *find_on_root_level(self, np.int64_t pos[3], int level):
+        # We need this because the root level won't just have four children
+        # So we find on the root level, then we traverse the tree.
+        cdef np.int64_t i, j
+        i = <np.int64_t> (pos[0] / self.po2[level])
+        j = <np.int64_t> (pos[1] / self.po2[level])
+        k = <np.int64_t> (pos[2] / self.po2[level])
+        return self.root_nodes[i][j][k]
+        
+    
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
+    def add_array_to_tree(self, int level,
+            np.ndarray[np.int64_t, ndim=1] pxs,
+            np.ndarray[np.int64_t, ndim=1] pys,
+            np.ndarray[np.int64_t, ndim=1] pzs,
+            np.ndarray[np.float64_t, ndim=2] pvals,
+            np.ndarray[np.float64_t, ndim=1] pweight_vals):
+        cdef int np = pxs.shape[0]



More information about the yt-svn mailing list