Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integrate_data_along_axis filter #3852

Open
lverret opened this issue Jan 22, 2023 · 0 comments
Open

Add integrate_data_along_axis filter #3852

lverret opened this issue Jan 22, 2023 · 0 comments
Labels
feature-request Please add this cool feature!

Comments

@lverret
Copy link
Contributor

lverret commented Jan 22, 2023

Describe the feature you would like to be added.

The integrate_data filter was added in #2790 and aims to integrate a variable over a surface or a volume.

Oftentimes, we want to study the cumulative evolution of that integral over multiple slices of that surface or volume to see the contribution of each segment to this integral. I've attached a rough implementation and screenshots to better illustrate the idea.

I am thinking this could be added as a integrate_data_along_axis or plot_integrated_data_along_axis filter (which would show the matplotlib plot similar to plot_over_line).

I am not sure whether these filters would fit within the scope of PyVista or not, let me know.

Links to VTK Documentation, Examples, or Class Definitions.

No response

Pseudocode or Screenshots

import pyvista as pv
import numpy as np
from matplotlib.pyplot import cm
import matplotlib.pyplot as plt

ax_index = 0
ax_label = {0: "x", 1: "y", 2: "z"}[ax_index]
n = 20
l = []

output = pv.MultiBlock()
mesh = pv.Cone()
plotter = pv.Plotter()

rng = np.linspace(mesh.bounds[ax_index * 2] + 1e-8, mesh.bounds[ax_index * 2 + 1], n)
center = mesh.center
col = cm.rainbow(np.linspace(0, 1, n))

for i in range(n):
    center[ax_index] = rng[i]
    clipped, mesh = mesh.clip(normal=ax_label, origin=center, return_clipped=True)

    output.append(clipped)
    l.append(clipped.integrate_data()["Area"])
    plotter.add_mesh(clipped, color=col[i])
    
plotter.show_axes()
plotter.show()
plt.plot(np.cumsum(l))
plt.xlabel(ax_label)
plt.ylabel("Cumulative area integral")
plt.show()

image
image

@lverret lverret added the feature-request Please add this cool feature! label Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Please add this cool feature!
Projects
None yet
Development

No branches or pull requests

1 participant