Mercurial > repos > bimib > marea_2
changeset 260:85e5a73eb6d2 draft
Uploaded
author | luca_milaz |
---|---|
date | Sun, 04 Aug 2024 15:06:31 +0000 |
parents | 28de43f27623 |
children | db3f82d4c519 |
files | marea_2/flux_to_map.py |
diffstat | 1 files changed, 8 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 #############################################