<div><br><div class="gmail_quote"><div>On Wed, May 17, 2017 at 5:29 AM Matej Tyc <<a href="mailto:matej.tyc@gmail.com">matej.tyc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<p>On 15.5.2017 21:26, Nathan Goldbaum wrote:<br>
</p>
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">On Mon, May 15, 2017 at 2:12 PM,
Matěj Týč <span><<a href="mailto:matej.tyc@gmail.com" target="_blank">matej.tyc@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello guys,<br>
</blockquote>
<div><br>
</div>
<div>we're not all guys :)</div>
</div>
</div>
</div>
</blockquote></div><div text="#000000" bgcolor="#FFFFFF">
Actually, guys includes everybody:<br>
<a class="m_7423083210683240003moz-txt-link-freetext" href="https://en.wiktionary.org/wiki/guys" target="_blank">https://en.wiktionary.org/wiki/guys</a> </div></blockquote><div><br></div><div>I've had several women tell me that using gendered language like that makes them feel uncomfortable participating in discussions. That's why I pointed it out, I want to make sure everyone feels comfortable.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><br></div><div text="#000000" bgcolor="#FFFFFF">
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
our research group would like to visualize volume data,
where the<br>
transfer function is bivariate (see<br>
<a href="http://lists.spacepope.org/pipermail/yt-users-spacepope.org/2017-April/008552.html" rel="noreferrer" target="_blank">http://lists.spacepope.org/pipermail/yt-users-spacepope.org/2017-April/008552.html</a><br>
). We have been struggling with this task, so I would like
you to help<br>
me understand some of the basic concepts I have come
across and that I<br>
find confusing.<br>
<br>
1. I think that I somehow understand the concept of
transfer functions<br>
with multiple fields, but I have difficulties of creating
a volume<br>
source with multiple fields. I have somehow examined the
source code,<br>
and it seems to me that only the first field is used
(judging by<br>
<a href="https://github.com/yt-project/yt/blob/master/yt/visualization/volume_rendering/render_source.py#L516" rel="noreferrer" target="_blank">https://github.com/yt-project/yt/blob/master/yt/visualization/volume_rendering/render_source.py#L516</a><br>
). </blockquote>
<div><br>
</div>
<div>The class you linked to here is for rendering
unstructured mesh data. Is that what you're trying to do?
If so then the advice for how to proceed is very different
than if you are rendering gridded data.</div>
</div>
</div>
</div>
</blockquote></div><div text="#000000" bgcolor="#FFFFFF">
It is great that you have pointed this out. I think that we have
gridded data (i.e. a numpy array that corresponds to sampled data).
What does it mean that render_source is not involved? </div></blockquote><div><br></div><div>You will be using a VolumeSource in that case, not a MeshSource. There will still be a source to be rendered though.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">Would be the
following snippet OK if I implement the MyCustomTF correctly?<br>
<br>
import scipy as sp<br>
import yt<br>
import yt.visualization.volume_rendering.api as vr_api<br>
<br>
trans = sp.rand(20, 40, 40)<br>
color = sp.rand(20, 40, 40)<br>
<br>
ds = yt.load_uniform_grid(dict(color=color, trans=trans),<br>
color.shape)<br>
<br>
scene = vr_api.Scene()<br>
<br>
source = vr_api.VolumeSource(ds.all_data(), ["color", "trans"])<br>
source.log_field = False<br>
source.transfer_function = MyCustomTF(...)<br>
scene.add_source(source)<br>
<br>
scene.add_camera()<br>
scene.save('render.png')</div></blockquote><div><br></div><div>In principle yes.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"></div><div text="#000000" bgcolor="#FFFFFF"><br>
<br>
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>You are right that each source only renders a single
field. If you want to render more than one field you will
need to create multiple sources.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If I am wrong and it is
meaningful and possible to construct a source<br>
with multiple fields, could you please provide an example?<br>
</blockquote>
<div><br>
</div>
<div>Here's an example:</div>
<div><br>
</div>
<div><a href="https://github.com/yt-project/yt/blob/master/doc/source/cookbook/render_two_fields.py" target="_blank">https://github.com/yt-project/yt/blob/master/doc/source/cookbook/render_two_fields.py</a><br>
</div>
<div><br>
</div>
<div>That said, this is simply compositing two separate
volume renderings together. A bivariate transfer function
is a bit more complex than this.</div>
</div>
</div>
</div>
</blockquote></div><div text="#000000" bgcolor="#FFFFFF">
Transfer function is a property of a volume source, isn't it? So if
one source means one field, then how can a transfer function access
multiple fields? At least PlanckTransferFunction uses multiple
fields.</div></blockquote><div><br></div><div>Good point. You may need to relax that assumption.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"></div><div text="#000000" bgcolor="#FFFFFF"><br>
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. I have no doubts that transfer functions work, but I
was unable to<br>
find out how are they involved in the integration process.
What I came<br>
across were the integration routines and they have
mentioned that the<br>
transfer function is not used:<br>
<a href="https://github.com/yt-project/yt/blob/master/yt/utilities/lib/ray_integrators.pyx#L235" rel="noreferrer" target="_blank">https://github.com/yt-project/yt/blob/master/yt/utilities/lib/ray_integrators.pyx#L235</a><br>
. This is really interesting, how is it in reality?<br>
</blockquote>
<div><br>
</div>
<div>I believe the low-level routine you want to look at in
is yt/utlities/lib/image_samplers.pyx, in particular the
VolumeRenderSampler. The PlaneVoxelIntegration class you
linked to here is experimental code that is not used
elsewhere in yt.</div>
</div>
</div>
</div>
</blockquote></div><div text="#000000" bgcolor="#FFFFFF">
okay, I am happy about this as the code was extremely hard to read.
This one is somehow easier, although the code still doesn't reveal
much intent and names of variables are difficult to understand for
an outsider. Anyway, I will proceed and if I manage to understand
it, I may be able to come up with some proposals.</div></blockquote><div><br></div><div>Feel free to ask questions as you have them.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"></div><div text="#000000" bgcolor="#FFFFFF"><br>
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
3. You have mentioned the PlanckTransferFunction as a good
example of<br>
multivariate transfer function.<br>
However, doing a Google search, hoping that we will find a
code snippet<br>
featuring a non-trivial example did not yield any results.
Would you be<br>
so kind and provide one?<br>
</blockquote>
<div><br>
</div>
<div>There is no easy example I'm aware of. Making it easier
to do the sorts of bivariate volume renderings you're
trying to do is a longstanding issue. I'm not aware of
anyone successfully using the machinery in yt for doing
volume renderings with transfer functions that depend on
multiple fields since John Wise added the code for the
PlanckTransferFunction several years ago. That code was
not added with any documentation or tests so unfortunately
it may have bitrot since it was added. Also, in the
meantime the volume rendering machinery in yt has
undergone substantial reworking so it's possible that
things are just simply broken right now. </div>
<div><br>
</div>
<div>We would welcome contributions that make it easier to
do the sorts of volume renderings you are trying to do.
I'm sorry that it's not straightforward to do that right
now.</div>
</div>
</div>
</div>
</blockquote></div><div text="#000000" bgcolor="#FFFFFF">
As soon as I get this working, I will be happy to submit a PR.<br>
<br>
</div>
_______________________________________________<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/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div></div>