如何在Paraview python脚本中设置颜色表范围?

时间:2016-06-01 14:35:32

标签: python paraview

我在Paraview中可视化空间数据的时间序列,我希望我的设置脚本根据整个时间序列中的字段范围设置给定字段的颜色表,而不是单个快照。我已尝试使用脚本计算的值初始化查找表,但无济于事。

下图显示了运行我的设置脚本的结果。 Python Shell窗口中的值是应该设置的比例,但颜色条显示另一个值。

results of running the setup script. The values in the Python Shell window are what the scales should be set to, but the color bar shows another value

我的设置脚本的相关部分在这里。

# get the scales for the surface fields
mag_os_xdmf = FindSource('mag_os.xdmf')
with h5py.File(mag_os_xdmf.FileName.replace('xdmf', 'h5'), 'r') as h5:
    for comp in ('br', 'bt', 'bp'):
        scale = np.abs(h5[comp].value).max()
        print(comp, scale)
        ctab = [-scale, 0.23137254901960785, 0.2980392156862745, 0.7529411764705882,
                scale, 0.7058823529411765, 0.01568627450980392, 0.14901960784313725]
        DataRep = GetDisplayProperties(mag_os_xdmf)
        lut = GetLookupTableForArray(comp, 1, NanColor=[0.24705882352941178, 0.0, 0.0],
                                     RGBPoints = ctab, ColorSpace='Diverging' )
        DataRep.ColorArrayName = ('POINT_DATA', comp)
        DataRep.LookupTable = lut
Render()

为了比较,我在手动更改颜色栏时输出了python跟踪

try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

mag_os_xdmf = GetActiveSource()
DataRepresentation6 = GetDisplayProperties(mag_os_xdmf)
a1_br_PVLookupTable = GetLookupTableForArray( "br", 1, RGBPoints=[-0.122, 0.23, 0.299, 0.754, 0.122, 0.706, 0.016, 0.15] )

DataRepresentation6.ScalarOpacityFunction = []
DataRepresentation6.ColorArrayName = ('POINT_DATA', 'br')
DataRepresentation6.LookupTable = a1_br_PVLookupTable

Render()

1 个答案:

答案 0 :(得分:0)

您应该可以执行以下操作:

>> javaaddpath('C:\Octave\Octave-4.0.1\pretty-tools-JDDE-2.0.3\pretty-tools-JDDE-2.0.3.jar')
>> javaclasspath
   STATIC JAVA PATH

      C:\Octave\Octave-4.0.1\pretty-tools-JDDE-2.0.3\pretty-tools-JDDE-2.0.3.jar

   DYNAMIC JAVA PATH

      C:\Octave\Octave-4.0.1\pretty-tools-JDDE-2.0.3\pretty-tools-JDDE-2.0.3.jar

>>  a = javaObject('com.pretty_tools.dde.client.DDEClientConversation')

error: [java] java.lang.UnsatisfiedLinkError: no JavaDDE in java.library.path
>>  a = javaObject('com.pretty_tools.dde.client.DDEClientConversation')

error: [java] java.lang.NoClassDefFoundError: Could not initialize class com.pretty_tools.dde.client.DDEClientConversation