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

Bitbucket commits-noreply at bitbucket.org
Fri Jan 20 10:28:53 PST 2012


15 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/598a00f550dd/
changeset:   598a00f550dd
branch:      yt
user:        samskillman
date:        2012-01-18 04:15:15
summary:     Reworking some vectors in the MosaicFisheyeCamera.  It now accepts both a center and a focal_center.  Also adding a rotation function which defaults to keeping the focus of the camera in the center and spinning around it.  It can be switched with keep_focus=False, and the camera itself with spin.
affected #:  2 files

diff -r 62c106c602a98c29debbc0dd1eb0f48292d8cf6e -r 598a00f550dd505a91febdb25836692e66547c53 yt/utilities/_amr_utils/VolumeIntegrator.pyx
--- a/yt/utilities/_amr_utils/VolumeIntegrator.pyx
+++ b/yt/utilities/_amr_utils/VolumeIntegrator.pyx
@@ -68,6 +68,7 @@
     double cos(double x)
     double sin(double x)
     double asin(double x)
+    double acos(double x)
 
 cdef struct Triangle:
     Triangle *next
@@ -242,7 +243,8 @@
     return tr
 
 def arr_fisheye_vectors(int resolution, np.float64_t fov, int nimx=1, int
-        nimy=1, int nimi=0, int nimj=0):
+        nimy=1, int nimi=0, int nimj=0, np.float64_t off_theta=0.0, np.float64_t
+        off_phi=0.0):
     # We now follow figures 4-7 of:
     # http://paulbourke.net/miscellaneous/domefisheye/fisheye/
     # ...but all in Cython.
@@ -266,11 +268,25 @@
             else:
                 phi = asin(py / r)
             theta = r * fov_rad / 2.0
+            theta += off_theta
+            phi += off_phi
             vp[i,j,0] = sin(theta) * cos(phi)
             vp[i,j,1] = sin(theta) * sin(phi)
             vp[i,j,2] = cos(theta)
     return vp
 
+def rotate_vectors(np.ndarray[np.float64_t, ndim=3] vecs,
+        np.ndarray[np.float64_t, ndim=2] R):
+    cdef int nx = vecs.shape[0]
+    cdef int ny = vecs.shape[1]
+    rotated = np.empty((nx,ny,3),dtype='float64') 
+    for i in range(nx):
+        for j in range(ny):
+            for k in range(3):
+                rotated[i,j,k] =\
+                    R[k,0]*vecs[i,j,0]+R[k,1]*vecs[i,j,1]+R[k,2]*vecs[i,j,2]
+    return rotated
+
 cdef class star_kdtree_container:
     cdef kdtree_utils.kdtree *tree
     cdef public np.float64_t sigma


diff -r 62c106c602a98c29debbc0dd1eb0f48292d8cf6e -r 598a00f550dd505a91febdb25836692e66547c53 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -32,13 +32,38 @@
 
 from yt.utilities.amr_utils import TransferFunctionProxy, VectorPlane, \
     arr_vec2pix_nest, arr_pix2vec_nest, AdaptiveRaySource, \
-    arr_ang2pix_nest, arr_fisheye_vectors
+    arr_ang2pix_nest, arr_fisheye_vectors, rotate_vectors
 from yt.visualization.image_writer import write_bitmap
 from yt.data_objects.data_containers import data_object_registry
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     ParallelAnalysisInterface, ProcessorPool
 from yt.utilities.amr_kdtree.api import AMRKDTree
 from numpy import pi
+from time import time
+def get_rotation_matrix_euler(phi,theta,psi):
+    cost = na.cos(theta)
+    sint = na.sin(theta)
+    cosp = na.cos(phi)
+    sinp = na.sin(phi)
+    coss = na.cos(psi)
+    sins = na.sin(psi)
+    R = na.array([[cost*coss, -cosp*sins + sinp*sint*coss, sinp*sins + cosp*sint*coss],
+                  [cost*sins, cosp*coss + sinp*sint*sins, -sinp*coss + cosp*sint*sins],
+                  [-sint, sinp*cost, cosp*cost]])
+    return R
+
+def get_rotation_matrix(theta, rot_vector):
+    ux = rot_vector[0]
+    uy = rot_vector[1]
+    uz = rot_vector[2]
+    cost = na.cos(theta)
+    sint = na.sin(theta)
+    
+    R = na.array([[cost+ux**2*(1-cost), ux*uy*(1-cost)-uz*sint, ux*uz*(1-cost)+uy*sint],
+                  [uy*ux*(1-cost)+uz*sint, cost+uy**2*(1-cost), uy*uz*(1-cost)-ux*sint],
+                  [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
+
+    return R
 
 class Camera(ParallelAnalysisInterface):
     def __init__(self, center, normal_vector, width,
@@ -800,7 +825,7 @@
                  pf = None, no_ghost=False, rotation = None):
         ParallelAnalysisInterface.__init__(self)
         if rotation is None: rotation = na.eye(3)
-        self.rotation = rotation
+        self.rotation_matrix = rotation
         if pf is not None: self.pf = pf
         self.center = na.array(center, dtype='float64')
         self.radius = radius
@@ -829,7 +854,7 @@
         vp.shape = (self.resolution**2,1,3)
         vp2 = vp.copy()
         for i in range(3):
-            vp[:,:,i] = (vp2 * self.rotation[:,i]).sum(axis=2)
+            vp[:,:,i] = (vp2 * self.rotation_matrix[:,i]).sum(axis=2)
         del vp2
         vp *= self.radius
         uv = na.ones(3, dtype='float64')
@@ -853,7 +878,7 @@
         return image
 
 class MosaicFisheyeCamera(Camera):
-    def __init__(self, center, radius, fov, resolution,
+    def __init__(self, center, radius, fov, resolution, focal_center=None,
                  transfer_function = None, fields = None,
                  sub_samples = 5, log_fields = None, volume = None,
                  pf = None, l_max=None, no_ghost=False,nimx=1, nimy=1, procs_per_wg=None,
@@ -976,35 +1001,47 @@
         """
 
         ParallelAnalysisInterface.__init__(self)
-        PP = ProcessorPool()
-        if procs_per_wg is None:
-            procs_per_wg = PP.size
-        for j in range(nimy):
-            for i in range(nimx):
-                PP.add_workgroup(size=procs_per_wg, name='%04i_%04i'%(i,j))
-                
-        for wg in PP.workgroups:
-            if self.comm.rank in wg.ranks:
-                my_wg = wg
+        self.image_decomp = self.comm.size>1
+        if self.image_decomp:
+            PP = ProcessorPool()
+            if procs_per_wg is None:
+                procs_per_wg = PP.size
+            for j in range(nimy):
+                for i in range(nimx):
+                    PP.add_workgroup(size=procs_per_wg, name='%04i_%04i'%(i,j))
+                    
+            for wg in PP.workgroups:
+                if self.comm.rank in wg.ranks:
+                    my_wg = wg
+            
+            self.global_comm = self.comm
+            self.comm = my_wg.comm
+            self.wg = my_wg
+            self.imi = int(self.wg.name[0:4])
+            self.imj = int(self.wg.name[5:9])
+            print 'My new communicator has the name %s' % self.wg.name
+            self.nimx = nimx
+            self.nimy = nimy
+        else:
+            self.imi = 0
+            self.imj = 0
+            self.nimx = 1
+            self.nimy = 1
+        if pf is not None: self.pf = pf
         
-        self.global_comm = self.comm
-        self.comm = my_wg.comm
-        self.wg = my_wg
-        self.imi = int(self.wg.name[0:4])
-        self.imj = int(self.wg.name[5:9])
-        print 'My new communicator has the name %s' % self.wg.name
-
-        if pf is not None: self.pf = pf
-    
         if rotation is None: rotation = na.eye(3)
-        self.rotation = rotation
+        self.rotation_matrix = rotation
+        
+        self.normal_vector = na.array([0.,0.,1.])
+        self.north_vector = na.array([1.,0.,0.])
+        self.east_vector = na.array([0.,1.,0.])
+        self.rotation_vector = self.north_vector
 
         if iterable(resolution):
             raise RuntimeError("Resolution must be a single int")
         self.resolution = resolution
-        self.nimx = nimx
-        self.nimy = nimy
         self.center = na.array(center, dtype='float64')
+        self.focal_center = focal_center
         self.radius = radius
         self.fov = fov
         if transfer_function is None:
@@ -1018,26 +1055,48 @@
             volume = AMRKDTree(self.pf, fields=self.fields, no_ghost=no_ghost,
                                log_fields=log_fields,l_max=l_max)
         self.volume = volume
+        self.vp = None
+        self.image = None 
 
-    def snapshot(self):
+    def get_vector_plane(self):
+        if self.focal_center is not None:
+            rvec =  na.array(self.focal_center) - na.array(self.center)
+            rvec /= (rvec**2).sum()**0.5
+            angle = na.arccos( (self.normal_vector*rvec).sum()/( (self.normal_vector**2).sum()**0.5 *
+                (rvec**2).sum()**0.5))
+            rot_vector = na.cross(rvec, self.normal_vector)
+            rot_vector /= (rot_vector**2).sum()**0.5
+            
+            self.rotation_matrix = get_rotation_matrix(angle,rot_vector)
+            self.normal_vector = na.dot(self.rotation_matrix,self.normal_vector)
+            self.north_vector = na.dot(self.rotation_matrix,self.north_vector)
+            self.east_vector = na.dot(self.rotation_matrix,self.east_vector)
+        else:
+            self.focal_center = self.center + self.radius*self.normal_vector  
+        dist = ((self.focal_center - self.center)**2).sum()**0.5
         # We now follow figures 4-7 of:
         # http://paulbourke.net/miscellaneous/domefisheye/fisheye/
         # ...but all in Cython.
+        
+        self.vp = arr_fisheye_vectors(self.resolution, self.fov, self.nimx, 
+                self.nimy, self.imi, self.imj)
+        
+        self.vp = rotate_vectors(self.vp, self.rotation_matrix)
 
-        vp = arr_fisheye_vectors(self.resolution, self.fov, self.nimx,
-                self.nimy, self.imi, self.imj)
-        vp2 = vp.copy()
-        for i in range(3):
-            vp[:,:,i] = (vp2 * self.rotation[:,i]).sum(axis=2)
-        del vp2
- 
-        vp *= self.radius
-        nx, ny = vp.shape[0], vp.shape[1]
-        vp.shape = (nx*ny,1,3)
+        self.center = self.focal_center - dist*self.normal_vector
+        self.vp *= self.radius
+        nx, ny = self.vp.shape[0], self.vp.shape[1]
+        self.vp.shape = (nx*ny,1,3)
+
+    def snapshot(self):
+        if self.vp is None:
+            self.get_vector_plane()
+
+        nx,ny = self.resolution/self.nimx, self.resolution/self.nimy
         image = na.zeros((nx*ny,1,3), dtype='float64', order='C')
         uv = na.ones(3, dtype='float64')
         positions = na.ones((nx*ny, 1, 3), dtype='float64') * self.center
-        vector_plane = VectorPlane(positions, vp, self.center,
+        vector_plane = VectorPlane(positions, self.vp, self.center,
                         (0.0, 1.0, 0.0, 1.0), image, uv, uv)
         tfp = TransferFunctionProxy(self.transfer_function)
         tfp.ns = self.sub_samples
@@ -1054,6 +1113,8 @@
         pbar.finish()
         image.shape = (nx, ny, 3)
 
+        if self.image is not None:
+            del self.image
         self.image = image
        
         return image
@@ -1070,24 +1131,99 @@
         
         image = self.image
         nx,ny = self.resolution/self.nimx, self.resolution/self.nimy
+        if self.image_decomp:
+            if self.comm.rank == 0:
+                if self.global_comm.rank == 0:
+                    final_image = na.empty((nx*self.nimx, 
+                        ny*self.nimy, 3),
+                        dtype='float64',order='C')
+                    final_image[:nx, :ny, :] = image
+                    for j in range(self.nimy):
+                        for i in range(self.nimx):
+                            if i==0 and j==0: continue
+                            arr = self.global_comm.recv_array((self.wg.size)*(j*self.nimx + i), tag = (self.wg.size)*(j*self.nimx + i))
 
-        if self.comm.rank == 0:
-            if self.global_comm.rank == 0:
-                final_image = na.empty((nx*self.nimx, 
-                    ny*self.nimy, 3),
-                    dtype='float64',order='C')
-                final_image[:nx, :ny, :] = image
-                for j in range(self.nimy):
-                    for i in range(self.nimx):
-                        if i==0 and j==0: continue
-                        arr = self.global_comm.recv_array((self.wg.size)*(j*self.nimx + i), tag = (self.wg.size)*(j*self.nimx + i))
+                            final_image[i*nx:(i+1)*nx, j*ny:(j+1)*ny,:] = arr
+                            del arr
+                    write_bitmap(final_image, fn)
+                else:
+                    self.global_comm.send_array(image, 0, tag = self.global_comm.rank)
+        else:
+            if self.comm.rank == 0:
+                write_bitmap(image, fn)
+        return
 
-                        final_image[i*nx:(i+1)*nx, j*ny:(j+1)*ny,:] = arr
-                        del arr
-                write_bitmap(final_image, fn)
-            else:
-                self.global_comm.send_array(image, 0, tag = self.global_comm.rank)
-        return
+    def rotate(self, theta, rot_vector=None, keep_focus=True):
+        r"""Rotate by a given angle
+
+        Rotate the view.  If `rot_vector` is None, rotation will occur
+        around the `north_vector`.
+
+        Parameters
+        ----------
+        theta : float, in radians
+             Angle (in radians) by which to rotate the view.
+        rot_vector  : array_like, optional
+            Specify the rotation vector around which rotation will
+            occur.  Defaults to None, which sets rotation around
+            `north_vector`
+
+        Examples
+        --------
+
+        >>> cam.rotate(na.pi/4)
+        """
+        if rot_vector is None:
+            rot_vector = self.rotation_vector
+        
+        ux = rot_vector[0]
+        uy = rot_vector[1]
+        uz = rot_vector[2]
+        cost = na.cos(theta)
+        sint = na.sin(theta)
+        dist = ((self.focal_center - self.center)**2).sum()**0.5
+
+        R = na.array([[cost+ux**2*(1-cost), ux*uy*(1-cost)-uz*sint, ux*uz*(1-cost)+uy*sint],
+                      [uy*ux*(1-cost)+uz*sint, cost+uy**2*(1-cost), uy*uz*(1-cost)-ux*sint],
+                      [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
+        
+        self.vp = rotate_vectors(self.vp, R)
+        self.normal_vector = na.dot(R,self.normal_vector)
+        self.north_vector = na.dot(R,self.north_vector)
+        self.east_vector = na.dot(R,self.east_vector)
+
+        if keep_focus:
+            self.center = self.focal_center - dist*self.normal_vector
+
+    def rotation(self, theta, n_steps, rot_vector=None, keep_focus=True):
+        r"""Loop over rotate, creating a rotation
+
+        This will yield `n_steps` snapshots until the current view has been
+        rotated by an angle `theta`
+
+        Parameters
+        ----------
+        theta : float, in radians
+            Angle (in radians) by which to rotate the view.
+        n_steps : int
+            The number of look_at snapshots to make.
+        rot_vector  : array_like, optional
+            Specify the rotation vector around which rotation will
+            occur.  Defaults to None, which sets rotation around the
+            original `north_vector`
+
+        Examples
+        --------
+
+        >>> for i, snapshot in enumerate(cam.rotation(na.pi, 10)):
+        ...     iw.write_bitmap(snapshot, 'rotation_%04i.png' % i)
+        """
+
+        dtheta = (1.0*theta)/n_steps
+        for i in xrange(n_steps):
+            self.rotate(dtheta, rot_vector=rot_vector, keep_focus=keep_focus)
+            yield self.snapshot()
+
 
 def off_axis_projection(pf, center, normal_vector, width, resolution,
                         field, weight = None, volume = None, no_ghost = True):



https://bitbucket.org/yt_analysis/yt/changeset/f347ac7a4337/
changeset:   f347ac7a4337
branch:      yt
user:        samskillman
date:        2012-01-18 04:19:42
summary:     Moving some stuff around, cleaning up.
affected #:  1 file

diff -r 598a00f550dd505a91febdb25836692e66547c53 -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -39,31 +39,6 @@
     ParallelAnalysisInterface, ProcessorPool
 from yt.utilities.amr_kdtree.api import AMRKDTree
 from numpy import pi
-from time import time
-def get_rotation_matrix_euler(phi,theta,psi):
-    cost = na.cos(theta)
-    sint = na.sin(theta)
-    cosp = na.cos(phi)
-    sinp = na.sin(phi)
-    coss = na.cos(psi)
-    sins = na.sin(psi)
-    R = na.array([[cost*coss, -cosp*sins + sinp*sint*coss, sinp*sins + cosp*sint*coss],
-                  [cost*sins, cosp*coss + sinp*sint*sins, -sinp*coss + cosp*sint*sins],
-                  [-sint, sinp*cost, cosp*cost]])
-    return R
-
-def get_rotation_matrix(theta, rot_vector):
-    ux = rot_vector[0]
-    uy = rot_vector[1]
-    uz = rot_vector[2]
-    cost = na.cos(theta)
-    sint = na.sin(theta)
-    
-    R = na.array([[cost+ux**2*(1-cost), ux*uy*(1-cost)-uz*sint, ux*uz*(1-cost)+uy*sint],
-                  [uy*ux*(1-cost)+uz*sint, cost+uy**2*(1-cost), uy*uz*(1-cost)-ux*sint],
-                  [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
-
-    return R
 
 class Camera(ParallelAnalysisInterface):
     def __init__(self, center, normal_vector, width,
@@ -1067,7 +1042,7 @@
             rot_vector = na.cross(rvec, self.normal_vector)
             rot_vector /= (rot_vector**2).sum()**0.5
             
-            self.rotation_matrix = get_rotation_matrix(angle,rot_vector)
+            self.rotation_matrix = self.get_rotation_matrix(angle,rot_vector)
             self.normal_vector = na.dot(self.rotation_matrix,self.normal_vector)
             self.north_vector = na.dot(self.rotation_matrix,self.north_vector)
             self.east_vector = na.dot(self.rotation_matrix,self.east_vector)
@@ -1176,17 +1151,10 @@
         if rot_vector is None:
             rot_vector = self.rotation_vector
         
-        ux = rot_vector[0]
-        uy = rot_vector[1]
-        uz = rot_vector[2]
-        cost = na.cos(theta)
-        sint = na.sin(theta)
         dist = ((self.focal_center - self.center)**2).sum()**0.5
+        
+        R = self.get_rotation_matrix(theta, rot_vector)
 
-        R = na.array([[cost+ux**2*(1-cost), ux*uy*(1-cost)-uz*sint, ux*uz*(1-cost)+uy*sint],
-                      [uy*ux*(1-cost)+uz*sint, cost+uy**2*(1-cost), uy*uz*(1-cost)-ux*sint],
-                      [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
-        
         self.vp = rotate_vectors(self.vp, R)
         self.normal_vector = na.dot(R,self.normal_vector)
         self.north_vector = na.dot(R,self.north_vector)
@@ -1224,6 +1192,20 @@
             self.rotate(dtheta, rot_vector=rot_vector, keep_focus=keep_focus)
             yield self.snapshot()
 
+    def get_rotation_matrix(self, theta, rot_vector):
+        ux = rot_vector[0]
+        uy = rot_vector[1]
+        uz = rot_vector[2]
+        cost = na.cos(theta)
+        sint = na.sin(theta)
+        
+        R = na.array([[cost+ux**2*(1-cost), ux*uy*(1-cost)-uz*sint, ux*uz*(1-cost)+uy*sint],
+                      [uy*ux*(1-cost)+uz*sint, cost+uy**2*(1-cost), uy*uz*(1-cost)-ux*sint],
+                      [uz*ux*(1-cost)-uy*sint, uz*uy*(1-cost)+ux*sint, cost+uz**2*(1-cost)]])
+
+        return R
+
+
 
 def off_axis_projection(pf, center, normal_vector, width, resolution,
                         field, weight = None, volume = None, no_ghost = True):



https://bitbucket.org/yt_analysis/yt/changeset/5427531d038a/
changeset:   5427531d038a
branch:      yt
user:        samskillman
date:        2012-01-18 04:20:16
summary:     Merging
affected #:  7 files

diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/analysis_modules/api.py
--- a/yt/analysis_modules/api.py
+++ b/yt/analysis_modules/api.py
@@ -69,8 +69,7 @@
 from .halo_profiler.api import \
     VirialFilter, \
     HaloProfiler, \
-    FakeProfile, \
-    shift_projections
+    FakeProfile
 
 from .hierarchy_subset.api import \
     ConstructedRootGrid, \


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3351,11 +3351,13 @@
            na.any(self.right_edge + buffer > self.pf.domain_right_edge):
             grids,ind = self.pf.hierarchy.get_periodic_box_grids_below_level(
                             self.left_edge - buffer,
-                            self.right_edge + buffer, self.level)
+                            self.right_edge + buffer, self.level,
+                            min(self.level, self.pf.min_level))
         else:
             grids,ind = self.pf.hierarchy.get_box_grids_below_level(
                 self.left_edge - buffer,
-                self.right_edge + buffer, self.level)
+                self.right_edge + buffer, self.level,
+                min(self.level, self.pf.min_level))
         sort_ind = na.argsort(self.pf.h.grid_levels.ravel()[ind])
         self._grids = self.pf.hierarchy.grids[ind][(sort_ind,)][::-1]
 
@@ -3490,11 +3492,27 @@
 
     def _get_list_of_grids(self):
         if self._grids is not None: return
-        buffer = ((self.pf.domain_right_edge - self.pf.domain_left_edge)
-                 / self.pf.domain_dimensions).max()
-        AMRCoveringGridBase._get_list_of_grids(self, buffer)
+        cg = self.pf.h.covering_grid(self.level,
+            self.left_edge, self.ActiveDimensions)
+        cg._use_pbar = False
+        count = cg.ActiveDimensions.prod()
+        for g in cg._grids:
+            count -= cg._get_data_from_grid(g, [])
+            if count <= 0:
+                min_level = g.Level
+                break
         # We reverse the order to ensure that coarse grids are first
-        self._grids = self._grids[::-1]
+        if na.any(self.left_edge < self.pf.domain_left_edge) or \
+           na.any(self.right_edge > self.pf.domain_right_edge):
+            grids,ind = self.pf.hierarchy.get_periodic_box_grids_below_level(
+                            self.left_edge, self.right_edge, self.level,
+                            min_level)
+        else:
+            grids,ind = self.pf.hierarchy.get_box_grids_below_level(
+                self.left_edge, self.right_edge, self.level,
+                min(self.level, min_level))
+        sort_ind = na.argsort(self.pf.h.grid_levels.ravel()[ind])
+        self._grids = self.pf.hierarchy.grids[ind][(sort_ind,)]
 
     def get_data(self, field=None):
         self._get_list_of_grids()
@@ -3518,9 +3536,10 @@
         for gi, grid in enumerate(self._grids):
             if self._use_pbar: pbar.update(gi)
             if grid.Level > last_level and grid.Level <= self.level:
-                self._update_level_state(last_level + 1)
-                self._refine(1, fields_to_get)
-                last_level = grid.Level
+                while grid.Level > last_level:
+                    self._update_level_state(last_level + 1)
+                    self._refine(1, fields_to_get)
+                    last_level += 1
             self._get_data_from_grid(grid, fields_to_get)
         if self.level > 0:
             for field in fields_to_get:


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/data_objects/object_finding_mixin.py
--- a/yt/data_objects/object_finding_mixin.py
+++ b/yt/data_objects/object_finding_mixin.py
@@ -205,17 +205,19 @@
                     mask[gi] = True
         return self.grids[mask], na.where(mask)
 
-    def get_box_grids_below_level(self, left_edge, right_edge, level):
+    def get_box_grids_below_level(self, left_edge, right_edge, level,
+                                  min_level = 0):
         # We discard grids if they are ABOVE the level
         mask = na.empty(self.grids.size, dtype='int32')
         get_box_grids_below_level(left_edge, right_edge,
                             level,
                             self.grid_left_edge, self.grid_right_edge,
-                            self.grid_levels, mask)
+                            self.grid_levels, mask, min_level)
         mask = mask.astype("bool")
         return self.grids[mask], na.where(mask)
 
-    def get_periodic_box_grids_below_level(self, left_edge, right_edge, level):
+    def get_periodic_box_grids_below_level(self, left_edge, right_edge, level,
+                                           min_level = 0):
         mask = na.zeros(self.grids.shape, dtype='bool')
         dl = self.parameter_file.domain_left_edge
         dr = self.parameter_file.domain_right_edge
@@ -232,7 +234,8 @@
                 for off_z in [-1, 0, 1]:
                     nle[2] = (dw[2]*off_z + dl[2]) + left_dist[2]
                     nre = nle + db
-                    g, gi = self.get_box_grids_below_level(nle, nre, level)
+                    g, gi = self.get_box_grids_below_level(nle, nre,
+                                            level, min_level)
                     mask[gi] = True
         return self.grids[mask], na.where(mask)
 


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -87,6 +87,8 @@
         # to get the timing right, do this before the heavy lifting
         self._instantiated = time.time()
 
+        self.min_level = 0
+
         self._parse_parameter_file()
         self._set_units()
 


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -286,6 +286,8 @@
             [self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
         self.domain_right_edge = na.array(
             [self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
+        self.min_level = self._find_parameter(
+            "integer", "lrefine_min", scalar = False) - 1
 
         # Determine domain dimensions
         try:


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/utilities/_amr_utils/misc_utilities.pyx
--- a/yt/utilities/_amr_utils/misc_utilities.pyx
+++ b/yt/utilities/_amr_utils/misc_utilities.pyx
@@ -96,13 +96,14 @@
                         np.ndarray[np.float64_t, ndim=2] left_edges,
                         np.ndarray[np.float64_t, ndim=2] right_edges,
                         np.ndarray[np.int32_t, ndim=2] levels,
-                        np.ndarray[np.int32_t, ndim=1] mask):
+                        np.ndarray[np.int32_t, ndim=1] mask,
+                        int min_level = 0):
     cdef int i, n
     cdef int nx = left_edges.shape[0]
     cdef int inside 
     for i in range(nx):
         mask[i] = 0
-        if levels[i,0] <= level:
+        if levels[i,0] <= level and levels[i,0] >= min_level:
             inside = 1
             for n in range(3):
                 if left_edge[n] >= right_edges[i,n] or \


diff -r f347ac7a4337c28e5c11e5a1cf3c454fd383f072 -r 5427531d038a64a397f409d7b4ee9dac74f52990 yt/utilities/data_point_utilities.c
--- a/yt/utilities/data_point_utilities.c
+++ b/yt/utilities/data_point_utilities.c
@@ -1059,9 +1059,9 @@
 
     int n_fields = PyList_Size(oc_data);
     if(n_fields == 0) {
-      PyErr_Format(_dataCubeError,
+      /*PyErr_Format(_dataCubeError,
           "CombineGrids: Length zero for c_data is invalid.");
-      goto _fail;
+      goto _fail;*/
     }
     if (!PyList_Check(og_data) || (PyList_Size(og_data) != n_fields)){
       PyErr_Format(_dataCubeError,



https://bitbucket.org/yt_analysis/yt/changeset/7448e8898519/
changeset:   7448e8898519
branch:      yt
user:        samskillman
date:        2012-01-18 19:08:40
summary:     Forcing the rot_vector to be the north vector if not specified.
affected #:  1 file

diff -r 5427531d038a64a397f409d7b4ee9dac74f52990 -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1149,7 +1149,7 @@
         >>> cam.rotate(na.pi/4)
         """
         if rot_vector is None:
-            rot_vector = self.rotation_vector
+            rot_vector = self.north_vector
         
         dist = ((self.focal_center - self.center)**2).sum()**0.5
         



https://bitbucket.org/yt_analysis/yt/changeset/c4dc6c3ff45b/
changeset:   c4dc6c3ff45b
branch:      yt
user:        samskillman
date:        2012-01-18 22:00:46
summary:     Merging.
affected #:  5 files

diff -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3492,24 +3492,43 @@
 
     def _get_list_of_grids(self):
         if self._grids is not None: return
-        cg = self.pf.h.covering_grid(self.level,
-            self.left_edge, self.ActiveDimensions)
-        cg._use_pbar = False
-        count = cg.ActiveDimensions.prod()
-        for g in cg._grids:
-            count -= cg._get_data_from_grid(g, [])
-            if count <= 0:
-                min_level = g.Level
-                break
-        # We reverse the order to ensure that coarse grids are first
-        if na.any(self.left_edge < self.pf.domain_left_edge) or \
-           na.any(self.right_edge > self.pf.domain_right_edge):
+        # Check for ill-behaved AMR schemes (Enzo) where we may have
+        # root-tile-boundary issues.  This is specific to the root tiles not
+        # allowing grids to cross them and also allowing > 1 level of
+        # difference between neighboring areas.
+        nz = 0
+        buf = 0.0
+        dl = ((self.global_startindex.astype("float64") + 1)
+           / (self.pf.refine_by**self.level))
+        dr = ((self.global_startindex.astype("float64")
+              + self.ActiveDimensions - 1)
+           / (self.pf.refine_by**self.level))
+        if na.any(dl == na.rint(dl)) or na.any(dr == na.rint(dr)):
+            nz = 2 * self.pf.refine_by**self.level
+            buf = self._base_dx
+        if nz <= self.pf.refine_by**3: # delta level of 3
+            cg = self.pf.h.covering_grid(self.level,
+                self.left_edge - buf, self.ActiveDimensions + nz)
+            cg._use_pbar = False
+            count = cg.ActiveDimensions.prod()
+            for g in cg._grids:
+                count -= cg._get_data_from_grid(g, [])
+                if count <= 0:
+                    min_level = g.Level
+                    break
+        else:
+            nz = buf = 0
+            min_level = 0
+        # This should not cost substantial additional time.
+        BLE = self.left_edge - buf
+        BRE = self.right_edge + buf
+        if na.any(BLE < self.pf.domain_left_edge) or \
+           na.any(BRE > self.pf.domain_right_edge):
             grids,ind = self.pf.hierarchy.get_periodic_box_grids_below_level(
-                            self.left_edge, self.right_edge, self.level,
-                            min_level)
+                            BLE, BRE, self.level, min_level)
         else:
             grids,ind = self.pf.hierarchy.get_box_grids_below_level(
-                self.left_edge, self.right_edge, self.level,
+                BLE, BRE, self.level,
                 min(self.level, min_level))
         sort_ind = na.argsort(self.pf.h.grid_levels.ravel()[ind])
         self._grids = self.pf.hierarchy.grids[ind][(sort_ind,)]


diff -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -167,6 +167,8 @@
                 continue
             available = na.all([f in self.field_list for f in fd.requested])
             if available: self.derived_field_list.append(field)
+        [self.parameter_file.conversion_factors[field] 
+         for field in self.field_list]
         for field in self.field_list:
             if field not in self.derived_field_list:
                 self.derived_field_list.append(field)
@@ -351,6 +353,7 @@
             if "bounding box" in fileh["/"].keys():
                 fileh.close()
                 return True
+            fileh.close()
         except:
             pass
         return False


diff -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -33,7 +33,6 @@
     ValidateGridType
 import yt.data_objects.universal_fields
 
-
 KnownFLASHFields = FieldInfoContainer()
 add_flash_field = KnownFLASHFields.add_field
 
@@ -110,36 +109,78 @@
         return data.convert(fname)
     return _conv
 
-add_field("dens", function=lambda a,b: None, take_log=True,
-          convert_function=_get_convert("dens"),
-          units=r"\rm{g}/\rm{cm}^3")
-add_field("xvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("xvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("yvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("yvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("zvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("zvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("particle_xvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("particle_xvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("particle_yvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("particle_yvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("particle_zvel", function=lambda a,b: None, take_log=False,
-          convert_function=_get_convert("particle_zvel"),
-          units=r"\rm{cm}/\rm{s}")
-add_field("temp", function=lambda a,b: None, take_log=True,
-          convert_function=_get_convert("temp"),
-          units=r"\rm{K}")
-add_field("pres", function=lambda a,b: None, take_log=True,
-          convert_function=_get_convert("pres"),
-          units=r"\rm{unknown}")
+add_flash_field("dens", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("dens"),
+                units=r"\rm{g}/\rm{cm}^3")
+add_flash_field("velx", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("velx"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("vely", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("vely"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("velz", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("velz"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("particle_posx", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_posx"),
+                units=r"\rm{cm}")
+add_flash_field("particle_posy", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_posy"),
+                units=r"\rm{cm}")
+add_flash_field("particle_posz", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_posz"),
+                units=r"\rm{cm}")
+add_flash_field("particle_velx", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_velx"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("particle_vely", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_vely"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("particle_velz", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_velz"),
+                units=r"\rm{cm}/\rm{s}")
+add_flash_field("particle_mass", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("particle_mass"),
+                units=r"\rm{g}")
+add_flash_field("temp", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("temp"),
+                units=r"\rm{K}")
+add_flash_field("pres", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("pres"),
+                units=r"\rm{erg}\//\/\rm{cm}^{3}")
+add_flash_field("pden", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("pden"),
+                units=r"\rm{g}/\rm{cm}^3")
+add_flash_field("magx", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("magx"),
+                units = r"\mathrm{Gau\ss}")
+add_flash_field("magy", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("magy"),
+                units = r"\mathrm{Gau\ss}")
+add_flash_field("magz", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("magz"),
+                units = r"\mathrm{Gau\ss}")
+add_flash_field("magp", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("magp"),
+                units = r"\rm{erg}\//\/\rm{cm}^{3}")
+add_flash_field("divb", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("divb"),
+                units = r"\mathrm{Gau\ss}\/\rm{cm}")
+add_flash_field("game", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("game"),
+                units=r"\rm{ratio\/of\/specific\/heats}")
+add_flash_field("gamc", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("gamc"),
+                units=r"\rm{ratio\/of\/specific\/heats}")
+add_flash_field("gpot", function=lambda a,b: None, take_log=True,
+                convert_function=_get_convert("gpot"),
+                units=r"\rm{ergs\//\/g}")
+add_flash_field("gpol", function=lambda a,b: None, take_log=False,
+                convert_function=_get_convert("gpol"),
+                units = r"\rm{ergs\//\/g}")
 
 for f,v in translation_dict.items():
-    if v not in FLASHFieldInfo:
+    if v not in KnownFLASHFields:
         pfield = v.startswith("particle")
         add_field(v, function=lambda a,b: None, take_log=False,
                   validators = [ValidateDataField(v)],
@@ -147,54 +188,6 @@
     #print "Setting up translator from %s to %s" % (v, f)
     _generate_translation(v, f)
 
-add_field("gamc", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("gamc")],
-          units = r"\rm{ratio\/of\/specific\/heats}")
-
-add_field("game", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("game")],
-          units = r"\rm{ratio\/of\/specific\/heats}")
-
-add_field("gpot", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("gpot")],
-          units = r"\rm{ergs\//\/g}")
-
-add_field("gpol", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("gpol")],
-          units = r"\rm{ergs\//\/g}")
-
-add_field("grac", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("grac")],
-          units = r"\rm{cm\/s^{-2}}")
-
-add_field("pden", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("pden")],
-          units = r"\rm{g}\//\/\rm{cm}^{3}")
-
-add_field("pres", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("pres")],
-          units = r"\rm{erg}\//\/\rm{cm}^{3}")
-
-add_field("magx", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("magx")],
-          units = r"\rm{G}")
-
-add_field("magy", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("magy")],
-          units = r"\rm{G}")
-
-add_field("magz", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("magz")],
-          units = r"\rm{G}")
-
-add_field("magp", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("magp")],
-          units = r"\rm{erg}\//\/\rm{cm}^{3}")
-
-add_field("divb", function=lambda a,b: None, take_log=False,
-          validators = [ValidateDataField("divb")],
-          units = r"\rm{G}\/\rm{cm}")
-
 def _convertParticleMassMsun(data):
     return 1.0/1.989e33
 def _ParticleMassMsun(field, data):


diff -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb yt/startup_tasks.py
--- a/yt/startup_tasks.py
+++ b/yt/startup_tasks.py
@@ -95,6 +95,8 @@
         param, val = values.split("=")
         mylog.debug("Overriding config: %s = %s", param, val)
         ytcfg["yt",param] = val
+        if param == "loglevel": # special case
+            mylog.setLevel(int(val))
 
 parser = argparse.ArgumentParser(description = 'yt command line arguments')
 parser.add_argument("--config", action=SetConfigOption,


diff -r 7448e88985197e01b974f8bd68b4e7d08cbe90e2 -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -90,11 +90,12 @@
 
 class GetParameterFiles(argparse.Action):
     def __call__(self, parser, namespace, values, option_string = None):
+        print parser, namespace, values, option_string
         if len(values) == 1:
             pfs = values
         elif len(values) == 2 and namespace.basename is not None:
-            pfs = ["%s%04i" % (opts.basename, r)
-                   for r in range(int(values[0]), int(values[1]), opts.skip) ]
+            pfs = ["%s%04i" % (namespace.basename, r)
+                   for r in range(int(values[0]), int(values[1]), namespace.skip) ]
         else:
             pfs = values
         namespace.pf = [_fix_pf(pf) for pf in pfs]



https://bitbucket.org/yt_analysis/yt/changeset/2aa2732a80f7/
changeset:   2aa2732a80f7
branch:      yt
user:        samskillman
date:        2012-01-19 03:13:38
summary:     Merging
affected #:  2 files

diff -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb -r 2aa2732a80f7b689acc2618a7a21dbcfe87fe5b5 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3601,7 +3601,7 @@
 
         input_left = (self._old_global_startindex + 0.5) * rf 
         dx = na.fromiter((self['cd%s' % ax] for ax in 'xyz'), count=3, dtype='float64')
-        output_dims = na.rint((self.right_edge-self.left_edge)/dx).astype('int32') + 2
+        output_dims = na.rint((self.right_edge-self.left_edge)/dx+0.5).astype('int32') + 2
 
         self._cur_dims = output_dims
 


diff -r c4dc6c3ff45b038b04ab185a6ed22e0e0a3308fb -r 2aa2732a80f7b689acc2618a7a21dbcfe87fe5b5 yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -25,6 +25,8 @@
 
 from yt.data_objects.field_info_container import \
     FieldInfoContainer, \
+    NullFunc, \
+    TranslationFunc, \
     FieldInfo, \
     ValidateParameter, \
     ValidateDataField, \
@@ -82,7 +84,8 @@
                     "H2II_Fraction": "htwp",
                     "DI_Fraction": "deut",
                     "DII_Fraction": "dplu",
-                    "ParticleMass": "particle_mass"}
+                    "ParticleMass": "particle_mass",
+                    "Flame_Fraction": "flam"}
 
 def _get_density(fname):
     def _dens(field, data):
@@ -92,101 +95,109 @@
 for fn1, fn2 in translation_dict.items():
     if fn1.endswith("_Fraction"):
         add_field(fn1.split("_")[0] + "_Density",
-                  function=_get_density(fn1), take_log=True)
-
-def _get_alias(alias):
-    def _alias(field, data):
-        return data[alias]
-    return _alias
-
-def _generate_translation(mine, theirs):
-    pfield = theirs.startswith("particle")
-    add_field(theirs, function=_get_alias(mine), take_log=True,
-              particle_type = pfield)
+                  function=_get_density(fn1), take_log=True,
+                  display_name="%s\/Density" % fn1.split("_")[0])
 
 def _get_convert(fname):
     def _conv(data):
         return data.convert(fname)
     return _conv
 
-add_flash_field("dens", function=lambda a,b: None, take_log=True,
+add_flash_field("dens", function=NullFunc, take_log=True,
                 convert_function=_get_convert("dens"),
                 units=r"\rm{g}/\rm{cm}^3")
-add_flash_field("velx", function=lambda a,b: None, take_log=False,
+add_flash_field("velx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("velx"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("vely", function=lambda a,b: None, take_log=False,
+add_flash_field("vely", function=NullFunc, take_log=False,
                 convert_function=_get_convert("vely"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("velz", function=lambda a,b: None, take_log=False,
+add_flash_field("velz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("velz"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("particle_posx", function=lambda a,b: None, take_log=False,
+add_flash_field("ener", function=NullFunc, take_log=True,
+                convert_function=_get_convert("ener"),
+                units=r"\rm{erg}/\rm{g}")
+add_flash_field("eint", function=NullFunc, take_log=True,
+                convert_function=_get_convert("eint"),
+                units=r"\rm{erg}/\rm{g}")
+add_flash_field("particle_posx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posx"),
                 units=r"\rm{cm}")
-add_flash_field("particle_posy", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_posy", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posy"),
                 units=r"\rm{cm}")
-add_flash_field("particle_posz", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_posz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posz"),
                 units=r"\rm{cm}")
-add_flash_field("particle_velx", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_velx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_velx"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("particle_vely", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_vely", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_vely"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("particle_velz", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_velz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_velz"),
                 units=r"\rm{cm}/\rm{s}")
-add_flash_field("particle_mass", function=lambda a,b: None, take_log=False,
+add_flash_field("particle_tag", function=NullFunc, take_log=False,
+                convert_function=_get_convert("particle_tag"))
+add_flash_field("particle_mass", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_mass"),
                 units=r"\rm{g}")
-add_flash_field("temp", function=lambda a,b: None, take_log=True,
+add_flash_field("temp", function=NullFunc, take_log=True,
                 convert_function=_get_convert("temp"),
                 units=r"\rm{K}")
-add_flash_field("pres", function=lambda a,b: None, take_log=True,
+add_flash_field("pres", function=NullFunc, take_log=True,
                 convert_function=_get_convert("pres"),
                 units=r"\rm{erg}\//\/\rm{cm}^{3}")
-add_flash_field("pden", function=lambda a,b: None, take_log=True,
+add_flash_field("pden", function=NullFunc, take_log=True,
                 convert_function=_get_convert("pden"),
                 units=r"\rm{g}/\rm{cm}^3")
-add_flash_field("magx", function=lambda a,b: None, take_log=False,
+add_flash_field("magx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("magx"),
                 units = r"\mathrm{Gau\ss}")
-add_flash_field("magy", function=lambda a,b: None, take_log=False,
+add_flash_field("magy", function=NullFunc, take_log=False,
                 convert_function=_get_convert("magy"),
                 units = r"\mathrm{Gau\ss}")
-add_flash_field("magz", function=lambda a,b: None, take_log=False,
+add_flash_field("magz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("magz"),
                 units = r"\mathrm{Gau\ss}")
-add_flash_field("magp", function=lambda a,b: None, take_log=True,
+add_flash_field("magp", function=NullFunc, take_log=True,
                 convert_function=_get_convert("magp"),
                 units = r"\rm{erg}\//\/\rm{cm}^{3}")
-add_flash_field("divb", function=lambda a,b: None, take_log=True,
+add_flash_field("divb", function=NullFunc, take_log=False,
                 convert_function=_get_convert("divb"),
                 units = r"\mathrm{Gau\ss}\/\rm{cm}")
-add_flash_field("game", function=lambda a,b: None, take_log=True,
+add_flash_field("game", function=NullFunc, take_log=False,
                 convert_function=_get_convert("game"),
                 units=r"\rm{ratio\/of\/specific\/heats}")
-add_flash_field("gamc", function=lambda a,b: None, take_log=True,
+add_flash_field("gamc", function=NullFunc, take_log=False,
                 convert_function=_get_convert("gamc"),
                 units=r"\rm{ratio\/of\/specific\/heats}")
-add_flash_field("gpot", function=lambda a,b: None, take_log=True,
+add_flash_field("gpot", function=NullFunc, take_log=False,
                 convert_function=_get_convert("gpot"),
                 units=r"\rm{ergs\//\/g}")
-add_flash_field("gpol", function=lambda a,b: None, take_log=False,
+add_flash_field("gpol", function=NullFunc, take_log=False,
                 convert_function=_get_convert("gpol"),
                 units = r"\rm{ergs\//\/g}")
+add_flash_field("flam", function=NullFunc, take_log=False,
+                convert_function=_get_convert("flam"))
 
 for f,v in translation_dict.items():
     if v not in KnownFLASHFields:
         pfield = v.startswith("particle")
-        add_field(v, function=lambda a,b: None, take_log=False,
+        add_flash_field(v, function=NullFunc, take_log=False,
                   validators = [ValidateDataField(v)],
                   particle_type = pfield)
-    #print "Setting up translator from %s to %s" % (v, f)
-    _generate_translation(v, f)
+    else:
+        if f.endswith("_Fraction") :
+            dname = "%s\/Fraction" % f.split("_")[0]
+        else :
+            dname = f                    
+        ff = KnownFLASHFields[v]
+        add_field(f, TranslationFunc(v),
+                  take_log=KnownFLASHFields[v].take_log,
+                  units = ff._units, display_name=dname)
 
 def _convertParticleMassMsun(data):
     return 1.0/1.989e33



https://bitbucket.org/yt_analysis/yt/changeset/b0af3a26bfcc/
changeset:   b0af3a26bfcc
branch:      yt
user:        samskillman
date:        2012-01-19 20:50:38
summary:     Merging in changes with better checking on the parallelism on the MosaicFisheyeCamera.
affected #:  2 files

diff -r 2aa2732a80f7b689acc2618a7a21dbcfe87fe5b5 -r b0af3a26bfcc903a0f8fee98b7b59398daccfddd yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -106,6 +106,7 @@
         
         self.grid_left_edge[:] = f["/bounding box"][:,:,0]
         self.grid_right_edge[:] = f["/bounding box"][:,:,1]
+        
         # Move this to the parameter file
         try:
             nxb = pf._find_parameter("integer", "nxb", True)
@@ -129,7 +130,12 @@
         self.grids = na.empty(self.num_grids, dtype='object')
         for i in xrange(self.num_grids):
             self.grids[i] = self.grid(i+1, self, self.grid_levels[i,0])
-
+        dx = ((self.parameter_file.domain_right_edge -
+               self.parameter_file.domain_left_edge)/
+              self.parameter_file.refine_by**(self.grid_levels.max())).astype('float64')
+        self.grid_left_edge = na.rint(self.grid_left_edge/dx)*dx
+        self.grid_right_edge = na.rint(self.grid_right_edge/dx)*dx
+                        
     def _populate_grid_objects(self):
         # We only handle 3D data, so offset is 7 (nfaces+1)
         
@@ -285,9 +291,9 @@
         else:
             raise RuntimeError("Can't figure out FLASH file version.")
         self.domain_left_edge = na.array(
-            [self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
+            [self._find_parameter("real", "%smin" % ax) for ax in 'xyz']).astype("float64")
         self.domain_right_edge = na.array(
-            [self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
+            [self._find_parameter("real", "%smax" % ax) for ax in 'xyz']).astype("float64")
         self.min_level = self._find_parameter(
             "integer", "lrefine_min", scalar = False) - 1
 


diff -r 2aa2732a80f7b689acc2618a7a21dbcfe87fe5b5 -r b0af3a26bfcc903a0f8fee98b7b59398daccfddd yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -453,8 +453,8 @@
                     self.center += (na.array(final) - self.center) / (10. * n_steps)
                 final_zoom = final_width/na.array(self.width)
                 dW = final_zoom**(1.0/n_steps)
-	    else:
-		dW = 1.0
+            else:
+                dW = 1.0
             position_diff = (na.array(final)/self.center)*1.0
             dx = position_diff**(1.0/n_steps)
         else:
@@ -463,8 +463,8 @@
                     width = na.array([final_width, final_width, final_width]) 
                     # front/back, left/right, top/bottom
                 dW = (1.0*final_width-na.array(self.width))/n_steps
-	    else:
-		dW = 1.0
+            else:
+                dW = 1.0
             dx = (na.array(final)-self.center)*1.0/n_steps
         for i in xrange(n_steps):
             if exponential:
@@ -965,7 +965,7 @@
         >>>         transfer_function = tf, 
         >>>         sub_samples = 5, 
         >>>         pf=pf, 
-        >>>         nimx=2,nimy=2,procs_per_wg=4)
+        >>>         nimx=2,nimy=2,procs_per_wg=2)
         
         # Take a snapshot
         >>> im = cam.snapshot()
@@ -979,8 +979,16 @@
         self.image_decomp = self.comm.size>1
         if self.image_decomp:
             PP = ProcessorPool()
+            npatches = nimy*nimx
             if procs_per_wg is None:
-                procs_per_wg = PP.size
+                if (PP.size % npatches):
+                    raise RuntimeError("Cannot evenly divide %i procs to %i patches" % (PP.size,npatches))
+                else:
+                    procs_per_wg = PP.size / npatches
+            if (PP.size != npatches*procs_per_wg):
+               raise RuntimeError("You need %i processors to utilize %i procs per one patch in [%i,%i] grid" 
+                     % (npatches*procs_per_wg,procs_per_wg,nimx,nimy))
+ 
             for j in range(nimy):
                 for i in range(nimx):
                     PP.add_workgroup(size=procs_per_wg, name='%04i_%04i'%(i,j))
@@ -1205,8 +1213,6 @@
 
         return R
 
-
-
 def off_axis_projection(pf, center, normal_vector, width, resolution,
                         field, weight = None, volume = None, no_ghost = True):
     r"""Project through a parameter file, off-axis, and return the image plane.



https://bitbucket.org/yt_analysis/yt/changeset/29fb31e9350f/
changeset:   29fb31e9350f
branch:      yt
user:        ngoldbaum
date:        2012-01-19 23:25:55
summary:     Added an interface to set normal_vector, north_vector, east_vector,
and rotation_vector when defining a MosaicFisheyeCamera
affected #:  1 file

diff -r b0af3a26bfcc903a0f8fee98b7b59398daccfddd -r 29fb31e9350febeed670c7c76a1460b265b08368 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -857,7 +857,9 @@
                  transfer_function = None, fields = None,
                  sub_samples = 5, log_fields = None, volume = None,
                  pf = None, l_max=None, no_ghost=False,nimx=1, nimy=1, procs_per_wg=None,
-                 rotation=None):
+                 rotation=None,normal_vector = na.array([0.,0.,1.]),
+                 north_vector=na.array([1.,0.,0.]),east_vector=na.array([0.,1.,0.]),
+                 rotation_vector=na.array([1.,0.,0.])):
         r"""A fisheye lens camera, taking adantage of image plane decomposition
         for parallelism..
 



https://bitbucket.org/yt_analysis/yt/changeset/d3a13d9e7db7/
changeset:   d3a13d9e7db7
branch:      yt
user:        ngoldbaum
date:        2012-01-19 23:45:28
summary:     Forgot to set the vectors in __init__
affected #:  1 file

diff -r 29fb31e9350febeed670c7c76a1460b265b08368 -r d3a13d9e7db7e92c4bdadacf60f3fcadfc883f2f yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1017,10 +1017,10 @@
         if rotation is None: rotation = na.eye(3)
         self.rotation_matrix = rotation
         
-        self.normal_vector = na.array([0.,0.,1.])
-        self.north_vector = na.array([1.,0.,0.])
-        self.east_vector = na.array([0.,1.,0.])
-        self.rotation_vector = self.north_vector
+        self.normal_vector = normal_vector
+        self.north_vector = north_vector
+        self.east_vector = east_vector
+        self.rotation_vector = rotation_vector
 
         if iterable(resolution):
             raise RuntimeError("Resolution must be a single int")



https://bitbucket.org/yt_analysis/yt/changeset/c608d50001f7/
changeset:   c608d50001f7
branch:      yt
user:        ngoldbaum
date:        2012-01-20 04:53:11
summary:     Added a move_to() method
affected #:  1 file

diff -r d3a13d9e7db7e92c4bdadacf60f3fcadfc883f2f -r c608d50001f71c2b9d22c4b2447372a5fe520f19 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1202,6 +1202,41 @@
             self.rotate(dtheta, rot_vector=rot_vector, keep_focus=keep_focus)
             yield self.snapshot()
 
+    def move_to(self,final,n_steps,exponential=False):
+        r"""Loop over a look_at
+
+        This will yield `n_steps` snapshots until the current view has been
+        moved to a final center of `final`.
+
+        Parameters
+        ----------
+        final : array_like
+            The final center to move to after `n_steps`
+        n_steps : int
+            The number of look_at snapshots to make.
+        exponential : boolean
+            Specifies whether the move/zoom transition follows an
+            exponential path toward the destination or linear
+            
+        Examples
+        --------
+
+        >>> for i, snapshot in enumerate(cam.move_to([0.2,0.3,0.6], 10)):
+        ...     cam.save_image("move_%04i.png" % i)
+        """
+
+        if exponential:
+            position_diff = (na.array(final)/self.center)*1.0
+            dx = position_diff**(1.0/n_steps)
+        else:
+            dx = (na.array(final) - self.center)*1.0/n_steps
+        for i in xrange(n_steps):
+            if exponential:
+                self.center *= dx
+            else:
+                self.center += dx
+            yield self.snapshot()
+
     def get_rotation_matrix(self, theta, rot_vector):
         ux = rot_vector[0]
         uy = rot_vector[1]



https://bitbucket.org/yt_analysis/yt/changeset/8ed1eac1f961/
changeset:   8ed1eac1f961
branch:      yt
user:        ngoldbaum
date:        2012-01-20 05:47:47
summary:     Added a clip_ratio option so that the images from MosaicFisheyeCamera
have better contrast
affected #:  1 file

diff -r c608d50001f71c2b9d22c4b2447372a5fe520f19 -r 8ed1eac1f961a240972ab226d86e0e489211236e yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1104,7 +1104,7 @@
        
         return image
 
-    def save_image(self, fn):
+    def save_image(self, fn, clip_ratio=None):
         if '.png' not in fn:
             fn = fn + '.png'
         
@@ -1130,12 +1130,18 @@
 
                             final_image[i*nx:(i+1)*nx, j*ny:(j+1)*ny,:] = arr
                             del arr
-                    write_bitmap(final_image, fn)
+                    if clip_ratio is not None:
+                        write_bitmap(final_image, fn, image.mean() + clip_ratio*image.std())
+                    else:
+                        write_bitmap(final_image, fn)
                 else:
                     self.global_comm.send_array(image, 0, tag = self.global_comm.rank)
         else:
             if self.comm.rank == 0:
-                write_bitmap(image, fn)
+                if clip_ratio is not None:
+                    write_bitmap(image, fn, clip_ratio*image.std())
+                else:
+                    write_bitmap(image, fn)
         return
 
     def rotate(self, theta, rot_vector=None, keep_focus=True):



https://bitbucket.org/yt_analysis/yt/changeset/3f924fba5c15/
changeset:   3f924fba5c15
branch:      yt
user:        ngoldbaum
date:        2012-01-20 09:07:22
summary:     Better to keep clip_ratio consistent with the rest of camera.py
affected #:  1 file

diff -r 8ed1eac1f961a240972ab226d86e0e489211236e -r 3f924fba5c153b8c2f7eaccccebbb954739e610b yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1131,7 +1131,7 @@
                             final_image[i*nx:(i+1)*nx, j*ny:(j+1)*ny,:] = arr
                             del arr
                     if clip_ratio is not None:
-                        write_bitmap(final_image, fn, image.mean() + clip_ratio*image.std())
+                        write_bitmap(final_image, fn, clip_ratio*final_image.max())
                     else:
                         write_bitmap(final_image, fn)
                 else:



https://bitbucket.org/yt_analysis/yt/changeset/7250c526e5c6/
changeset:   7250c526e5c6
branch:      yt
user:        ngoldbaum
date:        2012-01-20 19:20:27
summary:     Removing the camera vectors from the MosaicFisheyeCamera call.
affected #:  1 file

diff -r 8ed1eac1f961a240972ab226d86e0e489211236e -r 7250c526e5c650c930bcc0f8775076d80f165b3d yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -857,9 +857,7 @@
                  transfer_function = None, fields = None,
                  sub_samples = 5, log_fields = None, volume = None,
                  pf = None, l_max=None, no_ghost=False,nimx=1, nimy=1, procs_per_wg=None,
-                 rotation=None,normal_vector = na.array([0.,0.,1.]),
-                 north_vector=na.array([1.,0.,0.]),east_vector=na.array([0.,1.,0.]),
-                 rotation_vector=na.array([1.,0.,0.])):
+                 rotation=None):
         r"""A fisheye lens camera, taking adantage of image plane decomposition
         for parallelism..
 
@@ -1017,10 +1015,10 @@
         if rotation is None: rotation = na.eye(3)
         self.rotation_matrix = rotation
         
-        self.normal_vector = normal_vector
-        self.north_vector = north_vector
-        self.east_vector = east_vector
-        self.rotation_vector = rotation_vector
+        self.normal_vector = na.array([0.,0.,1])
+        self.north_vector = na.array([1.,0.,0.])
+        self.east_vector = na.array([0.,1.,0.])
+        self.rotation_vector = self.north_vector
 
         if iterable(resolution):
             raise RuntimeError("Resolution must be a single int")



https://bitbucket.org/yt_analysis/yt/changeset/6c3e0a041cd3/
changeset:   6c3e0a041cd3
branch:      yt
user:        ngoldbaum
date:        2012-01-20 19:20:53
summary:     Merging
affected #:  1 file

diff -r 7250c526e5c650c930bcc0f8775076d80f165b3d -r 6c3e0a041cd3f331d4a9b4be0fa0a476ba113eba yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -1129,7 +1129,7 @@
                             final_image[i*nx:(i+1)*nx, j*ny:(j+1)*ny,:] = arr
                             del arr
                     if clip_ratio is not None:
-                        write_bitmap(final_image, fn, image.mean() + clip_ratio*image.std())
+                        write_bitmap(final_image, fn, clip_ratio*final_image.max())
                     else:
                         write_bitmap(final_image, fn)
                 else:



https://bitbucket.org/yt_analysis/yt/changeset/2a62fb4acbf0/
changeset:   2a62fb4acbf0
branch:      yt
user:        samskillman
date:        2012-01-20 19:27:35
summary:     Merging
affected #:  2 files

diff -r 6c3e0a041cd3f331d4a9b4be0fa0a476ba113eba -r 2a62fb4acbf0694c42970070f2b3ede048718424 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -41,7 +41,8 @@
     io_registry
 
 from .fields import FLASHFieldInfo, add_flash_field, KnownFLASHFields
-from yt.data_objects.field_info_container import FieldInfoContainer, NullFunc
+from yt.data_objects.field_info_container import FieldInfoContainer, NullFunc, \
+     ValidateDataField
 
 class FLASHGrid(AMRGridPatch):
     _id_offset = 1
@@ -178,7 +179,14 @@
         for field in self.field_list:
             if field not in self.derived_field_list:
                 self.derived_field_list.append(field)
-
+            if (field not in KnownFLASHFields and
+                field.startswith("particle")) :
+                self.parameter_file.field_info.add_field(field,
+                                                         function=NullFunc,
+                                                         take_log=False,
+                                                         validators = [ValidateDataField(field)],
+                                                         particle_type=True)
+                
     def _setup_data_io(self):
         self.io = io_registry[self.data_style](self.parameter_file)
 


diff -r 6c3e0a041cd3f331d4a9b4be0fa0a476ba113eba -r 2a62fb4acbf0694c42970070f2b3ede048718424 yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -123,27 +123,28 @@
                 units=r"\rm{erg}/\rm{g}")
 add_flash_field("particle_posx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posx"),
-                units=r"\rm{cm}")
+                units=r"\rm{cm}", particle_type=True)
 add_flash_field("particle_posy", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posy"),
-                units=r"\rm{cm}")
+                units=r"\rm{cm}", particle_type=True)
 add_flash_field("particle_posz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_posz"),
-                units=r"\rm{cm}")
+                units=r"\rm{cm}", particle_type=True)
 add_flash_field("particle_velx", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_velx"),
-                units=r"\rm{cm}/\rm{s}")
+                units=r"\rm{cm}/\rm{s}", particle_type=True)
 add_flash_field("particle_vely", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_vely"),
-                units=r"\rm{cm}/\rm{s}")
+                units=r"\rm{cm}/\rm{s}", particle_type=True)
 add_flash_field("particle_velz", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_velz"),
-                units=r"\rm{cm}/\rm{s}")
+                units=r"\rm{cm}/\rm{s}", particle_type=True)
 add_flash_field("particle_tag", function=NullFunc, take_log=False,
-                convert_function=_get_convert("particle_tag"))
+                convert_function=_get_convert("particle_tag"),
+                particle_type=True)
 add_flash_field("particle_mass", function=NullFunc, take_log=False,
                 convert_function=_get_convert("particle_mass"),
-                units=r"\rm{g}")
+                units=r"\rm{g}", particle_type=True)
 add_flash_field("temp", function=NullFunc, take_log=True,
                 convert_function=_get_convert("temp"),
                 units=r"\rm{K}")

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