[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Jun 27 13:15:18 PDT 2014
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/ff488410925e/
Changeset: ff488410925e
Branch: yt-3.0
User: ngoldbaum
Date: 2014-06-24 22:50:36
Summary: Updating ensure_numpy_array to handle ndarray sublcasses and zero-length arrays.
Affected #: 1 file
diff -r 0e28105c1c3bbaeb901e4a1ad14b72577f6ba8c7 -r ff488410925e24ce9d1e924cce21a25005039297 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -60,7 +60,10 @@
convert scalar, list or tuple argument passed to functions using Cython.
"""
if isinstance(obj, np.ndarray):
- return obj
+ if obj.shape == ():
+ return np.array([obj])
+ # We cast to ndarray to catch ndarray subclasses
+ return np.array(obj)
elif isinstance(obj, (types.ListType, types.TupleType)):
return np.asarray(obj)
else:
https://bitbucket.org/yt_analysis/yt/commits/33c3d60dc8dc/
Changeset: 33c3d60dc8dc
Branch: yt-3.0
User: ngoldbaum
Date: 2014-06-24 22:50:52
Summary: Adding find_field_value_at_point to the grid geometry handler.
Affected #: 1 file
diff -r ff488410925e24ce9d1e924cce21a25005039297 -r 33c3d60dc8dc8bd0760929b0db4338644634a981 yt/geometry/grid_geometry_handler.py
--- a/yt/geometry/grid_geometry_handler.py
+++ b/yt/geometry/grid_geometry_handler.py
@@ -241,6 +241,40 @@
ind = pts.find_points_in_tree()
return self.grids[ind], ind
+ def find_field_value_at_point(self, fields, coord):
+ r"""Find the value of fields at a coordinate.
+
+ Returns the values [field1, field2,...] of the fields at the given
+ (x, y, z) points. Returns a list of field values in the same order as
+ the input *fields*.
+
+ Parameters
+ ----------
+ fields : string or list of strings
+ The field(s) that will be returned.
+
+ coord : list or array of coordinates
+ The location for which field values will be returned.
+
+ Examples
+ --------
+ >>> pf.h.find_field_value_at_point(['Density', 'Temperature'],
+ [0.4, 0.3, 0.8])
+ [2.1489e-24, 1.23843e4]
+ """
+ this = self.find_points(*coord)[0][-1]
+ cellwidth = (this.RightEdge - this.LeftEdge) / this.ActiveDimensions
+ mark = np.zeros(3).astype('int')
+ # Find the index for the cell containing this point.
+ for dim in xrange(len(coord)):
+ mark[dim] = int((coord[dim] - this.LeftEdge[dim]) / cellwidth[dim])
+ out = []
+ fields = ensure_list(fields)
+ # Pull out the values and add it to the out list.
+ for field in fields:
+ out.append(this[field][mark[0], mark[1], mark[2]])
+ return out
+
def get_grid_tree(self) :
left_edge = self.pf.arr(np.zeros((self.num_grids, 3)),
https://bitbucket.org/yt_analysis/yt/commits/b2896a72bf4e/
Changeset: b2896a72bf4e
Branch: yt-3.0
User: MatthewTurk
Date: 2014-06-27 22:15:10
Summary: Merged in ngoldbaum/yt/yt-3.0 (pull request #977)
Adding find_field_value_at_point to the grid geometry handler
Affected #: 2 files
diff -r 35cecc8a0a24bbf074956ef320f70e0e686478a7 -r b2896a72bf4e6be36e61024d901faac6c2b7564f yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -60,7 +60,10 @@
convert scalar, list or tuple argument passed to functions using Cython.
"""
if isinstance(obj, np.ndarray):
- return obj
+ if obj.shape == ():
+ return np.array([obj])
+ # We cast to ndarray to catch ndarray subclasses
+ return np.array(obj)
elif isinstance(obj, (types.ListType, types.TupleType)):
return np.asarray(obj)
else:
diff -r 35cecc8a0a24bbf074956ef320f70e0e686478a7 -r b2896a72bf4e6be36e61024d901faac6c2b7564f yt/geometry/grid_geometry_handler.py
--- a/yt/geometry/grid_geometry_handler.py
+++ b/yt/geometry/grid_geometry_handler.py
@@ -241,6 +241,40 @@
ind = pts.find_points_in_tree()
return self.grids[ind], ind
+ def find_field_value_at_point(self, fields, coord):
+ r"""Find the value of fields at a coordinate.
+
+ Returns the values [field1, field2,...] of the fields at the given
+ (x, y, z) points. Returns a list of field values in the same order as
+ the input *fields*.
+
+ Parameters
+ ----------
+ fields : string or list of strings
+ The field(s) that will be returned.
+
+ coord : list or array of coordinates
+ The location for which field values will be returned.
+
+ Examples
+ --------
+ >>> pf.h.find_field_value_at_point(['Density', 'Temperature'],
+ [0.4, 0.3, 0.8])
+ [2.1489e-24, 1.23843e4]
+ """
+ this = self.find_points(*coord)[0][-1]
+ cellwidth = (this.RightEdge - this.LeftEdge) / this.ActiveDimensions
+ mark = np.zeros(3).astype('int')
+ # Find the index for the cell containing this point.
+ for dim in xrange(len(coord)):
+ mark[dim] = int((coord[dim] - this.LeftEdge[dim]) / cellwidth[dim])
+ out = []
+ fields = ensure_list(fields)
+ # Pull out the values and add it to the out list.
+ for field in fields:
+ out.append(this[field][mark[0], mark[1], mark[2]])
+ return out
+
def get_grid_tree(self) :
left_edge = self.pf.arr(np.zeros((self.num_grids, 3)),
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