[yt-svn] commit/yt: chummels: Merged in krafczyk/yt (pull request #2493)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Jan 17 08:30:24 PST 2017


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/fc3d1369fd28/
Changeset:   fc3d1369fd28
Branch:      yt
User:        chummels
Date:        2017-01-17 16:29:58+00:00
Summary:     Merged in krafczyk/yt (pull request #2493)

Add new arguments to the annotate_halos callback
Affected #:  2 files

diff -r e03273b808d64c8e09a1914149bcea38e16e4831 -r fc3d1369fd2821a203b0bae4b94b53915254f468 doc/source/visualizing/callbacks.rst
--- a/doc/source/visualizing/callbacks.rst
+++ b/doc/source/visualizing/callbacks.rst
@@ -304,8 +304,10 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. function:: annotate_halos(self, halo_catalog, circle_args=None, \
-                             width=None, annotate_field=None, text_args=None, \
-                             factor=1.0)
+                             width=None, annotate_field=None, \
+                             radius_field='virial_radius', \
+                             center_field_prefix="particle_position", \
+                             text_args=None, factor=1.0)
 
    (This is a proxy for
    :class:`~yt.visualization.plot_modifications.HaloCatalogCallback`.)
@@ -321,11 +323,22 @@
    with the annotate_field, which 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, whereas
-   ``'particle_identifier'`` shows the halo number).  font_kwargs contains the
-   arguments controlling the text appearance of the annotated field.
-   Factor is the 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.
+   ``'particle_identifier'`` shows the halo number). The size of the circles is
+   found from the field ``radius_field`` which is ``'virial_radius'`` by
+   default. If another radius has been found as part of your halo analysis
+   workflow, you can save that field and use it as the ``radius_field`` to
+   change the size of the halos. The position of each halo is determined using
+   ``center_field_prefix`` in the following way. If ``'particle_position'``
+   is the value of ``center_field_prefix`` as is the default, the x value of
+   the halo position is stored in the field ``'particle_position_x'``, y is
+   ``'particle_position_y'``, and z is ``'particle_position_z'``. If you have
+   stored another set of coordinates for each halo as part of your halo
+   analysis as fields such as ``'halo_position_x'``, you can use these fields
+   to determine halo position by passing ``'halo_position'`` to
+   ``center_field_prefix``. font_kwargs contains the arguments controlling the
+   text appearance of the annotated field. Factor is the 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.
 
 .. python-script::
 

diff -r e03273b808d64c8e09a1914149bcea38e16e4831 -r fc3d1369fd2821a203b0bae4b94b53915254f468 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -1414,6 +1414,15 @@
         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.
+    radius_field: Accepts a field contained in the halo
+        catalog to set the radius of the circle which will
+        surround each halo.
+    center_field_prefix: Accepts a field prefix which will
+        be used to find the fields containing the coordinates
+        of the center of each halo. Ex: 'particle_position'
+        will result in the fields 'particle_position_x' for x
+        'particle_position_y' for y, and 'particle_position_z' 
+        for z.
     text_args: Contains the arguments controlling the text
         appearance of the annotated field.
     factor: A number the virial radius is multiplied by for
@@ -1427,14 +1436,17 @@
     _supported_geometries = ("cartesian", "spectral_cube")
 
     def __init__(self, halo_catalog, circle_args=None, circle_kwargs=None,
-                 width=None, annotate_field=None, text_args=None,
-                 font_kwargs=None, factor=1.0):
+                 width=None, annotate_field=None, radius_field='virial_radius',
+                 center_field_prefix="particle_position",
+                 text_args=None, font_kwargs=None, factor=1.0):
 
         PlotCallback.__init__(self)
         def_circle_args = {'edgecolor':'white', 'facecolor':'None'}
         def_text_args = {'color':'white'}
         self.halo_catalog = halo_catalog
         self.width = width
+        self.radius_field = radius_field
+        self.center_field_prefix = center_field_prefix
         self.annotate_field = annotate_field
         if circle_kwargs is not None:
             circle_args = circle_kwargs
@@ -1462,9 +1474,9 @@
         axis_names = plot.data.ds.coordinates.axis_name
         xax = plot.data.ds.coordinates.x_axis[data.axis]
         yax = plot.data.ds.coordinates.y_axis[data.axis]
-        field_x = "particle_position_%s" % axis_names[xax]
-        field_y = "particle_position_%s" % axis_names[yax]
-        field_z = "particle_position_%s" % axis_names[data.axis]
+        field_x = "%s_%s" % (self.center_field_prefix, axis_names[xax])
+        field_y = "%s_%s" % (self.center_field_prefix, axis_names[yax])
+        field_z = "%s_%s" % (self.center_field_prefix, axis_names[data.axis])
 
         # Set up scales for pixel size and original data
         pixel_scale = self.pixel_scale(plot)[0]
@@ -1478,7 +1490,7 @@
         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 = halo_data[self.radius_field][:].in_units(units)
         radius = np.array(radius*pixel_scale*self.factor/data_scale)
 
         if self.width:

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