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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Mar 23 22:03:38 PDT 2014


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/0740ec5cbb46/
Changeset:   0740ec5cbb46
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-23 22:28:22
Summary:     Cleaning up a bit of grid_traversal.pyx.
Affected #:  1 file

diff -r 233a27edec6ff7a1855b36aa096b05361ebd7759 -r 0740ec5cbb466024644cc9ef6719e02d61836157 yt/utilities/lib/grid_traversal.pyx
--- a/yt/utilities/lib/grid_traversal.pyx
+++ b/yt/utilities/lib/grid_traversal.pyx
@@ -18,6 +18,8 @@
 cimport cython
 #cimport healpix_interface
 from libc.stdlib cimport malloc, free, abs
+from libc.math cimport exp, floor, log2, \
+    lrint, fabs, atan, asin, cos, sin, sqrt
 from fp_utils cimport imax, fmax, imin, fmin, iclip, fclip, i64clip
 from field_interpolation_tables cimport \
     FieldInterpolationTable, FIT_initialize_table, FIT_eval_transfer,\
@@ -28,25 +30,6 @@
 
 DEF Nch = 4
 
-cdef extern from "math.h":
-    double exp(double x) nogil
-    float expf(float x) nogil
-    long double expl(long double x) nogil
-    double floor(double x) nogil
-    double ceil(double x) nogil
-    double fmod(double x, double y) nogil
-    double log2(double x) nogil
-    long int lrint(double x) nogil
-    double nearbyint(double x) nogil
-    double fabs(double x) nogil
-    double atan(double x) nogil
-    double atan2(double y, double x) nogil
-    double acos(double x) nogil
-    double asin(double x) nogil
-    double cos(double x) nogil
-    double sin(double x) nogil
-    double sqrt(double x) nogil
-
 ctypedef void sampler_function(
                 VolumeContainer *vc,
                 np.float64_t v_pos[3],


https://bitbucket.org/yt_analysis/yt/commits/46e74b94e170/
Changeset:   46e74b94e170
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-24 05:14:03
Summary:     Removing HomogenizedVolume.
Affected #:  4 files

diff -r 0740ec5cbb466024644cc9ef6719e02d61836157 -r 46e74b94e170993075cac9d6df43b899226e1652 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -161,7 +161,7 @@
 
 from yt.visualization.volume_rendering.api import \
     ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \
-    HomogenizedVolume, Camera, off_axis_projection, MosaicFisheyeCamera
+    Camera, off_axis_projection, MosaicFisheyeCamera
 
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     parallel_objects

diff -r 0740ec5cbb466024644cc9ef6719e02d61836157 -r 46e74b94e170993075cac9d6df43b899226e1652 yt/visualization/volume_rendering/api.py
--- a/yt/visualization/volume_rendering/api.py
+++ b/yt/visualization/volume_rendering/api.py
@@ -17,9 +17,6 @@
                              PlanckTransferFunction, \
                              MultiVariateTransferFunction, \
                              ProjectionTransferFunction
-from grid_partitioner import HomogenizedVolume, \
-                             export_partitioned_grids, \
-                             import_partitioned_grids
 from image_handling import export_rgba, import_rgba, \
                            plot_channel, plot_rgb
 

diff -r 0740ec5cbb466024644cc9ef6719e02d61836157 -r 46e74b94e170993075cac9d6df43b899226e1652 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -21,7 +21,6 @@
 from yt.units.yt_array import YTArray
 from copy import deepcopy
 
-from .grid_partitioner import HomogenizedVolume
 from .transfer_functions import ProjectionTransferFunction
 
 from yt.utilities.lib.grid_traversal import \
@@ -1513,12 +1512,10 @@
 
     def build_volume(self, volume, fields, log_fields, l_max, no_ghost, tree_type, le, re):
         if volume is None:
-            if self.use_kd:
-                volume = AMRKDTree(self.pf, l_max=l_max, fields=self.fields, 
-                                   no_ghost=no_ghost, tree_type=tree_type, 
-                                   log_fields=log_fields, le=le, re=re)
-            else:
-                volume = HomogenizedVolume(fields, pf=self.pf, log_fields=log_fields)
+            if self.use_kd: raise NotImplementedError
+            volume = AMRKDTree(self.pf, l_max=l_max, fields=self.fields, 
+                               no_ghost=no_ghost, tree_type=tree_type, 
+                               log_fields=log_fields, le=le, re=re)
         else:
             self.use_kd = isinstance(volume, AMRKDTree)
         return volume

diff -r 0740ec5cbb466024644cc9ef6719e02d61836157 -r 46e74b94e170993075cac9d6df43b899226e1652 yt/visualization/volume_rendering/grid_partitioner.py
--- a/yt/visualization/volume_rendering/grid_partitioner.py
+++ /dev/null
@@ -1,250 +0,0 @@
-"""
-Import the components of the volume rendering extension
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, 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.funcs import *
-import h5py
-
-from yt.utilities.lib.grid_traversal import PartitionedGrid, ProtoPrism, GridFace
-from yt.utilities.parallel_tools.parallel_analysis_interface import \
-    ParallelAnalysisInterface, parallel_root_only
-
-# HISTORICAL NOTE OF SOME IMPORT:
-#   The homogenized brick class should and will be removed.  The more general,
-#   and less fancy-parallel, HomogenizedVolume is the way to go.  The HBC is a
-#   complicated mechanism that was designed for back when we were going to be
-#   passing bricks all around between processors.
-
-class HomogenizedVolume(ParallelAnalysisInterface):
-    bricks = None
-    def __init__(self, fields = "Density", source = None, pf = None,
-                 log_fields = None, no_ghost = False,
-                 max_level = 48):
-        # Typically, initialized as hanging off a index.  But, not always.
-        ParallelAnalysisInterface.__init__(self)
-        self.no_ghost = no_ghost
-        if pf is not None: self.pf = pf
-        if source is None: source = self.pf.h.all_data()
-        self.source = source
-        self.fields = ensure_list(fields)
-        if log_fields is not None:
-            log_fields = ensure_list(log_fields)
-        else:
-            log_fields = [self.pf.field_info[field].take_log
-                         for field in self.fields]
-        self.max_level = max_level
-        self.log_fields = log_fields
-
-    def traverse(self, back_point, front_point, image):
-        mylog.info("Traversing %s bricks between %s and %s",
-                   len(self.bricks), back_point, front_point)
-        if self.bricks is None: self.initialize_source()
-        vec = front_point - back_point
-        dist = np.minimum(
-             np.sum((self.brick_left_edges - back_point) * vec, axis=1),
-             np.sum((self.brick_right_edges - back_point) * vec, axis=1))
-        ind = np.argsort(dist)
-        for b in self.bricks[ind]:
-            #print b.LeftEdge, b.RightEdge
-            yield b
-
-    def _partition_grid(self, grid):
-
-        # This is not super efficient, as it re-fills the regions once for each
-        # field.
-        vcds = []
-        for field, log_field in zip(self.fields, self.log_fields):
-            vcd = grid.get_vertex_centered_data(field, no_ghost = self.no_ghost)
-            vcd = vcd.astype("float64")
-            if log_field: vcd = np.log10(vcd)
-            vcds.append(vcd)
-
-        GF = GridFaces(grid.Children + [grid])
-        PP = ProtoPrism(grid.id, grid.LeftEdge, grid.RightEdge, GF)
-
-        pgs = []
-        cm = grid.child_mask.copy()
-        if grid.Level > self.max_level:
-            return pgs
-        elif grid.Level == self.max_level:
-            cm[:] = 1
-        for P in PP.sweep(0):
-            sl = P.get_brick(grid.LeftEdge, grid.dds, cm)
-            if len(sl) == 0: continue
-            dd = [d[sl[0][0]:sl[0][1]+1,
-                    sl[1][0]:sl[1][1]+1,
-                    sl[2][0]:sl[2][1]+1].copy() for d in vcds]
-            pgs.append(PartitionedGrid(grid.id, dd,
-                        P.LeftEdge, P.RightEdge, sl[-1]))
-        return pgs
-
-    def initialize_source(self, source = None):
-        if self.bricks is not None and source is not None:
-            raise NotImplementedError("Sorry, dynamic shuffling of bricks is" + 
-                                      " not yet supported")
-        if self.bricks is not None and source is None: return
-        bricks = []
-        self.comm.preload(self.source._grids, self.fields, self.pf.h.io)
-        pbar = get_pbar("Partitioning ", len(self.source._grids))
-        for i, g in enumerate(self.source._grids):
-            pbar.update(i)
-            bricks += self._partition_grid(g)
-        pbar.finish()
-        self.initialize_bricks(bricks)
-
-    def initialize_bricks(self, bricks):
-        NB = len(bricks)
-        # Now we set up our (local for now) index.  Note that to calculate
-        # intersection, we only need to do the left edge & right edge.
-        #
-        # We're going to double up a little bit here in memory.
-        self.brick_left_edges = np.zeros( (NB, 3), dtype='float64')
-        self.brick_right_edges = np.zeros( (NB, 3), dtype='float64')
-        self.brick_parents = np.zeros( NB, dtype='int64')
-        self.brick_dimensions = np.zeros( (NB, 3), dtype='int64')
-        self.bricks = np.empty(len(bricks), dtype='object')
-        for i,b in enumerate(bricks):
-            self.brick_left_edges[i,:] = b.LeftEdge
-            self.brick_right_edges[i,:] = b.RightEdge
-            self.brick_parents[i] = b.parent_grid_id
-            self.brick_dimensions[i,:] = b.my_data[0].shape
-            self.bricks[i] = b
-        # Vertex-centered means we subtract one from the shape
-        self.brick_dimensions -= 1
-
-    def reflect_across_boundaries(self):
-        mylog.warning("Note that this doesn't fix ghost zones, so there may be artifacts at domain boundaries!")
-        nb = []
-        # Simplest, clearest iteration ...
-        for i in [-1, 1]:
-            for j in [-1, 1]:
-                for k in [-1, 1]:
-                    for b in self.bricks:
-                        BB = np.array([b.LeftEdge * [i,j,k], b.RightEdge * [i,j,k]])
-                        LE, RE = np.min(BB, axis=0), np.max(BB, axis=0)
-                        nb.append(
-                            PartitionedGrid(b.parent_grid_id, len(b.my_data), 
-                                [md[::i,::j,::k].copy("C") for md in b.my_data],
-                                LE, RE, np.array(b.my_data[0].shape) - 1))
-        # Replace old bricks
-        self.initialize_bricks(nb)
-
-    def store_bricks(self, fn):
-        import h5py, cPickle
-        f = h5py.File(fn, "w")
-        f.create_dataset("/left_edges", data=self.brick_left_edges)
-        f.create_dataset("/right_edges", data=self.brick_right_edges)
-        f.create_dataset("/parents", data=self.brick_parents)
-        f.create_dataset("/dimensions", data=self.brick_dimensions)
-        f.create_group("/bricks")
-        for i,b in enumerate(self.bricks):
-            f.create_group("/bricks/brick_%08i" % i)
-            for fi,field in enumerate(self.fields):
-                f.create_dataset("/bricks/brick_%08i/%s" % (i, field),
-                                 data=b.my_data[fi])
-        f.close()
-
-    def load_bricks(self, fn):
-        import h5py
-        f = h5py.File(fn, "r")
-        self.brick_left_edges = f["/left_edges"][:]
-        self.brick_right_edges = f["/right_edges"][:]
-        self.brick_parents = f["/parents"][:]
-        self.brick_dimensions= f["/dimensions"][:]
-        bricks = []
-        for i,ds in enumerate(sorted(f["/bricks"])):
-            td = [f["/bricks/%s/%s" % (ds, field)][:] for field in self.fields]
-            bricks.append(PartitionedGrid(
-                                self.brick_parents[i], len(td), td,
-                                self.brick_left_edges[i,:],
-                                self.brick_right_edges[i,:],
-                                self.brick_dimensions[i,:],
-                                ))
-        self.bricks = np.array(bricks, dtype='object')
-        f.close()
-
-    def reset_cast(self):
-        pass
-
-class SingleBrickVolume(object):
-    bricks = None
-    def __init__(self, data_array):
-        self.bricks = [PartitionedGrid(-1, 1, 
-                       [data_array.astype("float64")],
-                       np.zeros(3, dtype='float64'),
-                       np.ones(3, dtype='float64'),
-                       np.array(data_array.shape, dtype='int64')-1)]
-        self.brick_dimensions = np.ones((1, 3), dtype='int64')*data_array.shape
-
-    def initialize_source(self):
-        pass
-
-    def traverse(self, back, front, image):
-        for b in self.bricks: yield b
-
-    def reset_cast(self):
-        pass
-
-class GridFaces(object):
-    def __init__(self, grids):
-        self.faces = [ [], [], [] ]
-        for grid in grids:
-            for direction in range(3):
-                self.faces[direction].append( GridFace(grid, direction, 1) )
-                self.faces[direction].append( GridFace(grid, direction, 0) )
-        for f in self.faces:
-            f.sort(key = lambda a: a.coord)
-
-    def __getitem__(self, item):
-        return self.faces[item]
-
-def export_partitioned_grids(grid_list, fn, int_type=np.int64, float_type=np.float64):
-    f = h5py.File(fn, "w")
-    pbar = get_pbar("Writing Grids", len(grid_list))
-    nelem = sum((grid.my_data.size for grid in grid_list))
-    ngrids = len(grid_list)
-    group = f.create_group("/PGrids")
-    left_edge = np.concatenate([[grid.LeftEdge,] for grid in grid_list])
-    f.create_dataset("/PGrids/LeftEdges", data=left_edge, dtype=float_type); del left_edge
-    right_edge = np.concatenate([[grid.RightEdge,] for grid in grid_list])
-    f.create_dataset("/PGrids/RightEdges", data=right_edge, dtype=float_type); del right_edge
-    dims = np.concatenate([[grid.my_data.shape[:],] for grid in grid_list])
-    f.create_dataset("/PGrids/Dims", data=dims, dtype=int_type); del dims
-    data = np.concatenate([grid.my_data.ravel() for grid in grid_list])
-    f.create_dataset("/PGrids/Data", data=data, dtype=float_type); del data
-    f.close()
-    pbar.finish()
-
-def import_partitioned_grids(fn, int_type=np.int64, float_type=np.float64):
-    f = h5py.File(fn, "r")
-    n_groups = len(f)
-    grid_list = []
-    dims = f["/PGrids/Dims"][:].astype(int_type)
-    left_edges = f["/PGrids/LeftEdges"][:].astype(float_type)
-    right_edges = f["/PGrids/RightEdges"][:].astype(float_type)
-    data = f["/PGrids/Data"][:].astype(float_type)
-    pbar = get_pbar("Reading Grids", dims.shape[0])
-    curpos = 0
-    for i in xrange(dims.shape[0]):
-        gd = dims[i,:]
-        gle, gre = left_edges[i,:], right_edges[i,:]
-        gdata = data[curpos:curpos+gd.prod()].reshape(gd)
-        # Vertex -> Grid, so we -1 from dims in this
-        grid_list.append(PartitionedGrid(-1, gdata, gle, gre, gd - 1))
-        curpos += gd.prod()
-        pbar.update(i)
-    pbar.finish()
-    f.close()
-    return np.array(grid_list, dtype='object')


https://bitbucket.org/yt_analysis/yt/commits/209d98b21916/
Changeset:   209d98b21916
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-24 05:18:44
Summary:     Removing unused functions and files.
Affected #:  3 files

This diff is so big that we needed to truncate the remainder.

https://bitbucket.org/yt_analysis/yt/commits/d25600daca2f/
Changeset:   d25600daca2f
Branch:      yt-3.0
User:        samskillman
Date:        2014-03-24 06:03:32
Summary:     Merged in MatthewTurk/yt/yt-3.0 (pull request #744)

Cleaning up a bit of grid_traversal.pyx.
Affected #:  7 files

diff -r 8165508993d62455bb511360d40208f78c3a5a82 -r d25600daca2f3d21df48c4b97abdb782eb673169 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -161,7 +161,7 @@
 
 from yt.visualization.volume_rendering.api import \
     ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \
-    HomogenizedVolume, Camera, off_axis_projection, MosaicFisheyeCamera
+    Camera, off_axis_projection, MosaicFisheyeCamera
 
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     parallel_objects

This diff is so big that we needed to truncate the remainder.

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