Commit ca6da2ab authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[HYPERCUBE] fix starting_year minor display issues.

parent 00bd8a55
No related merge requests found
Showing with 19 additions and 16 deletions
+19 -16
......@@ -30,6 +30,12 @@ class AbstractHypercubeVisualizer(object):
self.trend_test_class = trend_test_class
self.tuple_to_study_visualizer = tuple_to_study_visualizer # type: Dict[Tuple, StudyVisualizer]
if isinstance(nb_data_reduced_for_speed, bool):
self.nb_data_for_fast_mode = 7 if nb_data_reduced_for_speed else None
else:
assert isinstance(nb_data_reduced_for_speed, int)
self.nb_data_for_fast_mode = nb_data_reduced_for_speed
if exact_starting_year is not None:
assert first_starting_year is None
assert last_starting_year is None
......@@ -38,15 +44,17 @@ class AbstractHypercubeVisualizer(object):
default_first_starting_year, *_, default_last_starting_year = self.all_potential_starting_years
self.first_starting_year = first_starting_year if first_starting_year is not None else default_first_starting_year
self.last_starting_year = last_starting_year if last_starting_year is not None else default_last_starting_year
if isinstance(nb_data_reduced_for_speed, bool):
self.nb_data_for_fast_mode = 7 if nb_data_reduced_for_speed else None
else:
assert isinstance(nb_data_reduced_for_speed, int)
self.nb_data_for_fast_mode = nb_data_reduced_for_speed
# Load starting year
self.starting_years = [year for year in self.all_potential_starting_years
if self.first_starting_year <= year <= self.last_starting_year]
if self.nb_data_for_fast_mode is not None:
self.starting_years = self.starting_years[:self.nb_data_for_fast_mode]
self.last_starting_year = self.starting_years[-1]
if self.verbose:
print('Hypercube with parameters:')
print('First starting year: {}, Last starting year: {}'.format(self.first_starting_year, self.last_starting_year))
print('First starting year: {}, Last starting year: {}'.format(self.first_starting_year,
self.last_starting_year))
print('Starting years:', self.starting_years)
print('Trend test class:', get_display_name_from_object_type(self.trend_test_class))
......@@ -60,14 +68,6 @@ class AbstractHypercubeVisualizer(object):
def all_potential_starting_years(self):
return self.study_visualizer.starting_years
@cached_property
def starting_years(self):
starting_years = [year for year in self.all_potential_starting_years
if self.first_starting_year <= year <= self.last_starting_year]
if self.nb_data_for_fast_mode is not None:
starting_years = starting_years[:self.nb_data_for_fast_mode]
return starting_years
def tuple_values(self, idx):
return sorted(set([t[idx] if isinstance(t, tuple) else t for t in self.tuple_to_study_visualizer.keys()]))
......@@ -81,11 +81,11 @@ class AbstractHypercubeVisualizer(object):
df_spatio_temporal_trend_strength = [e[idx] for e in self.df_trends_spatio_temporal]
return pd.concat(df_spatio_temporal_trend_strength, keys=list(self.tuple_to_study_visualizer.keys()), axis=0)
@cached_property
def df_hypercube_trend_type(self) -> pd.DataFrame:
return self._df_hypercube_trend_meta(idx=0
)
@cached_property
def df_hypercube_trend_strength(self) -> pd.DataFrame:
return self._df_hypercube_trend_meta(idx=1)
......
......@@ -143,7 +143,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
if plot_title is not None:
argmax_idx = np.argmax(values)
best_year = xlabel_values[argmax_idx]
plot_title += '{} {}'.format(subtitle, best_year)
plot_title += ' (max reached in {})'.format(best_year)
if subtitle in SCM_STUDY_NAME_TO_COLOR:
ax, color, ylabel = ax.twinx(), SCM_STUDY_NAME_TO_COLOR[subtitle], subtitle
......
......@@ -15,8 +15,11 @@ from collections import OrderedDict
from experiment.trend_analysis.univariate_test.abstract_gev_change_point_test import GevLocationChangePointTest
from spatio_temporal_dataset.coordinates.transformed_coordinates.transformation.uniform_normalization import \
BetweenZeroAndOneNormalization, BetweenMinusOneAndOneNormalization
from utils import get_display_name_from_object_type
SCM_STUDIES = [SafranSnowfall, CrocusSwe, CrocusDepth]
SCM_STUDY_NAME_TO_COLOR = {get_display_name_from_object_type(s): color
for s, color in zip(SCM_STUDIES, ['r', 'b', 'g'])}
SCM_EXTENDED_STUDIES = [ExtendedSafranSnowfall, ExtendedCrocusSwe, ExtendedCrocusDepth]
SCM_STUDY_TO_EXTENDED_STUDY = OrderedDict(zip(SCM_STUDIES, SCM_EXTENDED_STUDIES))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment