[yt-users] Volume rendering

Nathan Goldbaum nathan12343 at gmail.com
Mon Dec 4 10:49:40 PST 2017


On Tue, Nov 28, 2017 at 3:36 AM, Андрей Парамонов <paramon at acdlabs.ru>
wrote:

> Hello!
>
> I've recently discovered yt, and I found the rendering examples really
> encouraging. I'm now trying to visualize a large 3D dataset via volume
> rendering technique. I have come up with the following script that is
> intended to plot a part of the dataset:
>
> ---
>
> import yt
> from yt.config import ytcfg
>
> import h5py
>
> f = h5py.File('ims-p.hdf5')
> intens = f['intensity'][:256,:256,:256]
> print(intens.shape)
> ds = yt.load_uniform_grid({'Intensity': intens}, intens.shape)
> print(ds)
> sc = yt.create_scene(ds, ('Intensity'), lens_type = 'perspective')
> sc[0].set_log(True)
> sc[0].tfh.plot('transfer_function.png', profile_field = 'Intensity')
> sc.camera.resolution = 1024
>
> sc.annotate_axes(alpha = 0.1)
> sc.annotate_domain(ds, color = [1, 1, 1, 0.1])
> sc.save_annotated('vr_grids.png', sigma_clip = 4)
>
> ---
>
> I get some really fascinating rendering (attached), and now I want to
> tweak it. I would be really happy if you could help me with the following
> questions:
>
> 1) What is the best way to configure the camera viewpoint so the complete
> data cube fits into the view?


Choose a Camera position that lies well outside the volume.


> How to quickly render the domain axes without performing the costly volume
> rendering (to find the "optimal" viewpoint experimentally)?
>

You could try creating the volume rendering scene manually:

from yt.visualization.volume_rendering.api import Scene

sc = Scene()
sc.add_camera(data_source=ds.all_data(), lens_type='perspective')
sc.annotate_domain(ds)



>
> 2) What is the best way to specify axes scales, so that rendered volume
> appears as cuboid, not cube? I want the resulting cuboid to be scaled as
> 3:2:2. How to specify resulting image size, e.g. how to get image of
> 1600x1200 pixels?
>

If your data are natively cubic there isn't a way right now to skew the
data along one of the axes. If your data are natively elongated along one
axis then you shouldn't have to do anything special.

The camera's resolution can be a tuple:

In [9]: sc.camera.resolution
Out[9]: (512, 512)

In [10]: sc.camera.resolution = (1600, 1200)

In [11]: sc.camera.resolution
Out[11]: (1600, 1200)


> 3) In my dataset, the grid is not in fact uniform, but rather X
> coordinates are specified by (non-decreasing) array rettime, Y coordinates
> are specified by (non-decreasing) array mz. What is the best way to pass
> this information (to load_uniform_grid)?
>

Right now this isn't supported. We do have support for nonuniformly spaced
grids (we call this a semi structured mesh) but don't have support for
volume rendering semi structured meshes using yt's AMR volume renderer,
which only supports regularly spaced grids.


>
> 4) Is it possible to use inverse transfer function model, i.e. white
> background?
>

It should be but there's a bug that prevents that from working right now:

https://github.com/yt-project/yt/issues/1579

I've been meaning to dive in and try to figure out why this isn't working
anymore. Unfortunately the bug was introduced during a large refactoring of
the volume rendering code that hapenned several years ago so it's tricky to
figure out the exact cause.


>
> 5) My complete dataset is rather large and doesn't readily fit into RAM.
> However it seems that for ray-tracing algorithm, it shouldn't be required
> that all data is available simultaneously. Is it possible to feed dataset
> by chunks?
>

Right now the AMR KDTree data structure that is used by the volume renderer
needs to keep a copy of the data in memory. If you have access to a
cluster, that memory can be shared among compute nodes using MPI-based
parallelism. There isn't a way to read the data in in a chunked fashion.


>
> Your help is greatly appreciated!
>

Apologies to not have easy answers for many of your questions.


>
> Best wishes,
> Andrey Paramonov
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20171204/6cc7adaa/attachment-0002.html>


More information about the yt-users mailing list