enthought / enthought/mayavi

mesh cannot be animated, but surf can

Open
#998 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

When using p = mlab.mesh(x, y, prob_2d), just the colormap is animated, but when using surf the gauss package is moving (like expected)

`
import numpy as np
import time

from mayavi import mlab

def psi_gauss_2d(x, y, a=1.0, x_0=0.0, y_0=0.0, k_0=0.0):
return ((a * np.sqrt(np.pi)) ** (-0.5) * np.exp(-0.5 * (((x - x_0) * 1.0) ** 2
+ ((y - y_0) * 1.0) ** 2) / (a ** 2) + 1j * x * k_0))

fig = mlab.figure()

L = 5
x, y = np.mgrid[-L:L:100j, -L:L:100j]
prob_2d = np.abs(psi_gauss_2d(x, y)) ** 2
p = mlab.mesh(x, y, prob_2d)

for i in range(0, 10, 1):
sc = 1.1 ** i * np.abs(psi_gauss_2d(x, y, x_0=0.5 * i)) ** 2
p.mlab_source.trait_set(scalars=sc)
mlab.savefig("anim_%02d.png" % i)
time.sleep(0.05)
`

mesh:
![anim_00](https://user-images.githubusercontent.com/43704364/103345058-a5107f80-4a90-11eb-9310-58280a5af04e.png)
![anim_07](https://user-images.githubusercontent.com/43704364/103345064-a93c9d00-4a90-11eb-8f01-cbdec956b396.png)

surf:
![anim_07](https://user-images.githubusercontent.com/43704364/103345295-51eafc80-4a91-11eb-93aa-ba9c2ef4e45d.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.