[Yt-svn] yt-commit r1101 - in trunk/yt: lagos/hop raven

sskory at wrangler.dreamhost.com sskory at wrangler.dreamhost.com
Sun Jan 11 18:33:44 PST 2009


Author: sskory
Date: Sun Jan 11 18:33:43 2009
New Revision: 1101
URL: http://yt.spacepope.org/changeset/1101

Log:
a HopParticleCallback which prints the actual particles of each halo (similar to ParticleCallback), and a few new useful HopGroup functions in SS_Hop.

Modified:
   trunk/yt/lagos/hop/SS_HopOutput.py
   trunk/yt/raven/Callbacks.py

Modified: trunk/yt/lagos/hop/SS_HopOutput.py
==============================================================================
--- trunk/yt/lagos/hop/SS_HopOutput.py	(original)
+++ trunk/yt/lagos/hop/SS_HopOutput.py	Sun Jan 11 18:33:43 2009
@@ -244,6 +244,12 @@
     def get_size(self):
         return self.indices.size
 
+    def get_indices(self):
+        return self.indices
+    
+    def get_positions(self):
+        return [self["particle_position_x"],self["particle_position_y"],self["particle_position_z"]]
+
 class HaloFinder(HopList, ParallelAnalysisInterface):
     def __init__(self, pf, threshold=160.0, dm_only=True, padding=0.2):
         self.pf = pf

Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py	(original)
+++ trunk/yt/raven/Callbacks.py	Sun Jan 11 18:33:43 2009
@@ -156,6 +156,8 @@
         if not self.color_field: particles_c = self.color
         else: particles_c = self.particles_c[goodI]
         plot._axes.hold(True)
+        print particles_x
+        print particles_y
         plot._axes.scatter(particles_x, particles_y, edgecolors='None',
                            s=self.p_size, c=particles_c)
         plot._axes.set_xlim(xx0,xx1)
@@ -506,6 +508,7 @@
         dx = plot.image._A.shape[0] / (x1-x0)
         dy = plot.image._A.shape[1] / (y1-y0)
         for halo in self.hop_output[:self.max_number]:
+            if halo.get_size() < self.min_size: continue
             radius = halo.maximum_radius() * dx
             center = halo.center_of_mass()
             center_x = (center[xi] - x0)*dx
@@ -520,6 +523,48 @@
                     plot._axes.text(center_x, center_y, "%s" % halo.id,
                     fontsize=self.font_size)
 
+class HopParticleCallback(PlotCallback):
+    def __init__(self, hop_output, axis, p_size=1.0, color=True,
+                max_number=None, min_size=20, alpha=0.2):
+        self.axis = axis
+        self.hop_output = hop_output
+        self.p_size = p_size
+        self.color = color
+        self.max_number = max_number
+        self.min_size = min_size
+        self.alpha = alpha
+    
+    def __call__(self,plot):
+        if self.max_number < 1: return
+        from numpy import *
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        xx0, xx1 = plot._axes.get_xlim()
+        yy0, yy1 = plot._axes.get_ylim()
+        l, b, width, height = _get_bounds(plot._axes.bbox)
+        xi = lagos.x_dict[plot.data.axis]
+        yi = lagos.y_dict[plot.data.axis]
+        dx = plot.image._A.shape[0] / (x1-x0)
+        dy = plot.image._A.shape[1] / (y1-y0)
+        # now we loop over the haloes
+        for halo in self.hop_output[:self.max_number]:
+            if halo.get_size() < self.min_size: continue
+            particles_x = []; particles_y = []; colors = [];
+            p = halo.get_positions()
+            colors_temp = ones_like(p[xi])
+            colors.append(colors_temp[::1])
+            colors = na.concatenate(colors)
+            particles_x.append(p[xi][::1])
+            particles_x = na.concatenate(particles_x)
+            particles_y.append(p[yi][::1])
+            particles_y = na.concatenate(particles_y)
+            plot._axes.hold(True)
+            plot._axes.scatter(particles_x*dx,particles_y*dy,edgecolors='None',
+                               s=self.p_size, color='black',alpha=self.alpha)
+            plot._axes.set_xlim(xx0,xx1)
+            plot._axes.set_ylim(yy0,yy1)
+            plot._axes.hold(False)
+
 class FloorToValueInPlot(PlotCallback):
     def __init__(self):
         pass



More information about the yt-svn mailing list