changeset 262:d3688d572259 draft

Uploaded
author luca_milaz
date Sun, 04 Aug 2024 15:18:49 +0000
parents db3f82d4c519
children 480412399608
files marea_2/flux_to_map.py
diffstat 1 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/flux_to_map.py	Sun Aug 04 15:11:45 2024 +0000
+++ b/marea_2/flux_to_map.py	Sun Aug 04 15:18:49 2024 +0000
@@ -831,7 +831,7 @@
     metabMap_mean = copy.deepcopy(metabMap)
     metabMap_median = copy.deepcopy(metabMap)
     
-    medians = {}
+    medians = {} # dict , for each class an array (the median)
     means = {}
     for key, value in class_pat.items():
         values = np.array(class_pat[key])
@@ -850,23 +850,26 @@
     for key, value in means.items():
         means[key] = means[key] / max_flux_means
 
-    # Mappatura dei colori, applica reds_cmap a ogni elemento
-    colors_median_rgb = {k: [reds_cmap(v) for v in arr] for k, arr in medians.items()}
-    colors_median = {k: rgba_to_hex(np.mean(c, axis=0)) for k, c in colors_median_rgb.items()}
+    for key, value in class_pat.items():
 
-    colors_mean_rgb = {k: [reds_cmap(v) for v in arr] for k, arr in means.items()}
-    colors_mean = {k: rgba_to_hex(np.mean(c, axis=0)) for k, c in colors_mean_rgb.items()}
+        colors_median={}
+        i=0
+        for rxn_id in ids:
+             colors_median[rxn_id] = rgba_to_hex(reds_cmap(medians[key][i]))
+             i+=1
 
-    utils.logWarning(
-        colors_mean,
-        ARGS.out_log)
+        colors_mean={}
+        i=0
+        for rxn_id in ids:
+             colors_mean[rxn_id] = rgba_to_hex(reds_cmap(means[key][i]))
+             i+=1
 
-    for rxn_id in ids:
-        arrow = Arrow(width=5, col=colors_median[rxn_id])
-        arrow.applyTo(rxn_id, metabMap_median, arrow.toStyleStr())
+        for rxn_id in ids:
+            arrow = Arrow(width=5, col=colors_median[rxn_id])
+            arrow.applyTo(rxn_id, metabMap_median, arrow.toStyleStr())
 
-    svgFilePath = utils.FilePath(details = "SVG Map median", ext = utils.FileFormat.SVG, prefix="result")
-    utils.writeSvg(svgFilePath, metabMap_median)
+        svgFilePath = utils.FilePath(details = "SVG Map median - class " + str(key), ext = utils.FileFormat.SVG, prefix="result")
+        utils.writeSvg(svgFilePath, metabMap_median)
 
     
 ############################ MAIN #############################################