3d data visualization

749 views
Skip to first unread message

louisalexan...@gmail.com

unread,
Feb 22, 2018, 12:35:24 PM2/22/18
to Dedalus Users
Hello Users,

Has anyone tried to use a 3d visualization software for their Dedalus data? Like visit?

I'm thinking about using Visit but I'm not sure whether Dedalus hdf5 output is readable?

This:
https://www.visitusers.org/index.php?title=VisIt_and_HDF5
says that some flavors of hdf5 are readable. Any idea which one Dedalus uses?

If not readable I guess I'll have to convert the hdf5 data to vtk format. But docs don't look friendly on how to install and bind vtk with python...

Any suggestion welcome!
Thanks
Louis

geoff

unread,
Feb 22, 2018, 5:17:52 PM2/22/18
to dedalu...@googlegroups.com, Eric Hester
Eric Hester has had some recent luck with Vapor. https://www.vapor.ucar.edu 

This is what Ben Brown and I used back in the day. We liked it quite a lot. But haven’t done any 3D viz for a lot time. I’m looking forward to seeing more come out of Dedalus! 

-Geoff

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To post to this group, send email to dedalu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/80d9b74f-afe7-4486-81b8-a6adbf9b999c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

louisalexan...@gmail.com

unread,
Feb 23, 2018, 3:37:55 AM2/23/18
to Dedalus Users
Hi Geoff,

Turns out I was able to get vtk to work with python.
I followed instructions here:
http://ghoshbishakh.github.io/blog/blogpost/2016/07/13/building-vtk-with-python3-wrappers.html

And adapted a script from here:
https://gist.github.com/jzrake/3784339
to convert Dedalus hdf5 data to vtk.

BUT, there is a simpler way (which of course I found after doing all the work...)! So discard what I said above and do the following:
1. Add the eVTK module to your python install. Instructions here:
https://bitbucket.org/pauloh/pyevtk

2. Then convert your numpy array to vtk readable files using evtk module. Some examples are given here:
https://www.vtk.org/Wiki/VTK/Writing_VTK_files_using_python

3. Enjoy visualizing your data in 3d using visit.

Hope this can help others!
Louis






Eric Hester

unread,
Mar 11, 2018, 4:30:34 AM3/11/18
to Dedalus Users
Hello Louis,

The vtk readable way sounds pretty useful -- I think I'll give that a go soon.

I'll also explain another way of doing things that I got to work.

I used vapor 2 for visualisation.

To do so, I needed to create uniformly spaced data in netCDF4 format.

I made a notebook that shows how to convert numpy arrays to netCDF4 format:

Then, you need two bash commands to create a header file for vapor, and then to process and filter the data into their format.

For the test data in the notebook, this first command creates the header:
    ncdfvdfcreate -dims 101x51x26 -vars temp -vars3d temp -numts 20 -timedims t -timevars t -extents -1:-1:0:1:1:1 data/test.nc test.vdf

Then, you process it with
    ncdf2vdf -vars temp -numts 20 -timedims t data/test.nc test.vdf

Then you have a dataset that you can play around with in the vaporgui.

Hope people find this useful!

Cheers,
Eric
make_data.ipynb
Message has been deleted

Julio

unread,
Sep 15, 2019, 3:19:51 PM9/15/19
to Dedalus Users
Hi,

does anyone tried the solution provided by Eric? after install vapor the ncdfvdfcreate command does not work :/

Best

Jeffrey S. Oishi

unread,
Sep 15, 2019, 3:41:26 PM9/15/19
to dedalus-users
Hi all,

I've been using paraview to good effect recently. One nice thing is that it can handle non uniform meshes with ease. I've written a little python script to take dedalus h5 output and write vtk input.  I've attached it here.

Jeff


--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
hdf2vtk.py

Julio

unread,
Sep 15, 2019, 3:46:49 PM9/15/19
to Dedalus Users
thank you Jeff!


On Sunday, September 15, 2019 at 3:41:26 PM UTC-4, Jeffrey S. Oishi wrote:
Hi all,

I've been using paraview to good effect recently. One nice thing is that it can handle non uniform meshes with ease. I've written a little python script to take dedalus h5 output and write vtk input.  I've attached it here.

Jeff


On Sun, Sep 15, 2019, 15:19 Julio <josefue...@gmail.com> wrote:
Hi,

does anyone tried the solution provided by Eric? after install vapor the ncdfvdfcreate command does not work :/

Best

On Thursday, February 22, 2018 at 12:35:24 PM UTC-5, louisalexa...@gmail.com wrote:
Hello Users,

Has anyone tried to use a 3d visualization software for their Dedalus data? Like visit?

I'm thinking about using Visit but I'm not sure whether Dedalus hdf5 output is readable?

This:
https://www.visitusers.org/index.php?title=VisIt_and_HDF5
says that some flavors of hdf5 are readable. Any idea which one Dedalus uses?

If not readable I guess I'll have to convert the hdf5 data to vtk format. But docs don't look friendly on how to install and bind vtk with python...

Any suggestion welcome!
Thanks
Louis

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalu...@googlegroups.com.

Julio

unread,
Sep 15, 2019, 4:49:51 PM9/15/19
to Dedalus Users
Hi Jeff,


I run your script by using python3 hdf2vtk.py --fields=comp --nt=-1 snapshots/snapshots_s45.h5 test.vtk

and I got this error

fields = ['comp']

outfile = test.vtk

Traceback (most recent call last):

  File "hdf2vtk.py", line 55, in <module>

    z = plot_tools.get_1d_vertices(datafile[scale_names[2]][:])

  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper

  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper

  File "/anaconda3/envs/dedalus/lib/python3.7/site-packages/h5py/_hl/group.py", line 262, in __getitem__

    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)

  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper

  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper

  File "h5py/h5o.pyx", line 190, in h5py.h5o.open

KeyError: "Unable to open object (object '1' doesn't exist)"


do you have any idea about what does it mean?

Thank you!

On Sunday, September 15, 2019 at 3:41:26 PM UTC-4, Jeffrey S. Oishi wrote:
Hi all,

I've been using paraview to good effect recently. One nice thing is that it can handle non uniform meshes with ease. I've written a little python script to take dedalus h5 output and write vtk input.  I've attached it here.

Jeff


On Sun, Sep 15, 2019, 15:19 Julio <josefue...@gmail.com> wrote:
Hi,

does anyone tried the solution provided by Eric? after install vapor the ncdfvdfcreate command does not work :/

Best

On Thursday, February 22, 2018 at 12:35:24 PM UTC-5, louisalexa...@gmail.com wrote:
Hello Users,

Has anyone tried to use a 3d visualization software for their Dedalus data? Like visit?

I'm thinking about using Visit but I'm not sure whether Dedalus hdf5 output is readable?

This:
https://www.visitusers.org/index.php?title=VisIt_and_HDF5
says that some flavors of hdf5 are readable. Any idea which one Dedalus uses?

If not readable I guess I'll have to convert the hdf5 data to vtk format. But docs don't look friendly on how to install and bind vtk with python...

Any suggestion welcome!
Thanks
Louis

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalu...@googlegroups.com.

Jeffrey S. Oishi

unread,
Sep 15, 2019, 4:57:56 PM9/15/19
to dedalus-users
Hi Julio,

It looks like I assumed that all of grids for each of your bases have the same scale. If that's not true for your datafile, you'll have to modify the code accordingly. I did this by getting the grid_scale just from the first basis (see line 51); if your z basis (really the last one, regardless of what you called it) doesn't have the same scale as x, it will crash just like this.

You can check that by opening the h5 file and printing

datafile['/scales/x'].keys()
datafile['/scales/z'].keys()

j

To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/7042f266-c836-46d3-85d0-83f378d53e62%40googlegroups.com.
Message has been deleted

Julio

unread,
Sep 16, 2019, 1:49:18 PM9/16/19
to Dedalus Users
I solved the problem by changing the line 51 to grid_scale = list(datafile[scale_names[0]].keys())[1], i.e., using the 1.0 scale :)

On Sunday, September 15, 2019 at 11:03:07 PM UTC-4, Julio wrote:
thank you jeff, I think you were right, after print the scales for x,y, and z I got

for x:  ['1', '1.0'], for y : ['1','1.0'] , for z = ['1.0'] 

is this related to the fact that I'm using a fourier basis for x and y, whereas for z I'm using a chebyshev? 

I don't know how to fix it, but I will see what can I do

Thank you!

Girish Nivarti

unread,
Feb 3, 2021, 4:46:44 AM2/3/21
to Dedalus Users
Thanks Jeff; I just found this script and clearly it still works! The only change I have had to make was declare scale_names as follows, instead of using a call to decode:

scale_names = [H5_SCALE_PATH+d for d in dim_labels]


Jeffrey S. Oishi

unread,
Feb 26, 2021, 3:31:40 PM2/26/21
to dedalus-users
Hi Girish,

Great, and thanks for pointing that out. It's due to a change in h5py. 

j

To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/d5cca876-6ae7-4c45-92cd-1893fbf8053en%40googlegroups.com.

Manohar Teja

unread,
Sep 2, 2022, 11:41:25 AM9/2/22
to Dedalus Users
Hi,

Thanks very much for the discussion and script. The code works perfectly, but I was wondering if there is a way to include time data too in the vtk file. I tried modifying the cell data line (line 59) as below cellData[f] = datafile[field_names[i]][:] to include time data but an error pops up while I try to create a vtk file:

fields = ['density']
outfile = rho.vtk

Traceback (most recent call last):
  File "/home/mk737/dedalus_v3/examples/ivp_2d_rti/hdf2vtk.py", line 61, in <module>
    gridToVTK(outfile, x, y, z, cellData = cellData)
  File "/home/mk737/miniconda3/envs/dedalus3/lib/python3.10/site-packages/pyevtk/hl.py", line 318, in gridToVTK
    _addDataToFile(w, cellData, pointData, fieldData)
  File "/home/mk737/miniconda3/envs/dedalus3/lib/python3.10/site-packages/pyevtk/hl.py", line 75, in _addDataToFile
    vtkFile.addData(key, data)
  File "/home/mk737/miniconda3/envs/dedalus3/lib/python3.10/site-packages/pyevtk/vtk.py", line 561, in addData
    assert False, "Bad array shape: " + str(data.shape)
AssertionError: Bad array shape: (50, 32, 32, 192)

So I understand that the VTK file is not accepting a 4D data but is there any other way to visualise the 3D data at different time instants?
I guess there should be one since the paraview has a box called "time" and i remember using it long time back.

Virginia TACPAK25

unread,
Sep 21, 2022, 3:07:50 PM9/21/22
to Dedalus Users
test did you get this feed back Leon?
Reply all
Reply to author
Forward
0 new messages