An error occurred while loading the file. Please try again.
-
Calmel Blaise authored
Fix few bugs : crash when popup is closed above 90%, auto u bias not resetting properly, meas_name not updating when new spreadsheet is load
04906131
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import Dict
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.colorbar as cbar
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_toolkits.axes_grid1 import make_axes_locatable
from extreme_estimator.margin_fits.plot.shifted_color_map import shiftedColorMap
from extreme_estimator.margin_fits.extreme_params import ExtremeParams
from extreme_estimator.margin_fits.gev.gev_params import GevParams
from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates
from spatio_temporal_dataset.slicer.split import Split
def plot_extreme_param(ax, gev_param_name, values):
# Load the shifted cmap to center on a middle point
vmin, vmax = np.min(values), np.max(values)
cmap = [plt.cm.coolwarm, plt.cm.bwr, plt.cm.seismic][1]
if gev_param_name == ExtremeParams.SHAPE and vmin < 0:
midpoint = 1 - vmax / (vmax + abs(vmin))
shifted_cmap = shiftedColorMap(cmap, midpoint=midpoint, name='shifted')
else:
shifted_cmap = shiftedColorMap(cmap, midpoint=0.0, name='shifted')
norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
divider = make_axes_locatable(ax)
cax = divider.append_axes('right', size='5%', pad=0.05)
cb = cbar.ColorbarBase(cax, cmap=shifted_cmap, norm=norm)
cb.set_label(gev_param_name)
return norm, shifted_cmap
def get_color_rbga(ax, gev_param_name, values):
"""
For some display it was necessary to transform dark blue values into white values
"""
norm, shifted_cmap = plot_extreme_param(ax, gev_param_name, values)
m = cm.ScalarMappable(norm=norm, cmap=shifted_cmap)
colors = [m.to_rgba(value) for value in values]
if gev_param_name != ExtremeParams.SHAPE:
colors = [color if color != (0, 0, 1, 1) else (1, 1, 1, 1) for color in colors]
return colors