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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Sep 15 11:47:13 PDT 2014


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/bef6811d8f7b/
Changeset:   bef6811d8f7b
Branch:      yt-3.0
User:        samskillman
Date:        2014-09-11 02:17:00
Summary:     Merging yt-3.0 head
Affected #:  2 files

diff -r a5f1bc376dd3fe5266e5dfc9463817872c48810d -r bef6811d8f7b1dc662a9e140ba5a2bd1afc59fcc yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -150,7 +150,7 @@
     TransferFunctionHelper
 
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
-    parallel_objects, enable_parallelism
+    parallel_objects, enable_parallelism, communication_system
 
 from yt.convenience import \
     load, simulation

diff -r a5f1bc376dd3fe5266e5dfc9463817872c48810d -r bef6811d8f7b1dc662a9e140ba5a2bd1afc59fcc yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -252,7 +252,7 @@
 
 axis_wcs = [[1,2],[0,2],[0,1]]
 
-def construct_image(data_source):
+def construct_image(data_source, center=None):
     ds = data_source.ds
     axis = data_source.axis
     if hasattr(ds, "wcs"):
@@ -266,11 +266,14 @@
     else:
         # This is some other kind of dataset
         unit = ds.get_smallest_appropriate_unit(ds.domain_width.max())
+        if center is None:
+            crval = [0.0,0.0]
+        else:
+            crval = [(ds.domain_center-center)[idx].in_units(unit) for idx in axis_wcs[axis]]
         dx = ds.index.get_smallest_dx()
         nx, ny = (ds.domain_width[axis_wcs[axis]]/dx).ndarray_view().astype("int")
         crpix = [0.5*(nx+1), 0.5*(ny+1)]
         cdelt = [dx.in_units(unit)]*2
-        crval = [ds.domain_center[idx].in_units(unit) for idx in axis_wcs[axis]]
         cunit = [unit]*2
         ctype = ["LINEAR"]*2
     frb = data_source.to_frb((1.0,"unitary"), (nx,ny))
@@ -295,7 +298,7 @@
     fields : string or list of strings
         The fields to slice
     center : A sequence floats, a string, or a tuple.
-         The coordinate of the center of the image. If set to 'c', 'center' or
+         The coordinate of the origin of the image. If set to 'c', 'center' or
          left blank, the plot is centered on the middle of the domain. If set to
          'max' or 'm', the center will be located at the maximum of the
          ('gas', 'density') field. Units can be specified by passing in center
@@ -308,7 +311,7 @@
         axis = fix_axis(axis, ds)
         center = get_sanitized_center(center, ds)
         slc = ds.slice(axis, center[axis], **kwargs)
-        w, frb = construct_image(slc)
+        w, frb = construct_image(slc, center=center)
         super(FITSSlice, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)
@@ -327,12 +330,21 @@
         The fields to project
     weight_field : string
         The field used to weight the projection.
+    center : A sequence floats, a string, or a tuple.
+        The coordinate of the origin of the image. If set to 'c', 'center' or
+        left blank, the plot is centered on the middle of the domain. If set to
+        'max' or 'm', the center will be located at the maximum of the
+        ('gas', 'density') field. Units can be specified by passing in center
+        as a tuple containing a coordinate and string unit name or by passing
+        in a YTArray.  If a list or unitless array is supplied, code units are
+        assumed.
     """
-    def __init__(self, ds, axis, fields, weight_field=None, **kwargs):
+    def __init__(self, ds, axis, fields, center="c", weight_field=None, **kwargs):
         fields = ensure_list(fields)
         axis = fix_axis(axis, ds)
+        center = get_sanitized_center(center, ds)
         prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs)
-        w, frb = construct_image(prj)
+        w, frb = construct_image(prj, center=center)
         super(FITSProjection, self).__init__(frb, fields=fields, wcs=w)
         for i, field in enumerate(fields):
             self[i].header["bunit"] = str(frb[field].units)


https://bitbucket.org/yt_analysis/yt/commits/7577dc4ee59b/
Changeset:   7577dc4ee59b
Branch:      yt-3.0
User:        samskillman
Date:        2014-09-11 02:17:25
Summary:     Merging yt-3.0 head
Affected #:  1 file

diff -r bef6811d8f7b1dc662a9e140ba5a2bd1afc59fcc -r 7577dc4ee59bb88a01493d673f71bd3a371eabf3 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -649,7 +649,7 @@
             del nz
         else:
             nim = im
-        ax = self._pylab.imshow(nim[:,:,:3]/nim[:,:,:3].max(), origin='lower')
+        ax = self._pylab.imshow(nim[:,:,:3]/nim[:,:,:3].max(), origin='upper')
         return ax
 
     def draw(self):
@@ -747,6 +747,9 @@
         image = ImageArray(self._render(double_check, num_threads, 
                                         image, sampler),
                            info=self.get_information())
+
+        # flip it up/down to handle how the png orientation is donetest.png
+        image = image[:,::-1,:]
         self.save_image(image, fn=fn, clip_ratio=clip_ratio, 
                        transparent=transparent)
         return image


https://bitbucket.org/yt_analysis/yt/commits/38910e03dbd6/
Changeset:   38910e03dbd6
Branch:      yt
User:        samskillman
Date:        2014-09-11 02:18:43
Summary:     Merging yt-3.0 into yt
Affected #:  1 file

diff -r f663cb9d1467cc564e1863644ad6ab7adb82c39f -r 38910e03dbd6d91bac876c29e14f3604c4438f16 yt/utilities/sdf.py
--- a/yt/utilities/sdf.py
+++ b/yt/utilities/sdf.py
@@ -524,6 +524,19 @@
     return sdf
 
 
+def _shift_periodic(pos, left, right, domain_width):
+    """
+    Periodically shift positions that are right of left+domain_width to
+    the left, and those left of right-domain_width to the right.
+    """
+    for i in range(3):
+        mask = pos[:,i] >= left[i] + domain_width[i]
+        pos[mask, i] -= domain_width[i]
+        mask = pos[:,i] < right[i] - domain_width[i]
+        pos[mask, i] += domain_width[i]
+    return
+
+
 class SDFIndex(object):
 
     """docstring for SDFIndex
@@ -914,14 +927,7 @@
             DW = self.true_domain_width
             # This hurts, but is useful for periodicity. Probably should check first
             # if it is even needed for a given left/right
-            for i in range(3):
-                #pos[:,i] = np.mod(pos[:,i] - left[i],
-                #                  self.true_domain_width[i]) + left[i]
-                mask = pos[:,i] >= left[i] + DW[i]
-                pos[mask, i] -= DW[i]
-                mask = pos[:,i] < right[i] - DW[i]
-                pos[mask, i] += DW[i]
-                #del mask
+            _shift_periodic(pos, left, right, DW)
 
             # Now get all particles that are within the bbox
             mask = np.all(pos >= left, axis=1) * np.all(pos < right, axis=1)
@@ -945,6 +951,39 @@
 
             yield filtered
 
+    def filter_sphere(self, center, radius, myiter):
+        """
+        Filter data by masking out data outside of a sphere defined
+        by a center and radius. Account for periodicity of data, allowing
+        left/right to be outside of the domain.
+        """
+
+        # Get left/right for periodicity considerations
+        left = center - radius
+        right = center + radius
+        for data in myiter:
+            pos = np.array([data['x'].copy(), data['y'].copy(), data['z'].copy()]).T
+
+            DW = self.true_domain_width
+            _shift_periodic(pos, left, right, DW)
+
+            # Now get all particles that are within the sphere 
+            mask = ((pos-center)**2).sum(axis=1)**0.5 < radius
+
+            mylog.debug("Filtering particles, returning %i out of %i" % (mask.sum(), mask.shape[0]))
+
+            if not np.any(mask):
+                continue
+
+            filtered = {ax: pos[:, i][mask] for i, ax in enumerate('xyz')}
+            for f in data.keys():
+                if f in 'xyz':
+                    continue
+                filtered[f] = data[f][mask]
+
+            yield filtered
+
+
     def iter_filtered_bbox_fields(self, left, right, data,
                                   pos_fields, fields):
         """
@@ -964,11 +1003,7 @@
 
         # This hurts, but is useful for periodicity. Probably should check first
         # if it is even needed for a given left/right
-        for i in range(3):
-            mask = pos[:,i] >= DW[i] + left[i]
-            pos[mask, i] -= DW[i]
-            mask = pos[:,i] < right[i] - DW[i]
-            pos[mask, i] += DW[i]
+        _shift_periodic(pos, left, right, DW)
 
         mylog.debug("Periodic filtering, %s %s %s %s" % (left, right, pos.min(axis=0), pos.max(axis=0)))
         # Now get all particles that are within the bbox
@@ -987,6 +1022,10 @@
                 yield f, data[f][mask]
 
     def iter_bbox_data(self, left, right, fields):
+        """
+        Iterate over all data within a bounding box defined by a left
+        and a right.
+        """
         _ensure_xyz_fields(fields)
         mylog.debug('MIDX Loading region from %s to %s' %(left, right))
         inds = self.get_bbox(left, right)
@@ -1007,15 +1046,17 @@
         #    yield dd
 
     def iter_sphere_data(self, center, radius, fields):
+        """
+        Iterate over all data within some sphere defined by a center and
+        a radius.
+        """
         _ensure_xyz_fields(fields)
         mylog.debug('MIDX Loading spherical region %s to %s' %(center, radius))
         inds = self.get_bbox(center-radius, center+radius)
 
-        my_filter = sphere_filter(center, radius, self.true_domain_width)
-
-        for dd in self.filter_particles(
-            self.iter_data(inds, fields),
-            my_filter):
+        for dd in self.filter_sphere(
+            center, radius,
+            self.iter_data(inds, fields)):
             yield dd
 
     def iter_ibbox_data(self, left, right, fields):


https://bitbucket.org/yt_analysis/yt/commits/d57c20f63956/
Changeset:   d57c20f63956
Branch:      yt
User:        ngoldbaum
Date:        2014-09-15 20:47:06
Summary:     Merged in samskillman/yt (pull request #1197)

Merger-induced commits.
Affected #:  1 file

diff -r 8bb2e6a405bf810eaaf0623deff453c746c546f4 -r d57c20f6395668851a7f7f6fe52b84069c14e287 yt/utilities/sdf.py
--- a/yt/utilities/sdf.py
+++ b/yt/utilities/sdf.py
@@ -524,6 +524,19 @@
     return sdf
 
 
+def _shift_periodic(pos, left, right, domain_width):
+    """
+    Periodically shift positions that are right of left+domain_width to
+    the left, and those left of right-domain_width to the right.
+    """
+    for i in range(3):
+        mask = pos[:,i] >= left[i] + domain_width[i]
+        pos[mask, i] -= domain_width[i]
+        mask = pos[:,i] < right[i] - domain_width[i]
+        pos[mask, i] += domain_width[i]
+    return
+
+
 class SDFIndex(object):
 
     """docstring for SDFIndex
@@ -914,14 +927,7 @@
             DW = self.true_domain_width
             # This hurts, but is useful for periodicity. Probably should check first
             # if it is even needed for a given left/right
-            for i in range(3):
-                #pos[:,i] = np.mod(pos[:,i] - left[i],
-                #                  self.true_domain_width[i]) + left[i]
-                mask = pos[:,i] >= left[i] + DW[i]
-                pos[mask, i] -= DW[i]
-                mask = pos[:,i] < right[i] - DW[i]
-                pos[mask, i] += DW[i]
-                #del mask
+            _shift_periodic(pos, left, right, DW)
 
             # Now get all particles that are within the bbox
             mask = np.all(pos >= left, axis=1) * np.all(pos < right, axis=1)
@@ -945,6 +951,39 @@
 
             yield filtered
 
+    def filter_sphere(self, center, radius, myiter):
+        """
+        Filter data by masking out data outside of a sphere defined
+        by a center and radius. Account for periodicity of data, allowing
+        left/right to be outside of the domain.
+        """
+
+        # Get left/right for periodicity considerations
+        left = center - radius
+        right = center + radius
+        for data in myiter:
+            pos = np.array([data['x'].copy(), data['y'].copy(), data['z'].copy()]).T
+
+            DW = self.true_domain_width
+            _shift_periodic(pos, left, right, DW)
+
+            # Now get all particles that are within the sphere 
+            mask = ((pos-center)**2).sum(axis=1)**0.5 < radius
+
+            mylog.debug("Filtering particles, returning %i out of %i" % (mask.sum(), mask.shape[0]))
+
+            if not np.any(mask):
+                continue
+
+            filtered = {ax: pos[:, i][mask] for i, ax in enumerate('xyz')}
+            for f in data.keys():
+                if f in 'xyz':
+                    continue
+                filtered[f] = data[f][mask]
+
+            yield filtered
+
+
     def iter_filtered_bbox_fields(self, left, right, data,
                                   pos_fields, fields):
         """
@@ -964,11 +1003,7 @@
 
         # This hurts, but is useful for periodicity. Probably should check first
         # if it is even needed for a given left/right
-        for i in range(3):
-            mask = pos[:,i] >= DW[i] + left[i]
-            pos[mask, i] -= DW[i]
-            mask = pos[:,i] < right[i] - DW[i]
-            pos[mask, i] += DW[i]
+        _shift_periodic(pos, left, right, DW)
 
         mylog.debug("Periodic filtering, %s %s %s %s" % (left, right, pos.min(axis=0), pos.max(axis=0)))
         # Now get all particles that are within the bbox
@@ -987,6 +1022,10 @@
                 yield f, data[f][mask]
 
     def iter_bbox_data(self, left, right, fields):
+        """
+        Iterate over all data within a bounding box defined by a left
+        and a right.
+        """
         _ensure_xyz_fields(fields)
         mylog.debug('MIDX Loading region from %s to %s' %(left, right))
         inds = self.get_bbox(left, right)
@@ -1007,15 +1046,17 @@
         #    yield dd
 
     def iter_sphere_data(self, center, radius, fields):
+        """
+        Iterate over all data within some sphere defined by a center and
+        a radius.
+        """
         _ensure_xyz_fields(fields)
         mylog.debug('MIDX Loading spherical region %s to %s' %(center, radius))
         inds = self.get_bbox(center-radius, center+radius)
 
-        my_filter = sphere_filter(center, radius, self.true_domain_width)
-
-        for dd in self.filter_particles(
-            self.iter_data(inds, fields),
-            my_filter):
+        for dd in self.filter_sphere(
+            center, radius,
+            self.iter_data(inds, fields)):
             yield dd
 
     def iter_ibbox_data(self, left, right, fields):

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list