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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Aug 4 05:29:13 PDT 2014


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/6d615405b72a/
Changeset:   6d615405b72a
Branch:      yt-3.0
User:        chummels
Date:        2014-08-03 03:26:41
Summary:     Renaming the particle fields associated with spherical coords and velocities to be more descriptively named and including docstrings.  There are no other references to them elsewhere in the code and/or docs, so this is it.
Affected #:  3 files

diff -r 4a8c93735cdf58c42d1f60dbd3fb323e227ab982 -r 6d615405b72a33501f025c3090059771fda8152c doc/source/reference/field_list.rst
--- a/doc/source/reference/field_list.rst
+++ b/doc/source/reference/field_list.rst
@@ -7,7 +7,8 @@
 This is a list of many of the fields available in ``yt``.  We have attempted to
 include most of the fields that are accessible through the plugin system, as well as
 the fields that are known by the frontends, however it is possible to generate many more
-permutations, particularly through vector operations.
+permutations, particularly through vector operations. For more information about the fields
+framework, see :ref:`fields`.
 
 Some fields are recognized by specific frontends only. These are typically fields like density
 and temperature that have their own names and units in the different frontend datasets. Often,
@@ -26,6 +27,9 @@
   for i in sorted(ds.field_list):
     print i
 
+To figure out out what all of the field types here mean, see
+:ref:`known-field-types`.
+
 .. _yt_fields:
 
 Fields Generated by ``yt``
@@ -127,53 +131,6 @@
           return data.apply_units(v, field.units)
   
 
-('all', 'particle_phi_spherical')
----------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_phi_spherical(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = spos
-          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          sphp = get_sph_phi_component(pos, phi, normal)
-          return sphp
-  
-
-('all', 'particle_phi_velocity')
---------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_phi_velocity(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = YTArray([data[ptype, spos % ax] for ax in "xyz"])
-          vel = YTArray([data[ptype, svel % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          vel = vel - np.reshape(bv, (3, 1))
-          sphp = get_sph_phi_component(vel, phi, normal)
-          return sphp
-  
-
 ('all', 'particle_position')
 ----------------------------
 
@@ -201,7 +158,12 @@
 
 .. code-block:: python
 
-      def _particle_radial_velocity(field, data):
+      def _particle_spherical_velocity_radius(field, data):
+          """
+          Particles' radial-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")
@@ -231,29 +193,6 @@
           return get_radius(data, "particle_position_")
   
 
-('all', 'particle_radius_spherical')
-------------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_radius_spherical(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = spos
-          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          sphr = get_sph_r_component(pos, theta, phi, normal)
-          return sphr
-  
-
 ('all', 'particle_specific_angular_momentum')
 ---------------------------------------------
 
@@ -368,17 +307,78 @@
           return xv*y - yv*x
   
 
-('all', 'particle_theta_spherical')
------------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_theta_spherical(field, data):
+('all', 'particle_spherical_position_phi')
+------------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_phi(field, data):
+          """
+          Particles' phi positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          sphp = get_sph_phi_component(pos, phi, normal)
+          return sphp
+  
+
+('all', 'particle_spherical_position_radius')
+---------------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_radius(field, data):
+          """
+          Particles' radial positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          sphr = get_sph_r_component(pos, theta, phi, normal)
+          return sphr
+  
+
+('all', 'particle_spherical_position_theta')
+--------------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_theta(field, data):
+          """
+          Particles' theta positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")
@@ -391,8 +391,8 @@
           return spht
   
 
-('all', 'particle_theta_velocity')
-----------------------------------
+('all', 'particle_spherical_velocity_phi')
+------------------------------------------
 
    * Units: :math:`\rm{cm} / \rm{s}`
    * Particle Type: True
@@ -401,7 +401,72 @@
 
 .. code-block:: python
 
-      def _particle_theta_velocity(field, data):
+      def _particle_spherical_velocity_phi(field, data):
+          """
+          Particles' phi-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = YTArray([data[ptype, spos % ax] for ax in "xyz"])
+          vel = YTArray([data[ptype, svel % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          vel = vel - np.reshape(bv, (3, 1))
+          sphp = get_sph_phi_component(vel, phi, normal)
+          return sphp
+  
+
+('all', 'particle_spherical_velocity_radius')
+---------------------------------------------
+
+   * Units: :math:`\rm{cm} / \rm{s}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_velocity_radius(field, data):
+          """
+          Particles' radial-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          vel = svel
+          vel = YTArray([data[ptype, vel % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          vel = vel - np.reshape(bv, (3, 1))
+          sphr = get_sph_r_component(vel, theta, phi, normal)
+          return sphr
+  
+
+('all', 'particle_spherical_velocity_theta')
+--------------------------------------------
+
+   * Units: :math:`\rm{cm} / \rm{s}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_velocity_theta(field, data):
+          """
+          Particles' theta-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")
@@ -3032,53 +3097,6 @@
           return data.apply_units(v, field.units)
   
 
-('io', 'particle_phi_spherical')
---------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_phi_spherical(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = spos
-          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          sphp = get_sph_phi_component(pos, phi, normal)
-          return sphp
-  
-
-('io', 'particle_phi_velocity')
--------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_phi_velocity(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = YTArray([data[ptype, spos % ax] for ax in "xyz"])
-          vel = YTArray([data[ptype, svel % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          vel = vel - np.reshape(bv, (3, 1))
-          sphp = get_sph_phi_component(vel, phi, normal)
-          return sphp
-  
-
 ('io', 'particle_position')
 ---------------------------
 
@@ -3106,7 +3124,12 @@
 
 .. code-block:: python
 
-      def _particle_radial_velocity(field, data):
+      def _particle_spherical_velocity_radius(field, data):
+          """
+          Particles' radial-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")
@@ -3136,29 +3159,6 @@
           return get_radius(data, "particle_position_")
   
 
-('io', 'particle_radius_spherical')
------------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_radius_spherical(field, data):
-          normal = data.get_field_parameter('normal')
-          center = data.get_field_parameter('center')
-          bv = data.get_field_parameter("bulk_velocity")
-          pos = spos
-          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
-          theta = get_sph_theta(pos, center)
-          phi = get_sph_phi(pos, center)
-          pos = pos - np.reshape(center, (3, 1))
-          sphr = get_sph_r_component(pos, theta, phi, normal)
-          return sphr
-  
-
 ('io', 'particle_specific_angular_momentum')
 --------------------------------------------
 
@@ -3273,17 +3273,78 @@
           return xv*y - yv*x
   
 
-('io', 'particle_theta_spherical')
-----------------------------------
-
-   * Units: :math:`\rm{cm} / \rm{s}`
-   * Particle Type: True
-
-**Field Source**
-
-.. code-block:: python
-
-      def _particle_theta_spherical(field, data):
+('io', 'particle_spherical_position_phi')
+-----------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_phi(field, data):
+          """
+          Particles' phi positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          sphp = get_sph_phi_component(pos, phi, normal)
+          return sphp
+  
+
+('io', 'particle_spherical_position_radius')
+--------------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_radius(field, data):
+          """
+          Particles' radial positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          sphr = get_sph_r_component(pos, theta, phi, normal)
+          return sphr
+  
+
+('io', 'particle_spherical_position_theta')
+-------------------------------------------
+
+   * Units: :math:`\rm{cm}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_position_theta(field, data):
+          """
+          Particles' theta positions in spherical coordinates based 
+          on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")
@@ -3296,8 +3357,8 @@
           return spht
   
 
-('io', 'particle_theta_velocity')
----------------------------------
+('io', 'particle_spherical_velocity_phi')
+-----------------------------------------
 
    * Units: :math:`\rm{cm} / \rm{s}`
    * Particle Type: True
@@ -3306,7 +3367,72 @@
 
 .. code-block:: python
 
-      def _particle_theta_velocity(field, data):
+      def _particle_spherical_velocity_phi(field, data):
+          """
+          Particles' phi-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = YTArray([data[ptype, spos % ax] for ax in "xyz"])
+          vel = YTArray([data[ptype, svel % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          vel = vel - np.reshape(bv, (3, 1))
+          sphp = get_sph_phi_component(vel, phi, normal)
+          return sphp
+  
+
+('io', 'particle_spherical_velocity_radius')
+--------------------------------------------
+
+   * Units: :math:`\rm{cm} / \rm{s}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_velocity_radius(field, data):
+          """
+          Particles' radial-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
+          normal = data.get_field_parameter('normal')
+          center = data.get_field_parameter('center')
+          bv = data.get_field_parameter("bulk_velocity")
+          pos = spos
+          pos = YTArray([data[ptype, pos % ax] for ax in "xyz"])
+          vel = svel
+          vel = YTArray([data[ptype, vel % ax] for ax in "xyz"])
+          theta = get_sph_theta(pos, center)
+          phi = get_sph_phi(pos, center)
+          pos = pos - np.reshape(center, (3, 1))
+          vel = vel - np.reshape(bv, (3, 1))
+          sphr = get_sph_r_component(vel, theta, phi, normal)
+          return sphr
+  
+
+('io', 'particle_spherical_velocity_theta')
+-------------------------------------------
+
+   * Units: :math:`\rm{cm} / \rm{s}`
+   * Particle Type: True
+
+**Field Source**
+
+.. code-block:: python
+
+      def _particle_spherical_velocity_theta(field, data):
+          """
+          Particles' theta-velocity components in spherical coordinates 
+          based on the provided field parameters for 'normal', 'center', and 
+          'bulk_velocity', 
+          """
           normal = data.get_field_parameter('normal')
           center = data.get_field_parameter('center')
           bv = data.get_field_parameter("bulk_velocity")

diff -r 4a8c93735cdf58c42d1f60dbd3fb323e227ab982 -r 6d615405b72a33501f025c3090059771fda8152c yt/fields/fluid_fields.py
--- a/yt/fields/fluid_fields.py
+++ b/yt/fields/fluid_fields.py
@@ -84,7 +84,7 @@
              units="cm/s")
 
     def _radial_mach_number(field, data):
-        """ M{|v|/t_sound} """
+        """ Radial component of M{|v|/c_sound} """
         tr = data[ftype, "radial_velocity"] / data[ftype, "sound_speed"]
         return np.abs(tr)
     registry.add_field((ftype, "radial_mach_number"),
@@ -100,7 +100,7 @@
                        units = "erg / cm**3")
 
     def _mach_number(field, data):
-        """ M{|v|/t_sound} """
+        """ M{|v|/c_sound} """
         return data[ftype, "velocity_magnitude"] / data[ftype, "sound_speed"]
     registry.add_field((ftype, "mach_number"),
             function=_mach_number,

diff -r 4a8c93735cdf58c42d1f60dbd3fb323e227ab982 -r 6d615405b72a33501f025c3090059771fda8152c yt/fields/particle_fields.py
--- a/yt/fields/particle_fields.py
+++ b/yt/fields/particle_fields.py
@@ -337,7 +337,12 @@
               units="cm", particle_type = True,
               display_name = "Particle Radius")
 
-    def _particle_radius_spherical(field, data):
+    def _particle_spherical_position_radius(field, data):
+        """
+        Particles' radial positions in spherical coordinates based 
+        on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -349,13 +354,18 @@
         sphr = get_sph_r_component(pos, theta, phi, normal)
         return sphr
 
-    registry.add_field((ptype, "particle_radius_spherical"),
-              function=_particle_radius_spherical,
-              particle_type=True, units="cm/s",
+    registry.add_field((ptype, "particle_spherical_position_radius"),
+              function=_particle_spherical_position_radius,
+              particle_type=True, units="cm",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])
 
-    def _particle_theta_spherical(field, data):
+    def _particle_spherical_position_theta(field, data):
+        """
+        Particles' theta positions in spherical coordinates based 
+        on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -367,13 +377,18 @@
         spht = get_sph_theta_component(pos, theta, phi, normal)
         return spht
 
-    registry.add_field((ptype, "particle_theta_spherical"),
-              function=_particle_theta_spherical,
-              particle_type=True, units="cm/s",
+    registry.add_field((ptype, "particle_spherical_position_theta"),
+              function=_particle_spherical_position_theta,
+              particle_type=True, units="cm",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])
 
-    def _particle_phi_spherical(field, data):
+    def _particle_spherical_position_phi(field, data):
+        """
+        Particles' phi positions in spherical coordinates based 
+        on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -385,13 +400,18 @@
         sphp = get_sph_phi_component(pos, phi, normal)
         return sphp
 
-    registry.add_field((ptype, "particle_phi_spherical"),
-              function=_particle_phi_spherical,
-              particle_type=True, units="cm/s",
+    registry.add_field((ptype, "particle_spherical_position_phi"),
+              function=_particle_spherical_position_phi,
+              particle_type=True, units="cm",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])
 
-    def _particle_radial_velocity(field, data):
+    def _particle_spherical_velocity_radius(field, data):
+        """
+        Particles' radial-velocity components in spherical coordinates 
+        based on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -406,13 +426,26 @@
         sphr = get_sph_r_component(vel, theta, phi, normal)
         return sphr
 
-    registry.add_field((ptype, "particle_radial_velocity"),
-              function=_particle_radial_velocity,
+    registry.add_field((ptype, "particle_spherical_velocity_radius"),
+              function=_particle_spherical_velocity_radius,
               particle_type=True, units="cm/s",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])
 
-    def _particle_theta_velocity(field, data):
+    # This is simply aliased to "particle_spherical_velocity_radius"
+    # for ease of use.
+    registry.add_field((ptype, "particle_radial_velocity"),
+              function=_particle_spherical_velocity_radius,
+              particle_type=True, units="cm/s",
+              validators=[ValidateParameter("normal"), 
+                          ValidateParameter("center")])
+
+    def _particle_spherical_velocity_theta(field, data):
+        """
+        Particles' theta-velocity components in spherical coordinates 
+        based on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -427,13 +460,18 @@
         spht = get_sph_theta_component(vel, theta, phi, normal)
         return spht
 
-    registry.add_field((ptype, "particle_theta_velocity"),
-              function=_particle_theta_velocity,
+    registry.add_field((ptype, "particle_spherical_velocity_theta"),
+              function=_particle_spherical_velocity_theta,
               particle_type=True, units="cm/s",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])
 
-    def _particle_phi_velocity(field, data):
+    def _particle_spherical_velocity_phi(field, data):
+        """
+        Particles' phi-velocity components in spherical coordinates 
+        based on the provided field parameters for 'normal', 'center', and 
+        'bulk_velocity', 
+        """
         normal = data.get_field_parameter('normal')
         center = data.get_field_parameter('center')
         bv = data.get_field_parameter("bulk_velocity")
@@ -446,8 +484,8 @@
         sphp = get_sph_phi_component(vel, phi, normal)
         return sphp
 
-    registry.add_field((ptype, "particle_phi_velocity"),
-              function=_particle_phi_velocity,
+    registry.add_field((ptype, "particle_spherical_velocity_phi"),
+              function=_particle_spherical_velocity_phi,
               particle_type=True, units="cm/s",
               validators=[ValidateParameter("normal"), 
                           ValidateParameter("center")])


https://bitbucket.org/yt_analysis/yt/commits/75075f999b8b/
Changeset:   75075f999b8b
Branch:      yt-3.0
User:        chummels
Date:        2014-08-03 03:31:37
Summary:     Merging.
Affected #:  4 files

diff -r 6d615405b72a33501f025c3090059771fda8152c -r 75075f999b8b2f201052c2c65cf8078458aa33ca doc/source/analyzing/analysis_modules/SZ_projections.ipynb
--- a/doc/source/analyzing/analysis_modules/SZ_projections.ipynb
+++ b/doc/source/analyzing/analysis_modules/SZ_projections.ipynb
@@ -1,7 +1,7 @@
 {
  "metadata": {
   "name": "",
-  "signature": "sha256:e4db171b795d155870280ddbe8986f55f9a94ffb10783abf9d4cc2de3ec24894"
+  "signature": "sha256:2cc168b2c1737c67647aa29892c0213e7a58233fa53c809f9cd975a4306e9bc8"
  },
  "nbformat": 3,
  "nbformat_minor": 0,
@@ -89,6 +89,7 @@
      "cell_type": "code",
      "collapsed": false,
      "input": [
+      "%matplotlib inline\n",
       "import yt\n",
       "from yt.analysis_modules.sunyaev_zeldovich.api import SZProjection\n",
       "\n",
@@ -222,4 +223,4 @@
    "metadata": {}
   }
  ]
-}
+}
\ No newline at end of file

diff -r 6d615405b72a33501f025c3090059771fda8152c -r 75075f999b8b2f201052c2c65cf8078458aa33ca doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -60,7 +60,7 @@
    # Set up the camera parameters: center, looking direction, width, resolution
    c = (ds.domain_right_edge + ds.domain_left_edge)/2.0
    L = np.array([1.0, 1.0, 1.0])
-   W = ds.quan(0.3, 'unitary)
+   W = ds.quan(0.3, 'unitary')
    N = 256 
 
    # Create a camera object

diff -r 6d615405b72a33501f025c3090059771fda8152c -r 75075f999b8b2f201052c2c65cf8078458aa33ca yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -39,6 +39,8 @@
     io_registry
 from yt.utilities.lib.misc_utilities import \
     get_box_grids_level
+from yt.data_objects.particle_unions import \
+    ParticleUnion
 
 from yt.frontends.art.definitions import *
 import yt.utilities.fortran_utils as fpu
@@ -104,17 +106,7 @@
         self.particle_field_list = [f for f in particle_fields]
         self.field_list = [("art", f) for f in fluid_fields]
         # now generate all of the possible particle fields
-        if "wspecies" in self.dataset.parameters.keys():
-            wspecies = self.dataset.parameters['wspecies']
-            nspecies = len(wspecies)
-            self.dataset.particle_types = ["darkmatter", "stars"]
-            for specie in range(nspecies):
-                self.dataset.particle_types.append("specie%i" % specie)
-            self.dataset.particle_types_raw = tuple(
-                self.dataset.particle_types)
-        else:
-            self.dataset.particle_types = []
-        for ptype in self.dataset.particle_types:
+        for ptype in self.dataset.particle_types_raw:
             for pfield in self.particle_field_list:
                 pfn = (ptype, pfield)
                 self.field_list.append(pfn)
@@ -313,6 +305,8 @@
             self.root_level = root_level
             mylog.info("Using root level of %02i", self.root_level)
         # read the particle header
+        self.particle_types = []
+        self.particle_types_raw = ()
         if not self.skip_particles and self._file_particle_header:
             with open(self._file_particle_header, "rb") as fh:
                 particle_header_vals = fpu.read_attrs(
@@ -323,6 +317,10 @@
                 lspecies = np.fromfile(fh, dtype='>i', count=10)
             self.parameters['wspecies'] = wspecies[:n]
             self.parameters['lspecies'] = lspecies[:n]
+            for specie in range(n):
+                self.particle_types.append("specie%i" % specie)
+            self.particle_types_raw = tuple(
+                self.particle_types)
             ls_nonzero = np.diff(lspecies)[:n-1]
             ls_nonzero = np.append(lspecies[0], ls_nonzero)
             self.star_type = len(ls_nonzero)
@@ -360,6 +358,16 @@
         self.gamma = self.parameters["gamma"]
         mylog.info("Max level is %02i", self.max_level)
 
+    def create_field_info(self):
+        super(ARTDataset, self).create_field_info()
+        if "wspecies" in self.parameters:
+            # We create dark_matter and stars unions.
+            ptr = self.particle_types_raw
+            pu = ParticleUnion("darkmatter", list(ptr[:-1]))
+            self.add_particle_union(pu)
+            pu = ParticleUnion("stars", list(ptr[-1:]))
+            self.add_particle_union(pu)
+
     @classmethod
     def _is_valid(self, *args, **kwargs):
         """

diff -r 6d615405b72a33501f025c3090059771fda8152c -r 75075f999b8b2f201052c2c65cf8078458aa33ca yt/frontends/art/io.py
--- a/yt/frontends/art/io.py
+++ b/yt/frontends/art/io.py
@@ -39,6 +39,11 @@
         self.cache = {}
         self.masks = {}
         super(IOHandlerART, self).__init__(*args, **kwargs)
+        self.ws = self.ds.parameters["wspecies"]
+        self.ls = self.ds.parameters["lspecies"]
+        self.file_particle = self.ds._file_particle_data
+        self.file_stars = self.ds._file_particle_stars
+        self.Nrow = self.ds.parameters["Nrow"]
 
     def _read_fluid_selection(self, chunks, selector, fields, size):
         # Chunks in this case will have affiliated domain subset objects
@@ -70,8 +75,6 @@
         if key in self.masks.keys() and self.caching:
             return self.masks[key]
         ds = self.ds
-        ptmax = self.ws[-1]
-        pbool, idxa, idxb = _determine_field_size(ds, ftype, self.ls, ptmax)
         pstr = 'particle_position_%s'
         x,y,z = [self._get_field((ftype, pstr % ax)) for ax in 'xyz']
         mask = selector.select_points(x, y, z, 0.0)
@@ -81,6 +84,26 @@
         else:
             return mask
 
+    def _read_particle_coords(self, chunks, ptf):
+        for chunk in chunks:
+            for ptype, field_list in sorted(ptf.items()):
+                x = self._get_field((ptype, "particle_position_x"))
+                y = self._get_field((ptype, "particle_position_y"))
+                z = self._get_field((ptype, "particle_position_z"))
+                yield ptype, (x, y, z)
+
+    def _read_particle_fields(self, chunks, ptf, selector):
+        for chunk in chunks:
+            for ptype, field_list in sorted(ptf.items()):
+                x = self._get_field((ptype, "particle_position_x"))
+                y = self._get_field((ptype, "particle_position_y"))
+                z = self._get_field((ptype, "particle_position_z"))
+                mask = selector.select_points(x, y, z, 0.0)
+                if mask is None: continue
+                for field in field_list:
+                    data = self._get_field((ptype, field))
+                    yield (ptype, field), data[mask]
+
     def _get_field(self,  field):
         if field in self.cache.keys() and self.caching:
             mylog.debug("Cached %s", str(field))
@@ -139,6 +162,13 @@
             temp[-nstars:] = data
             tr[field] = temp
             del data
+        # We check again, after it's been filled
+        if fname == "particle_mass":
+            # We now divide by NGrid in order to make this match up.  Note that
+            # this means that even when requested in *code units*, we are
+            # giving them as modified by the ng value.  This only works for
+            # dark_matter -- stars are regular matter.
+            tr[field] /= self.ds.domain_dimensions.prod()
         if tr == {}:
             tr = dict((f, np.array([])) for f in fields)
         if self.caching:
@@ -147,35 +177,15 @@
         else:
             return tr[field]
 
-    def _read_particle_selection(self, chunks, selector, fields):
-        chunk = chunks.next()
-        self.ds = chunk.objs[0].domain.ds
-        self.ws = self.ds.parameters["wspecies"]
-        self.ls = self.ds.parameters["lspecies"]
-        self.file_particle = self.ds._file_particle_data
-        self.file_stars = self.ds._file_particle_stars
-        self.Nrow = self.ds.parameters["Nrow"]
-        data = {f:np.array([]) for f in fields}
-        for f in fields:
-            ftype, fname = f
-            mask = self._get_mask(selector, ftype)
-            arr = self._get_field(f)[mask].astype('f8')
-            data[f] = np.concatenate((arr, data[f]))
-        return data
-
-def _determine_field_size(ds, field, lspecies, ptmax):
+def _determine_field_size(pf, field, lspecies, ptmax):
     pbool = np.zeros(len(lspecies), dtype="bool")
     idxas = np.concatenate(([0, ], lspecies[:-1]))
     idxbs = lspecies
     if "specie" in field:
         index = int(field.replace("specie", ""))
         pbool[index] = True
-    elif field == "stars":
-        pbool[-1] = True
-    elif field == "darkmatter":
-        pbool[0:-1] = True
     else:
-        pbool[:] = True
+        raise RuntimeError
     idxa, idxb = idxas[pbool][0], idxbs[pbool][-1]
     return pbool, idxa, idxb
 


https://bitbucket.org/yt_analysis/yt/commits/6049ff0178b6/
Changeset:   6049ff0178b6
Branch:      yt-3.0
User:        chummels
Date:        2014-08-03 16:41:24
Summary:     Updating docstrings for spherical components of particle fields consistent with Nathan's suggestions.
Affected #:  1 file

diff -r 75075f999b8b2f201052c2c65cf8078458aa33ca -r 6049ff0178b6b5dd56adbad27972e1671a349ef0 yt/fields/particle_fields.py
--- a/yt/fields/particle_fields.py
+++ b/yt/fields/particle_fields.py
@@ -339,7 +339,7 @@
 
     def _particle_spherical_position_radius(field, data):
         """
-        Particles' radial positions in spherical coordinates based 
+        Radial component of the particles' position vectors in spherical coords
         on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """
@@ -362,7 +362,7 @@
 
     def _particle_spherical_position_theta(field, data):
         """
-        Particles' theta positions in spherical coordinates based 
+        Theta component of the particles' position vectors in spherical coords
         on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """
@@ -385,7 +385,7 @@
 
     def _particle_spherical_position_phi(field, data):
         """
-        Particles' phi positions in spherical coordinates based 
+        Phi component of the particles' position vectors in spherical coords
         on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """
@@ -408,7 +408,7 @@
 
     def _particle_spherical_velocity_radius(field, data):
         """
-        Particles' radial-velocity components in spherical coordinates 
+        Radial component of the particles' velocity vectors in spherical coords
         based on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """
@@ -442,7 +442,7 @@
 
     def _particle_spherical_velocity_theta(field, data):
         """
-        Particles' theta-velocity components in spherical coordinates 
+        Theta component of the particles' velocity vectors in spherical coords
         based on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """
@@ -468,7 +468,7 @@
 
     def _particle_spherical_velocity_phi(field, data):
         """
-        Particles' phi-velocity components in spherical coordinates 
+        Phi component of the particles' velocity vectors in spherical coords
         based on the provided field parameters for 'normal', 'center', and 
         'bulk_velocity', 
         """


https://bitbucket.org/yt_analysis/yt/commits/af0201dadeeb/
Changeset:   af0201dadeeb
Branch:      yt-3.0
User:        chummels
Date:        2014-08-03 16:44:27
Summary:     Merging.
Affected #:  1 file

diff -r 6049ff0178b6b5dd56adbad27972e1671a349ef0 -r af0201dadeebed1e66e3470e718a225470140b95 doc/source/cookbook/particle_filter.py
--- a/doc/source/cookbook/particle_filter.py
+++ b/doc/source/cookbook/particle_filter.py
@@ -2,24 +2,33 @@
 import numpy as np
 from yt.data_objects.particle_filters import add_particle_filter
 
+
 # Define filter functions for our particle filters based on stellar age.
+# In this dataset particles in the initial conditions are given creation
+# times arbitrarily far into the future, so stars with negative ages belong
+# in the old stars filter.
 def stars_10Myr(pfilter, data):
-    filter = (data.pf.current_time - data["Stars", "creation_time"]).in_units('Myr') <= 10
+    age = data.ds.current_time - data["Stars", "creation_time"]
+    filter = np.logical_and(age >= 0, age.in_units('Myr') < 10)
     return filter
 
 def stars_100Myr(pfilter, data):
-    filter = (((data.pf.current_time - data["Stars", "creation_time"]).in_units('Myr') <= 100) & \
-              ((data.pf.current_time - data["Stars", "creation_time"]).in_units('Myr') >= 10))
+    age = (data.ds.current_time - data["Stars", "creation_time"]).in_units('Myr')
+    filter = np.logical_and(age >= 10, age < 100)
     return filter
 
 def stars_old(pfilter, data):
-    filter = (data.pf.current_time - data["Stars", "creation_time"]).in_units('Myr') > 100
+    age = data.ds.current_time - data["Stars", "creation_time"]
+    filter = np.logical_or(age < 0, age.in_units('Myr') >= 100)
     return filter
 
 # Create the particle filters
-add_particle_filter("stars_young", function=stars_10Myr, filtered_type='Stars', requires=["creation_time"])
-add_particle_filter("stars_medium", function=stars_100Myr, filtered_type='Stars', requires=["creation_time"])
-add_particle_filter("stars_old", function=stars_old, filtered_type='Stars', requires=["creation_time"])
+add_particle_filter("stars_young", function=stars_10Myr, filtered_type='Stars',
+                    requires=["creation_time"])
+add_particle_filter("stars_medium", function=stars_100Myr, filtered_type='Stars',
+                    requires=["creation_time"])
+add_particle_filter("stars_old", function=stars_old, filtered_type='Stars',
+                    requires=["creation_time"])
 
 # Load a dataset and apply the particle filters
 filename = "TipsyGalaxy/galaxy.00300"
@@ -39,5 +48,8 @@
 print "Mass of old stars = %g Msun" % mass_old
 
 # Generate 4 projections: gas density, young stars, medium stars, old stars
-prj = yt.ProjectionPlot(ds, 'z', [('gas', 'density'), ('deposit', 'stars_young_cic'), ('deposit', 'stars_medium_cic'), ('deposit', 'stars_old_cic')], center="max", width=(100, 'kpc'))
+fields = [('gas', 'density'), ('deposit', 'stars_young_cic'),
+          ('deposit', 'stars_medium_cic'), ('deposit', 'stars_old_cic')]
+
+prj = yt.ProjectionPlot(ds, 'z', fields, center="max", width=(100, 'kpc'))
 prj.save()

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