[yt-svn] commit/yt: MatthewTurk: Merged in ngoldbaum/yt (pull request #1149)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Aug 18 14:34:05 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/2f242116a579/
Changeset: 2f242116a579
Branch: yt
User: MatthewTurk
Date: 2014-08-18 23:33:56
Summary: Merged in ngoldbaum/yt (pull request #1149)
Fixing issues with TransferFunctions that are not log-scaled. Closes #880
Affected #: 3 files
diff -r 5c847041a74e8cd353617cc29da89048c62145ce -r 2f242116a579754330a95c7200eaa4dd7360a7e3 doc/source/visualizing/TransferFunctionHelper_Tutorial.ipynb
--- a/doc/source/visualizing/TransferFunctionHelper_Tutorial.ipynb
+++ b/doc/source/visualizing/TransferFunctionHelper_Tutorial.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:f3e6416e4807e008a016ad8c7dfc8e78cab0d7519498458660554a4c88549c23"
+ "signature": "sha256:5a1547973517987ff047f1b2405277a0e98392e8fd5ffe04521cb2dc372d32d3"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -83,7 +83,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "# Build a transfer function that is a multivariate gaussian in Density\n",
+ "# Build a transfer function that is a multivariate gaussian in temperature\n",
"tfh = yt.TransferFunctionHelper(ds)\n",
"tfh.set_field('temperature')\n",
"tfh.set_log(True)\n",
@@ -180,4 +180,4 @@
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r 5c847041a74e8cd353617cc29da89048c62145ce -r 2f242116a579754330a95c7200eaa4dd7360a7e3 yt/visualization/volume_rendering/transfer_function_helper.py
--- a/yt/visualization/volume_rendering/transfer_function_helper.py
+++ b/yt/visualization/volume_rendering/transfer_function_helper.py
@@ -154,7 +154,9 @@
xmi, xma = np.log10(self.bounds[0]), np.log10(self.bounds[1])
else:
xfunc = np.linspace
- xmi, xma = self.bounds
+ # Need to strip units off of the bounds to avoid a recursion error
+ # in matplotlib 1.3.1
+ xmi, xma = [np.float64(b) for b in self.bounds]
x = xfunc(xmi, xma, tf.nbins)
y = tf.funcs[3].y
@@ -166,7 +168,7 @@
canvas = FigureCanvasAgg(fig)
ax = fig.add_axes([0.2, 0.2, 0.75, 0.75])
ax.bar(x, tf.funcs[3].y, w, edgecolor=[0.0, 0.0, 0.0, 0.0],
- log=True, color=colors, bottom=[0])
+ log=self.log, color=colors, bottom=[0])
if profile_field is not None:
try:
@@ -177,10 +179,12 @@
if profile_field not in prof.keys():
prof.add_fields([profile_field], fractional=False,
weight=profile_weight)
- ax.plot(prof[self.field], prof[profile_field]*tf.funcs[3].y.max() /
- prof[profile_field].max(), color='w', linewidth=3)
- ax.plot(prof[self.field], prof[profile_field]*tf.funcs[3].y.max() /
- prof[profile_field].max(), color='k')
+ # Strip units, if any, for matplotlib 1.3.1
+ xplot = np.array(prof[self.field])
+ yplot = np.array(prof[profile_field]*tf.funcs[3].y.max() /
+ prof[profile_field].max())
+ ax.plot(xplot, yplot, color='w', linewidth=3)
+ ax.plot(xplot, yplot, color='k')
ax.set_xscale({True: 'log', False: 'linear'}[self.log])
ax.set_xlim(x.min(), x.max())
@@ -200,7 +204,7 @@
def setup_profile(self, profile_field=None, profile_weight=None):
if profile_field is None:
- profile_field = 'CellVolume'
+ profile_field = 'cell_volume'
prof = BinnedProfile1D(self.ds.all_data(), 128, self.field,
self.bounds[0], self.bounds[1],
log_space=self.log,
diff -r 5c847041a74e8cd353617cc29da89048c62145ce -r 2f242116a579754330a95c7200eaa4dd7360a7e3 yt/visualization/volume_rendering/transfer_functions.py
--- a/yt/visualization/volume_rendering/transfer_functions.py
+++ b/yt/visualization/volume_rendering/transfer_functions.py
@@ -48,6 +48,8 @@
def __init__(self, x_bounds, nbins=256):
self.pass_through = 0
self.nbins = nbins
+ # Strip units off of x_bounds, if any
+ x_bounds = [np.float64(xb) for xb in x_bounds]
self.x_bounds = x_bounds
self.x = np.linspace(x_bounds[0], x_bounds[1], nbins).astype('float64')
self.y = np.zeros(nbins, dtype='float64')
@@ -353,6 +355,8 @@
"""
def __init__(self, x_bounds, nbins=256, grey_opacity = False):
MultiVariateTransferFunction.__init__(self)
+ # Strip units off of x_bounds, if any
+ x_bounds = [np.float64(xb) for xb in x_bounds]
self.x_bounds = x_bounds
self.nbins = nbins
# This is all compatibility and convenience.
@@ -633,6 +637,7 @@
>>> tf = ColorTransferFunction( (-10.0, -5.0) )
>>> tf.sample_colormap(-7.0, 0.01, colormap='algae')
"""
+ v = np.float64(v)
if col_bounds is None:
rel = (v - self.x_bounds[0])/(self.x_bounds[1] - self.x_bounds[0])
else:
@@ -680,7 +685,8 @@
>>> tf.map_to_colormap(-6.0, -5.0, scale=10.0, colormap='algae',
... scale_func = linramp)
"""
-
+ mi = np.float64(mi)
+ ma = np.float64(ma)
rel0 = int(self.nbins*(mi - self.x_bounds[0])/(self.x_bounds[1] -
self.x_bounds[0]))
rel1 = int(self.nbins*(ma - self.x_bounds[0])/(self.x_bounds[1] -
@@ -800,6 +806,8 @@
if n_fields > 3:
raise NotImplementedError
MultiVariateTransferFunction.__init__(self)
+ # Strip units off of x_bounds, if any
+ x_bounds = [np.float64(xb) for xb in x_bounds]
self.x_bounds = x_bounds
self.nbins = 2
self.linear_mapping = TransferFunction(x_bounds, 2)
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