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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jul 3 10:33:08 PDT 2014


6 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/c305e2747e0a/
Changeset:   c305e2747e0a
Branch:      yt-3.0
User:        hegan
Date:        2014-07-02 23:27:00
Summary:     Fixed halo annotation to respect comoving units, and accurately reflect radii
Affected #:  1 file

diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c305e2747e0a7043061b330c7cc2ef2edc6a4586 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -16,6 +16,7 @@
 
 import numpy as np
 import h5py
+from matplotlib.patches import Circle
 
 from yt.funcs import *
 from yt.extern.six import add_metaclass
@@ -871,7 +872,8 @@
     _descriptor = None
 
     def __init__(self, halo_catalog, col='white', alpha =1, 
-            width = None, annotate_field = False, font_kwargs = None):
+            width = None, annotate_field = False,
+            font_kwargs = None, factor = 1.0):
 
         PlotCallback.__init__(self)
         self.halo_catalog = halo_catalog
@@ -880,6 +882,7 @@
         self.width = width
         self.annotate_field = annotate_field
         self.font_kwargs = font_kwargs
+        self.factor = factor
 
     def __call__(self, plot):
         data = plot.data
@@ -898,20 +901,20 @@
         plot._axes.hold(True)
 
         # Set up scales for pixel size and original data
-        units = 'Mpccm'
         pixel_scale = self.pixel_scale(plot)[0]
         data_scale = data.pf.length_unit
+        units = data_scale.units
 
         # Convert halo positions to code units of the plotted data
         # and then to units of the plotted window
         px = halo_data[field_x][:].in_units(units) / data_scale
         py = halo_data[field_y][:].in_units(units) / data_scale
         px, py = self.convert_to_plot(plot,[px,py])
+
+        # Convert halo radii to a radius in pixels
+        radius = halo_data['virial_radius'][:].in_units(units)
+        radius = radius*pixel_scale*self.factor/data_scale
         
-        # Convert halo radii to a radius in pixels
-        radius = halo_data['radius'][:].in_units(units)
-        radius = radius*pixel_scale/data_scale
-
         if self.width:
             pz = halo_data[field_z][:].in_units(units)/data_scale
             pz = data.pf.arr(pz, 'code_length')
@@ -927,8 +930,10 @@
             py = py[indices]
             radius = radius[indices]
 
-        plot._axes.scatter(px, py, edgecolors='None', marker='o',
-                           s=radius, c=self.color,alpha=self.alpha)
+        for x,y,r in zip(px, py, radius):
+            plot._axes.add_artist(Circle(xy=(x,y), 
+                radius = r,  color=self.color, alpha=self.alpha))
+
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)
         plot._axes.hold(False)


https://bitbucket.org/yt_analysis/yt/commits/be426814140e/
Changeset:   be426814140e
Branch:      yt-3.0
User:        hegan
Date:        2014-07-02 23:28:58
Summary:     clarifying colors
Affected #:  1 file

diff -r c305e2747e0a7043061b330c7cc2ef2edc6a4586 -r be426814140e54c5fbe87c2392817e07c905e00a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -932,7 +932,8 @@
 
         for x,y,r in zip(px, py, radius):
             plot._axes.add_artist(Circle(xy=(x,y), 
-                radius = r,  color=self.color, alpha=self.alpha))
+                radius = r,  facecolor=self.color,
+                edgecolor = 'None', alpha=self.alpha))
 
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)


https://bitbucket.org/yt_analysis/yt/commits/38056c687fb9/
Changeset:   38056c687fb9
Branch:      yt-3.0
User:        hegan
Date:        2014-07-03 00:28:16
Summary:     added circle kwargs and gave sane defaults
Affected #:  1 file

diff -r be426814140e54c5fbe87c2392817e07c905e00a -r 38056c687fb91e5e5fa0d215fb94d112de8b9b3a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -871,18 +871,19 @@
     region = None
     _descriptor = None
 
-    def __init__(self, halo_catalog, col='white', alpha =1, 
+    def __init__(self, halo_catalog, circle_kwargs = None, 
             width = None, annotate_field = False,
             font_kwargs = None, factor = 1.0):
 
         PlotCallback.__init__(self)
         self.halo_catalog = halo_catalog
-        self.color = col
-        self.alpha = alpha
         self.width = width
         self.annotate_field = annotate_field
         self.font_kwargs = font_kwargs
         self.factor = factor
+        if circle_kwargs is None:
+            circle_kwargs = {'edgecolor':'white', 'facecolor':'None'}
+        self.circle_kwargs = circle_kwargs
 
     def __call__(self, plot):
         data = plot.data
@@ -932,8 +933,7 @@
 
         for x,y,r in zip(px, py, radius):
             plot._axes.add_artist(Circle(xy=(x,y), 
-                radius = r,  facecolor=self.color,
-                edgecolor = 'None', alpha=self.alpha))
+                radius = r, **self.circle_kwargs)) 
 
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)


https://bitbucket.org/yt_analysis/yt/commits/25d1a86cdc86/
Changeset:   25d1a86cdc86
Branch:      yt-3.0
User:        hegan
Date:        2014-07-03 00:37:03
Summary:     added docstring to annotate_halos
Affected #:  1 file

diff -r 38056c687fb91e5e5fa0d215fb94d112de8b9b3a -r 25d1a86cdc869427c672143aac33e2ec69341ea9 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -866,6 +866,31 @@
         plot._axes.text(x, y, self.text, **kwargs)
 
 class HaloCatalogCallback(PlotCallback):
+    """
+    annotate_halos(halo_catalog, circle_kwargs=None,
+        width = None, annotate_field=False,
+        font_kwargs = None, factor = 1.0)
+
+    Plots circles at the locations of all the halos
+    in a halo catalog with radii corresponding to the
+    virial radius of each halo. 
+
+    circle_kwargs: Contains the arguments controlling the
+        appearance of the circles, supplied to the 
+        Matplotlib patch Circle.
+    width: the width over which to select halos to plot,
+        useful when overplotting to a slice plot. Accepts
+        a tuple in the form (1.0, 'Mpc').
+    annotate_field: Accepts a field contained in the 
+        halo catalog to add text to the plot near the halo.
+        Example: annotate_field = 'particle_mass' will
+        write the halo mass next to each halo.
+    font_kwargs: Contains the arguments controlling the text
+        appearance of the annotated field.
+    factor: A number the virial radius is multiplied by for
+        plotting the circles. Ex: factor = 2.0 will plot
+        circles with twice the radius of each halo virial radius.
+    """
 
     _type_name = 'halos'
     region = None


https://bitbucket.org/yt_analysis/yt/commits/2da411ca16e3/
Changeset:   2da411ca16e3
Branch:      yt-3.0
User:        hegan
Date:        2014-07-03 17:10:36
Summary:     making radius stop being a YTarray because of matplotlib bug
Affected #:  1 file

diff -r 25d1a86cdc869427c672143aac33e2ec69341ea9 -r 2da411ca16e3550f11653d2f5f1e48baf17570df yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -939,7 +939,7 @@
 
         # Convert halo radii to a radius in pixels
         radius = halo_data['virial_radius'][:].in_units(units)
-        radius = radius*pixel_scale*self.factor/data_scale
+        radius = np.array(radius*pixel_scale*self.factor/data_scale)
         
         if self.width:
             pz = halo_data[field_z][:].in_units(units)/data_scale


https://bitbucket.org/yt_analysis/yt/commits/a5713a69df23/
Changeset:   a5713a69df23
Branch:      yt-3.0
User:        ngoldbaum
Date:        2014-07-03 19:32:59
Summary:     Merged in hegan/yt/yt-3.0 (pull request #991)

Updates to the annotate halos callback
Affected #:  1 file

diff -r 599797ab880b78ea678c7ce63bb4c70b41394620 -r a5713a69df23a99d04e52a66344aadc7c40295a5 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -16,6 +16,7 @@
 
 import numpy as np
 import h5py
+from matplotlib.patches import Circle
 
 from yt.funcs import *
 from yt.extern.six import add_metaclass
@@ -865,21 +866,49 @@
         plot._axes.text(x, y, self.text, **kwargs)
 
 class HaloCatalogCallback(PlotCallback):
+    """
+    annotate_halos(halo_catalog, circle_kwargs=None,
+        width = None, annotate_field=False,
+        font_kwargs = None, factor = 1.0)
+
+    Plots circles at the locations of all the halos
+    in a halo catalog with radii corresponding to the
+    virial radius of each halo. 
+
+    circle_kwargs: Contains the arguments controlling the
+        appearance of the circles, supplied to the 
+        Matplotlib patch Circle.
+    width: the width over which to select halos to plot,
+        useful when overplotting to a slice plot. Accepts
+        a tuple in the form (1.0, 'Mpc').
+    annotate_field: Accepts a field contained in the 
+        halo catalog to add text to the plot near the halo.
+        Example: annotate_field = 'particle_mass' will
+        write the halo mass next to each halo.
+    font_kwargs: Contains the arguments controlling the text
+        appearance of the annotated field.
+    factor: A number the virial radius is multiplied by for
+        plotting the circles. Ex: factor = 2.0 will plot
+        circles with twice the radius of each halo virial radius.
+    """
 
     _type_name = 'halos'
     region = None
     _descriptor = None
 
-    def __init__(self, halo_catalog, col='white', alpha =1, 
-            width = None, annotate_field = False, font_kwargs = None):
+    def __init__(self, halo_catalog, circle_kwargs = None, 
+            width = None, annotate_field = False,
+            font_kwargs = None, factor = 1.0):
 
         PlotCallback.__init__(self)
         self.halo_catalog = halo_catalog
-        self.color = col
-        self.alpha = alpha
         self.width = width
         self.annotate_field = annotate_field
         self.font_kwargs = font_kwargs
+        self.factor = factor
+        if circle_kwargs is None:
+            circle_kwargs = {'edgecolor':'white', 'facecolor':'None'}
+        self.circle_kwargs = circle_kwargs
 
     def __call__(self, plot):
         data = plot.data
@@ -898,20 +927,20 @@
         plot._axes.hold(True)
 
         # Set up scales for pixel size and original data
-        units = 'Mpccm'
         pixel_scale = self.pixel_scale(plot)[0]
         data_scale = data.pf.length_unit
+        units = data_scale.units
 
         # Convert halo positions to code units of the plotted data
         # and then to units of the plotted window
         px = halo_data[field_x][:].in_units(units) / data_scale
         py = halo_data[field_y][:].in_units(units) / data_scale
         px, py = self.convert_to_plot(plot,[px,py])
+
+        # Convert halo radii to a radius in pixels
+        radius = halo_data['virial_radius'][:].in_units(units)
+        radius = np.array(radius*pixel_scale*self.factor/data_scale)
         
-        # Convert halo radii to a radius in pixels
-        radius = halo_data['radius'][:].in_units(units)
-        radius = radius*pixel_scale/data_scale
-
         if self.width:
             pz = halo_data[field_z][:].in_units(units)/data_scale
             pz = data.pf.arr(pz, 'code_length')
@@ -927,8 +956,10 @@
             py = py[indices]
             radius = radius[indices]
 
-        plot._axes.scatter(px, py, edgecolors='None', marker='o',
-                           s=radius, c=self.color,alpha=self.alpha)
+        for x,y,r in zip(px, py, radius):
+            plot._axes.add_artist(Circle(xy=(x,y), 
+                radius = r, **self.circle_kwargs)) 
+
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)
         plot._axes.hold(False)

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