<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 3, 2017 at 5:39 PM,  <span dir="ltr"><<a href="mailto:genghis17@comcast.net" target="_blank">genghis17@comcast.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
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.<br>
<br>
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.<br>
<br>
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:<br>
<br>
Traceback (most recent call last):<br>
  File "./doit.py", line 64, in <module><br>
    source.set_transfer_function(m<wbr>v)<br>
  File "/usr/lib64/python2.7/site-pac<wbr>kages/yt/visualization/volume_<wbr>rendering/render_source.py", line 311, in set_transfer_function<br>
    self.transfer_function = transfer_function<br>
  File "/usr/lib64/python2.7/site-pac<wbr>kages/yt/visualization/volume_<wbr>rendering/render_source.py", line 210, in transfer_function<br>
    "received object of type %s" % type(value))<br>
RuntimeError: transfer_function not a valid type, received object of type <class 'yt.visualization.volume_rende<wbr>ring.transfer_functions.MultiV<wbr>ariateTransferFunction'><br>
<br></blockquote><div><br></div><div>MultiVariateTransferFunction was written many years ago and was never properly documented or tested. A few years ago the volume rendering infrastructure was substantially refactored and the MultiVariateTransferFunction did not go along for the ride, mostly due to the poor state of the documentation and testing for it. I tried to port it a little bit ended up not having time to do the deep dive that was necessary to fully understand what it does.<br><br></div><div>In principle it should be possible to use a multi variate transfer function with the new volume rendering infrastructure but it will take someone willing to dive in and do some refactoring to re-enable support.<br><br></div><div>A first thing to do would be to add MultiVariateTransferFunction to the `valid_types` tuple a few lines above where the error you're seeing is getting issued.<br><br></div><div>If the documentation indicates that it's possible to use the MultiVariateTransferFunction we should probably remove those mentions until someone is able to re-enable that functionality.<br><br></div><div>If you're not willing to mess with the internals of the volume renderer then I'm afraid you're doing to need to stick with the other kinds of transfer functions in yt.<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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. </blockquote><div><br></div><div>I'm not sure there's a way to do what you're trying to do in the current version of yt, unfortunately. I suspect that the way forward is to re-enable the existing MultiVariateTransferFunction or rewrite it from scratch.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(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?)<br></blockquote><br></div><div class="gmail_quote">I agree about the field ids numbers not being particularly intuitive. Code contributions going in the direction of making that more intuitive would be very welcome.<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Does anyone know of a way to do this with yt?<br>
<br>
thanks,<br>
<br>
Dale<br>
<br>
______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
</blockquote></div><br></div></div>