[Yt-svn] commit/yt: sskory: Adding support for a constant choice of angle between random pairs of points.

Bitbucket commits-noreply at bitbucket.org
Mon Mar 7 15:18:00 PST 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/8e125ead5d48/
changeset:   r3803:8e125ead5d48
branch:      yt
user:        sskory
date:        2011-03-08 00:15:46
summary:     Adding support for a constant choice of angle between random pairs of points.
affected #:  1 file (870 bytes)

--- a/yt/analysis_modules/two_point_functions/two_point_functions.py	Sun Mar 06 08:24:26 2011 -0800
+++ b/yt/analysis_modules/two_point_functions/two_point_functions.py	Mon Mar 07 16:15:46 2011 -0700
@@ -42,7 +42,7 @@
     def __init__(self, pf, fields, left_edge=None, right_edge=None,
             total_values=1000000, comm_size=10000, length_type="lin",
             length_number=10, length_range=None, vol_ratio = 1,
-            salt=0):
+            salt=0, theta=None, phi=None):
         r""" Initialize a two point functions object.
         
         Parameters
@@ -81,6 +81,15 @@
             keeping everything else constant from this set: (MPI task count, 
             number of ruler lengths, ruler min/max, number of functions,
             number of point pairs per ruler length). Default = 0.
+        theta : Float
+            For random pairs of points, the second point is found by traversing
+            a distance along a ray set by the angle (theta, phi) from the first
+            point. To keep this angle constant, set ``theta`` to a value in the
+            range [0, 2pi). Default = None, which will randomize theta for
+            every pair of points.
+        phi : Float
+            Similar to theta above, but the range of values is [-pi/2, pi/2].
+            Default = None, which will randomize phi for every pair of points.
         
         Examples
         --------
@@ -95,6 +104,8 @@
             raise ImportError("You need to install the Forthon kD-Tree")
         self._fsets = []
         self.fields = fields
+        self.constant_theta = theta
+        self.constant_phi = phi
         # MPI stuff.
         self.size = self._mpi_get_size()
         self.mine = self._mpi_get_rank()
@@ -463,8 +474,12 @@
                 high=self.ds.right_edge[dim], size=size)
         # Next we find the second point, determined by a random
         # theta, phi angle.
-        theta = self.mt.uniform(low=0, high=2.*math.pi, size=size)
-        phi = self.mt.uniform(low=-math.pi/2., high=math.pi/2., size=size)
+        if self.constant_theta is None:
+            theta = self.mt.uniform(low=0, high=2.*math.pi, size=size)
+        else: theta = self.constant_theta * na.ones(size, dtype='float64')
+        if self.constant_phi is None:
+            phi = self.mt.uniform(low=-math.pi/2., high=math.pi/2., size=size)
+        else: phi = self.constant_phi * na.ones(size, dtype='float64')
         r2 = na.empty((size,3), dtype='float64')
         r2[:,0] = r1[:,0] + length * na.cos(theta) * na.cos(phi)
         r2[:,1] = r1[:,1] + length * na.sin(theta) * na.cos(phi)

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