[yt-users] use of MultivariateTransferFunction
genghis17 at comcast.net
genghis17 at comcast.net
Sun Dec 3 15:39:57 PST 2017
Hello,
I am trying to render some density data using a transfer function which
depends on both the density and the density_gradient_magnitude field.
From my study of the docs it seems that this can be done using the
MultivariateTransferFunction class, but the few examples given do not
make it clear.
What I want to do is render the density using, say, the 'hsv' colormap.
The bounds for the density will be 1e-6 to 1e0. However, if the
*gradient* of the density at a given grid point is outside the range of,
say, 1e-5 to 1e-2, then I don't want that datum to be visible in the
plot. The point of this is to highlight features in the density that
are only recognizable when considering how the density changes from
place to place.
It is not clear to me whether this kind of rendering can be done with
yt, but in any case the immediate problem I'm having is that
source.set_transfer_function() does not accept an instance of
MultiVariateTransferFunction as an argument. I get an error about an
incorrect data type:
Traceback (most recent call last):
File "./doit.py", line 64, in <module>
source.set_transfer_function(mv)
File
"/usr/lib64/python2.7/site-packages/yt/visualization/volume_rendering/render_source.py",
line 311, in set_transfer_function
self.transfer_function = transfer_function
File
"/usr/lib64/python2.7/site-packages/yt/visualization/volume_rendering/render_source.py",
line 210, in transfer_function
"received object of type %s" % type(value))
RuntimeError: transfer_function not a valid type, received object of
type <class
'yt.visualization.volume_rendering.transfer_functions.MultiVariateTransferFunction'>
I can avoid this error using either TransferFunction() or
ColorMapTransferFunction(), but then I can't query two fields of data to
do the rendering, as far as I know. (It would be easier to set up
transfer functions if fields could simply be referred to by name instead
of by field_id. How does one figure out the field_id for an arbitrary
field that one has added to a dataset? Is the density field always 0
and then any added fields are enumerated in the order in which they are
added?)
Does anyone know of a way to do this with yt?
thanks,
Dale
More information about the yt-users
mailing list