Open TomNicholas opened 4 years ago
Very neat! That looks really useful. There is also some interface to VisIT, though it's a bit clunky. The pain with 3D plotting really comes in tokamak field-aligned geometry, because the data has to be interpolated so that the plotting follows the curved field-lines. This is especially noticeable in STs near the centre-column. There is some code lying around somewhere to do this for Mayavi inputs, but I'm not sure where it is now.
Looks class Tom. Regarding tokamak geometries I think @friva000 has done a fair few 3D realistic plots of MAST, albeit in MATLAB if I remember correctly. Though he may have some techniques that could be replicated in xBOUT?
Fabio did a 3D plot in python using mayavi which I've stored here, including his code.
Ideally someone would write a 3D plotting accessor for xbout
which first does the field-aligned interpolation, then plots using whichever of mayavi and K3D-jupyter turns out to be better.
(It's unlikely I will have time to do that though)
I've started working on some plotting using K3D-jupyter... Watch this space! (also get #107 and #108 merged :wink: )
A couple of previews with TORPEX simulation data...
Unfortunately, github won't let me put the interactive html version in these comments!
oh cooooooool!
Have you tried doing isosurface plots? Should be able to see full 3D filaments then.
Unfortunately, github won't let me put the interactive html version in these comments!
(I used this excellent tool to quickly screengrab the gifs of me messing with the 3D plots.)
Haven't had a chance to dig into any more features yet! I found one example that let me replicate Fabio's mayavi implementation for the top fig, and then the second one was just a different choice of surfaces... Isosurfaces and animations are definitely on the wishlist. My main motivation for wanting to fix #115 is that it'd be nice to be able to slice in x or y, (not just in z) to put surfaces in interesting bits of the turbulence.
Tom found another potentially interesting 3d visualisation library: https://blog.jupyter.org/ipygany-jupyter-into-the-third-dimension-29a97597fc33?gi=65070678f5e5
In case anyone ever gets a chance to pick this up, the branch that I was working on is here https://github.com/boutproject/xBOUT/tree/plot3d. The 3d plotting stuff is in new functions, so I hope would be relatively straightforward to merge, although likely needs a few updates for compatibility with the changes to master
since I was working on it...
Another recent option for 3D plotting is pyvista, which like Mayavi wraps VTK tools, but unlike Mayavi someone made a neat xarray accessor for pyvista so you can get 3D plots in just one line!
An alternative approach has been developed here: https://github.com/DomLonghorn/SciViPy/blob/main/SciViPy/bout_cartesian_convert.py
It would be sweet to be able to make 3D plots of BOUT data. Unfortunately matplotlib3D is not great, and mayavi is a bit outdated (not sure if it's still actively developed?).
But I recently found this library, which runs in a jupyter notebook and uses WebGL as the plotting backend so it's really fast. The examples are insanely cool and the one of a chest cavity in particular is worth a look.
Here's me using K3D-jupyter to plot some filaments from a 3D slab turbulence simulation in like 3 lines of code (after preloading the values DataArray using xbout):
@johnomotani