Ocean Modeling Discussion


Search for:
It is currently Sat Sep 21, 2019 9:22 am

Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Author Message
PostPosted: Fri Apr 26, 2019 7:04 pm 

Joined: Sun Jul 27, 2003 6:49 pm
Posts: 86
Location: UNH, USA
Dear all --

I hope someone finds this usefull. I wanted to plot some iso-surfaces in 3D with ROMS data without re-gridding it to a rectangular grid or some such silliness. There are many heavy-weight environments that can do all sorts of cool things like that (paraview, vapor, yt) -- but getting them to ingest the data is non-obvious, and they require a whole new tool chain. Peh.

I realized there was an easy way to do it. Scikit-images has an algorithm to produce a triangular mesh of an isosurface from a cubic data array. It is trivial to run this code on a slab of ROMS data and take the output of this code in (i,j,k) space and remap it to (x,y,z) space, and then you have the faces of an iso-surface that is easy to display.

In the attached code, I provide a python routine to do so, and example code to visualize the output in the python visvis package. The output, a series of triangles representing the isosurface, can also be easily visualized in MayaVI2 or many other packages. Once you have the mesh for the iso-surface, almost any 3d visualization package can display it! Details on how to do so are discussed in the code.

This code should be able to make iso-surfaces from any model whose underlying structure is rectangular grids.

If you import the package, it provides the routine "makeMesh()" which does the heavy lifting. If you run the package, it will either plot a sphere:

Or a temperature iso-surface from a ROMS run (you will, of course, have to provide the ROMS data, and have a code to generate the 3D array of depths for each data point. I use pyroms, but any such tool will do).

One thing to keep in mind in plotting oceanographic code is that it has extreme aspect ratios. Please read the example code carefully to see how to manage this -- otherwise your plot will look like a sheet of paper viewed edge on (because that is what the ocean looks like, in truth...).


File comment: The python source.
makeIsoSurfaceMesh.py [8.31 KiB]
Downloaded 55 times
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group