diff --git a/convert.py b/convert.py index 7da196e3c2c71116dda07943bff5280b37ebae6d..bbf7ecdd605ae679e93398fed53511598097c5e4 100755 --- a/convert.py +++ b/convert.py @@ -21,8 +21,11 @@ import numpy as np import fossils fossils.setup_pythonpath() + +# folder = os.path.join('workspace', \ +# 'models_dolicorhynchops_dolicorhynchops_10k') folder = os.path.join('workspace', \ - 'models_dolicorhynchops_dolicorhynchops_10k') + 'models_Panthera_pardus_Panthera_pardus_RC_30') meshfile = os.path.join(folder, 'mesh.msh') datafile = os.path.join(folder, 'smooth_stress_zz.msh') # <= values for colours @@ -61,14 +64,21 @@ points = ugrid.GetPoints() npts = points.GetNumberOfPoints() # print(f'npts={npts}') # print(f'len(data)={len(data)}') -vmin = np.min(data) + +vmin = np.min(data) # <= use real full range (dolico) vmax = np.max(data) + +vmin = -30. # <= use custom range (panthera) +vmax = 30. + # print(f'vmin={vmin}') # print(f'vmax={vmax}') rng = vmax-vmin for i, v in enumerate(data): val = int((v-vmin)/rng*255) # compute "hue" value from 0 to 255 + if val>255: val=255 # saturate + if val<0: val=0 r, g, b = colorsys.hsv_to_rgb(val/255, 1.0, 1.0) # convert to "rainbow colours" colors.InsertTuple3(i, r*255, g*255, b*255)