[Yt-svn] yt-commit r755 - trunk/yt/lagos
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Mon Sep 8 03:29:47 PDT 2008
Author: mturk
Date: Mon Sep 8 03:29:47 2008
New Revision: 755
URL: http://yt.spacepope.org/changeset/755
Log:
Closing #155 was easier than I thought...
Modified:
trunk/yt/lagos/HelperFunctions.py
Modified: trunk/yt/lagos/HelperFunctions.py
==============================================================================
--- trunk/yt/lagos/HelperFunctions.py (original)
+++ trunk/yt/lagos/HelperFunctions.py Mon Sep 8 03:29:47 2008
@@ -25,6 +25,7 @@
"""
from yt.lagos import *
+import Interpolators as IT
class UnilinearFieldInterpolator:
def __init__(self, table, boundaries, field_names):
@@ -77,6 +78,12 @@
x_i = na.minimum(na.maximum(x_i,0), len(self.x_bins)-2)
y_i = na.minimum(na.maximum(y_i,0), len(self.y_bins)-2)
+ my_vals = na.zeros(x_vals.shape, dtype='float')
+ IT.BilinearlyInterpolate(self.table,
+ x_vals, y_vals, self.x_bins, self.y_bins,
+ x_i, y_i, my_vals)
+ return my_vals
+
x = (x_vals - self.x_bins[x_i]) / (self.x_bins[x_i+1] - self.x_bins[x_i])
y = (y_vals - self.y_bins[y_i]) / (self.y_bins[y_i+1] - self.y_bins[y_i])
xm = (self.x_bins[x_i+1] - x_vals) / (self.x_bins[x_i+1] - self.x_bins[x_i])
@@ -119,6 +126,14 @@
y_i = na.minimum(na.maximum(y_i,0), len(self.y_bins)-2)
z_i = na.minimum(na.maximum(z_i,0), len(self.z_bins)-2)
+ my_vals = na.zeros(x_vals.shape, dtype='float')
+ print self.table.dtype, x_vals.dtype, self.x_bins.dtype
+ IT.TrilinearlyInterpolate(self.table,
+ x_vals, y_vals, z_vals,
+ self.x_bins, self.y_bins, self.z_bins,
+ x_i, y_i, z_i, my_vals)
+ return my_vals
+
# Use notation from Paul Bourke's page on interpolation
# http://local.wasp.uwa.edu.au/~pbourke/other/interpolation/
x = (x_vals - self.x_bins[x_i]) / (self.x_bins[x_i+1] - self.x_bins[x_i])
@@ -142,3 +157,16 @@
my_vals += self.table[x_i+1,y_i+1,z_i ] * (x *y *zm)
my_vals += self.table[x_i+1,y_i+1,z_i+1] * (x *y *z )
return my_vals.reshape(orig_shape)
+
+def get_centers(pf, filename, center_cols, radius_col, unit='1'):
+ """
+ Return an iterator over EnzoSphere objects generated from the appropriate
+ columns in *filename*. Optionally specify the *unit* radius is in.
+ """
+ sp_list = []
+ for line in open(filename):
+ if line.startswith("#"): continue
+ vals = line.split()
+ x,y,z = [float(vals[i]) for i in center_cols]
+ r = float(vals[radius_col])
+ yield pf.h.sphere([x,y,z], r/pf[unit])
More information about the yt-svn
mailing list