From a92b7cf1e25a7aebc01a8a4b871d7605fc77a23e Mon Sep 17 00:00:00 2001
From: Romain Boman <romain.boman@gmail.com>
Date: Mon, 21 Nov 2022 16:15:39 +0100
Subject: [PATCH] adapt parameters to panthera

---
 convert.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/convert.py b/convert.py
index 7da196e..bbf7ecd 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)
 
-- 
GitLab