# HG changeset patch # User luca_milaz # Date 1722783991 0 # Node ID 85e5a73eb6d2ef5e5e9bd0bde18bcf3f36ca0ecf # Parent 28de43f27623afcd3b80889b1d8f4aa048f9ca6e Uploaded diff -r 28de43f27623 -r 85e5a73eb6d2 marea_2/flux_to_map.py --- a/marea_2/flux_to_map.py Sun Aug 04 14:51:03 2024 +0000 +++ b/marea_2/flux_to_map.py Sun Aug 04 15:06:31 2024 +0000 @@ -819,8 +819,8 @@ return '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255)) def reds_cmap(value): - """Map normalized value to RGB color using the Reds colormap.""" - # The `Reds` colormap starts with white and transitions to red + """Map a normalized value to RGB color using the Reds colormap.""" + # Assumi che 'value' sia scalare e tra 0 e 1 r = value g = 0 b = 0 @@ -830,9 +830,6 @@ metabMap_mean = copy.deepcopy(metabMap) metabMap_median = copy.deepcopy(metabMap) - - #class_pat 462 * cellule - medians = {} means = {} @@ -843,21 +840,22 @@ medians[key] = median means[key] = mean - max_flux_medians = max(np.max(np.abs(arr)) for arr in medians.values()) max_flux_means = max(np.max(np.abs(arr)) for arr in means.values()) + # Normalizzazione dei medians e means for key, value in medians.items(): medians[key] = medians[key] / max_flux_medians for key, value in means.items(): means[key] = means[key] / max_flux_means - colors_median_rgb = {k: reds_cmap(v) for k, v in medians.items()} - colors_median = {k: rgba_to_hex(c) for k, c in colors_median_rgb.items()} + # 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()} - colors_mean_rgb = {k: reds_cmap(v) for k, v in means.items()} - colors_mean = {k: rgba_to_hex(c) for k, c in colors_mean_rgb.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()} for rxn_id in ids: arrow = Arrow(width=5, col=colors_median[rxn_id]) @@ -865,7 +863,6 @@ svgFilePath = utils.FilePath(details = "SVG Map median", ext = utils.FileFormat.SVG, prefix="result") utils.writeSvg(svgFilePath, metabMap_median) - pass ############################ MAIN #############################################