pyvista.examples.downloads.download_single_sphere_animation

pyvista.examples.downloads.download_single_sphere_animation#

download_single_sphere_animation(load=True)[ソース]#

球体1個分のPVDファイルをダウンロードします.

パラメータ:
loadbool, default: True

True に設定すると,データセットをダウンロードした後に読み込みます. False に設定すると,ファイル名のみが返されます.

戻り値:
outputpyvista.MultiBlock | str

load に応じて,データセットまたはファイル名を指定します.

>>> import os
>>> from tempfile import mkdtemp
>>> import pyvista as pv
>>> from pyvista import examples
>>> filename = examples.download_single_sphere_animation(load=False)
>>> reader = pv.PVDReader(filename)

gifを一時ディレクトリに書き込みます.通常はローカルパスに書き込みます.

>>> gif_filename = os.path.join(mkdtemp(), 'single_sphere.gif')

アニメーションを生成します.

>>> pl = pv.Plotter()
>>> pl.open_gif(gif_filename)
>>> for time_value in reader.time_values:
...     reader.set_active_time_value(time_value)
...     mesh = reader.read()
...     _ = pl.add_mesh(mesh, smooth_shading=True)
...     _ = pl.add_text(f'Time: {time_value:.0f}', color='black')
...     pl.write_frame()
...     pl.clear()
...     pl.enable_lightkit()
>>> pl.close()

参考

Single Sphere Animation Dataset

詳細はデータセットギャラリーのこのデータセットをご覧ください。

Dual Sphere Animation Dataset

../../../_images/pyvista-examples-downloads-download_single_sphere_animation-66d5c9039d51dda3_00_00.gif