予め定義しておいた複数の点における任意の値を、タブ区切りテキストとして出力する。locationにリスト形式で点の座標を、variablesにリスト形式で変数名を指定しておき、本スクリプトを実行する。非定常データの場合は、時刻付きでデータが出力される。
動作確認環境
ParaView 3.14.1 64bit、CentOS 6.2 64bit、Python 2.7.3
Script
probePoints.py
location = ( (0.0, 1.2675, 4.25), (0.0, 1.2675, 6.25), (0.0, 1.2675, 8.25), ) variables = ( 'Pressure', ) source = GetActiveSource() view = GetActiveView() probe = ProbeLocation(ProbeType="Fixed Radius Point Source") probe.ProbeType = "Fixed Radius Point Source" #probe.ProbeType.Radius = 1.0 Show() list_time = source.TimestepValues if len(list_time) == 0: list_time = [0.0] f = [] for var in variables: f.append(open('probe_' + var + '.dat', 'w')) for i in range(0, len(list_time)): view.ViewTime = list_time[i] Render() list_temp = [str(list_time[i])] for j in range(0, len(variables)): for loc in location: probe.ProbeType.Center = loc Show() sm = servermanager.Fetch(probe) list_temp.append(str(sm.GetPointData().GetArray(variables[j]).GetValue(0))) f[j].writelines('\t'.join(list_temp) + '\n') for i in range(0, len(f)): f[i].close()
コメントを残す