Sister blog of Physicists of the Caribbean. Shorter, more focused posts specialising in astronomy and data visualisation.

Thursday 24 October 2019

Isosurfaces for fun and profit

The best way to look at at 3D volumetric data is, in my opinion, in its original 3D volumetric form. To this end I've spent several years years developing the 11,000 lines of Python code that is FRELLED (albeit all of which is just a script to load astronomical FITS files in Blender, which is what does the hard work). I've always been a bit skeptical of other ways of visualising the data... 2D slices are fine, and often necessary, but things like isosurfaces seem to me to be throwing away a lot of really pretty* information.

* I don't much care if it's meaningful or not.

To be fair, FRELLED does already include the ability to display renzograms, which are essentially contours of each slice of the data. While it's true that viewing the data at a fixed level, reducing it from a full volume to a thin surface, does remove a lot of information, I've been realising that by cutting away a lot of the noise it can actually become a lot easier to see interesting features. With the full volume, sometimes the noise just gets in the way. Using the renzogram facility of FRELLED, we've found a bunch of hydrogen streams in the Virgo cluster we'd just never noticed before (paper submitted).

So renzograms are super useful. But while 3D renzograms are sort-of isosurfaces, they're not proper 3D fits to the data. That's harder to do in Blender - I tried to get this a while back, and it sort of worked but it was very, very hacky. That method used someone's old Python script that skins a point cloud of vertices. It works well in some situations but not in others - a lot of manual cleaning is needed on complex data sets, and that's not much fun. The experience is a bit like using a half-broken toaster : you're never quite sure if you're going to have a nice breakfast or burn your house down.

But now I've found that the Python scikit-image module includes a "marching cubes" algorithm that generates proper isosurfaces. Fast, effective, and no mucking about with cleaning up artifacts at all. I've quickly hacked this into Blender, using another module to convert the vertex data generated into a Blender-readable format. The basic code is just a few lines long and it works without complaint.

So, time for some examples ! This first one is a bog-standard Virgo cluster galaxy with no interesting features whatsoever - it's just a long, cigar-like blob, with the long axis being velocity. Colours indicate brightness of the emisssion (purple, blue, green, yellow and red going from bright to faint).


For a second example, here's another Virgo galaxy which does seem to have a distinct protuberence on one side. It's probably losing gas as it moves through the cluster.


And then there are oddballs like this one, which seem to have a distinctly noisy appearance and a "tail" in velocity space :


Just to prove how incredibly easy this is, here's the whole data set of 102 galaxies. Even in this zoomed-out view, you can see that most galaxies are quite smooth and symmetrical, but some have pretty clear extensions and other weirdness (after a laborious statistical analysis we're highly confident these are real and not just due to variations in the noise).




You may be thinking that that's all very nice, but what about some nice resolved high resolution data ? No problem, here's one of my favourites - the M33 galaxy and its many associated clouds :



The M33 system is so complicated that I cheated a bit with the contours on that one. In all other cases, the same colour is used for identical brightness levels, but in the case of M33 I set the levels manually for each cloud - otherwise you start being totally dominated by noise in some cases, while not seeing anything at all in others.

Finally, here's an isosurface of Medusa a simulated galaxy undergoing strong ram pressure stripping. No noise to worry about at all for simulations.


All this is part of a larger effort to recode FRELLED in modern Blender. FRELLED currently relies on Blender 2.49, which is more than 10 years old. Blender 2.8 has a lot more features and comes with its own Python and Pip install, making it waaay easier to install the necessary modules. Perhaps that will help catapult FRELLED from obscurity to total domination of the astronomical community having more than a dozen users. That'd be nice.

No comments:

Post a Comment

Back from the grave ?

I'd thought that the controversy over NGC 1052-DF2 and DF4 was at least partly settled by now, but this paper would have you believe ot...