3D interpolation and plotting into a volume/isosurface on python - python

I'm looking for a way to interpolate 2D fields that are arranged on a list, making the shape data = [11,2016,2016]
Up to the moment I've managed to stack the 2D plots over the Z axis and create an interactive plot, but i want to create a plot of the volume and thought that an interpolation through the 11 steps would work, I'd like to get only one 2D array at the end to plot.
Any suggestions about how to perform this? can I make it on one single operation or am I obliged to perform step by step interpolations between each step?
edit: a picture showing the image that i'm able to generate now and can maybe explain better my problem.

Related

Slicing a multidimensional numpy array -> 3D point clusters at different time instances

I have a numpy-array, who's shape is:
(30,40,100,200)
Those are 3D points (30(x-axis)x40(y-axis)x100(z-axis)) for different times (200 in total):
For visualization only (this is not my dataset, the picture comes from here: http://15462.courses.cs.cmu.edu/fall2016/article/35)
Now, I have issues with understanding how I can slice it:
How do I extract a 3D cluster for one specific time, i.e. 140?
From that extracted 3D cluster, how can I plot a 2D x-z cross-section for a specific y-position, i.e.45?
You should read up on basic numpy slicing: https://numpy.org/doc/stable/reference/arrays.indexing.html
How do I extract a 3D cluster for one specific time, i.e. 140?
Just specify the time index, i.e. data[:, :, :, 140]. Be aware that Python indexing starts from 0.
From that extracted 3D cluster, how can I plot a 2D x-z cross-section for a specific y-position, i.e.45?
You can acquire a 2D cross-section by a similar slicing operation, i.e. cluster[:, 45, :]. It can be plotted in various ways depending on the plotting library. imshow() from matplotlib might be one possibility.
Is your question about the data set (how does data categorize and how to get a 3D cluster at a specific time), or about the coding?
If it is about "How to get a cluster at a specific time" it means that your problem is about your particular dataset, which Stackoverflow is not a correct place for these types of question.
If it is about "coding" then define clearly your question and provide us with your code and the problem with it.
Based on your explanation, I think that for each time step, you have a complete set of xyz data, and so the solution is very strait.

3D plot of 2D pandas data frame - z-axis limits, interactivity

I Posted this question about 3D plots of data frames:
3D plot of 2d Pandas data frame
and the user referred me very very helfully to this:
Plotting Pandas Crosstab Dataframe into 3D bar chart
It use useful and the code worked in principle, but it lookes like a mess (see image below) for several reasons:
I have huge number of values to plot (470 or so, along the y-axis) so perhaps a bar chart is not the best way (I am going for a histogram kind of look, so I assumed very narrow bars would be suitable)
my counts (z axis) do not give almost any information, because the differences I need to see are from 100 to the max value
how can I make the 3D plot that shows up interactive? (being able to rotate etc) - I have seen it done in blogs/videos but sure if it's something on Tools -> Preferences that I can't find
So re: the second issue, simple enough, I tried to just change the limits of the zbar as I would for a 2D Plot, by incorporating:
ax.set_zlim([110,150])
just before the axis labels, but obviously this is the wrong way:
SO do I have to limit the values from the original data set (i.e. filter out <110), or is there a way to do this from the plot?

slicing volume rendering graph in python

I have an input data with each row having (x,y,z,data), i.e., each coordinate (x,y,z) has a value "data". I would like to make a slicing volumetric graph like below in python. I am new to python, any tips would be much appreciated. see here for the example graph
If you have your data organized as a 2D array (n-points x 4) [x,y,z,data] (this can also be refered to as a point-cloud representations) and you want to display it as a volume rendering. You have to first resample it as a 3D array (interpolate 3D volume with numpy and or scipy) and then create an isosurface using marching cubes (How to display a 3D plot of a 3D array isosurface in matplotlib mplot3D or similar?)
You can also plot the values using a 3D scatter plot which is much easier, but won't get you the kind of plot you asked for (https://matplotlib.org/examples/mplot3d/scatter3d_demo.html)

Maplotlib 3d imshow

I have a 3d array of data of which I am trying to do a visualization. The entries of the 3d array can only take boolean value. I would like to visualize it in way imshow offers to visualize a matrix by giving a color value to each entry. Here it is in 3d so I guess we should add some empty space between the points to see the inside.
I have looked into matplotlib 3d plots but I could not find the right tool for such visualization. What could I use?

Using Mayavi and Mlab to plot "bubbles"

Currently, I am attempting to plot some "bubble" like shapes in a 3D space using Mayavi/Mlab. These bubbles are represented by a numpy array of shape (840,1100,30) where the parameters represent (x,y,z) and the value at any x,y,z is either 1 or 0. The array can be thought of as a collection of Voxels that are either on or off. I try to plot this data with the following commands:
mlab.contour3d(finalVolume)
mlab.show()
But the plot is coming out in 2 dimensions instead of in 3 dimensions. I have looked at the documentation but am having trouble understanding. If anyone could provide some help or a push in the right direction, then I would be very appreciative!
Thanks!
Sounds like you need to use volume rendering to accomplish this. This can be accomplished using:
mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=0, vmax=0.8)
You will need to adjust the opacity transfer function using vmin and vmax to make an appropriate image. Examples on volume rendering can be found at: http://docs.enthought.com/mayavi/mayavi/mlab.html

Categories

Resources