title: How do I set color table ranges in a Paraview python script?
body: <p>I'm visualizing a time series of spatial data in Paraview, and I would like for my setup script to set the color tables for a given field based on the field's range over the full time series, rather than an individual snapshot. I've tried initializing the lookup table with values computed by the script, but to no avail.</p>
  
  <p>The figure below shows results of running my setup script. The values in the Python Shell window are what the scales should be set to, but the color bar shows another value.</p>
  
  <p><a href="https://i.stack.imgur.com/JgJ2G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JgJ2G.png" alt="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"></a></p>
  
  <p>The relevant part of my setup script is here.</p>
  
  <pre><code># 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()
  </code></pre>
  
  <p>For comparison, here's the output of a python trace when I manually change the colorbar</p>
  
  <pre><code>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()
  </code></pre>