LoginSignup
9
14

More than 5 years have passed since last update.

Paraview Pythonのインストール

Posted at

オープンソースのデータ解析、可視化アプリケーションであるParaviewをPythonから操作するParaview Python。インストールで、というかどうやって使うと良いかよく分からなかったので、メモ。

Paraviewとは

http://www.paraview.org/
オープンソースのデータ解析、可視化アプリケーション。OpenFOAMなどOpen CAEの可視化でよく使われる。
PythonによるScripting、Web Browser上での表示等、できることが色々あるので今回インストール。ビルドするのも面倒なので、Binaryをダウンロードしてインストール。

Paraview Pythonとは

http://www.paraview.org/python/
ParaviewはPythonによってスクリプトを書くことができる。Clientアプリケーション上でも書くことができるが、今回はOpenFOAMの解析結果を自動的に画像、動画にして保存したいので、端末上で開発、実行できる環境を構築したい。

pvpython, pvbatchの設定、テスト

pvpythonは、起動するとparaviewモジュールがPYTHONPATHに含まれたシェルが起動する。pvbatchがPythonのソースコードを引数に、バッチ処理をするためのもの。基本的に、Binaryをダウンロードした時点で入っているので、Pathを通すだけでOK。

.zshrc
# Paraview python
export PATH="/Applications/ParaView-5.2.0.app/Contents/bin:$PATH"

これで以下の通り動作する。

pvpythonの起動

$ pvpython
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

pvbatchの起動

試しに以下のようなtest.pyを作成して実行。
(参考:http://www.paraview.org/ParaView3/Doc/Nightly/www/py-doc/paraview.simple.html)

test.py
from paraview.simple import *

# Create a new sphere proxy on the active connection and register it
# in the sources group.
sphere = Sphere(ThetaResolution=16, PhiResolution=32)

# Apply a shrink filter
shrink = Shrink(sphere)

# Turn the visiblity of the shrink object on.
Show(shrink)

# Render the scene
Render()

# Save as Image
WriteImage('test.png')

$ pvbatch test.py

これで以下のような画像が生成されるはず
U.png

9
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
14