Commit 74bcbcf7 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[HYPERCUBE VISUALIZER] add better visualization for the axis

parent a2dbf0b7
No related merge requests found
Showing with 24 additions and 15 deletions
+24 -15
...@@ -8,6 +8,10 @@ from experiment.meteo_france_data.visualization.study_visualization.study_visual ...@@ -8,6 +8,10 @@ from experiment.meteo_france_data.visualization.study_visualization.study_visual
from experiment.trend_analysis.univariate_test.abstract_univariate_test import AbstractUnivariateTest from experiment.trend_analysis.univariate_test.abstract_univariate_test import AbstractUnivariateTest
from utils import get_display_name_from_object_type from utils import get_display_name_from_object_type
ALTITUDES_XLABEL = 'altitudes'
STARTING_YEARS_XLABEL = 'starting years'
class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
...@@ -86,14 +90,18 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -86,14 +90,18 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
if ax_idx == 0: if ax_idx == 0:
# Global information # Global information
ax.set_ylabel(self.get_title_plot(xlabel, ax_idx=0)) ax.set_ylabel(self.get_title_plot(xlabel, ax_idx=0))
ax.set_yticks(list(range(0, 101, 10))) if xlabel != STARTING_YEARS_XLABEL:
ax.set_yticks(list(range(0, 101, 10)))
else: else:
ax.set_ylabel(self.get_title_plot(xlabel, ax_idx=ax_idx)) ax.set_ylabel(self.get_title_plot(xlabel, ax_idx=ax_idx))
# Common function functions # Common function functions
if xlabel == STARTING_YEARS_XLABEL:
ax.set_xticks(xlabel_values[::3])
else:
ax.set_xticks(xlabel_values)
ax.set_xlabel(xlabel) ax.set_xlabel(xlabel)
ax.grid() ax.grid()
ax.set_xticks(xlabel_values)
ax.legend() ax.legend()
title = 'Evolution of {} trends (significative or not) wrt to the {} with {}'.format(subtitle, xlabel, title = 'Evolution of {} trends (significative or not) wrt to the {} with {}'.format(subtitle, xlabel,
...@@ -135,14 +143,15 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -135,14 +143,15 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
def massif_index_level(self): def massif_index_level(self):
return 1 return 1
def visualize_year_trend_test(self, axes=None, marker='o', add_detailed_plots=False): @staticmethod
def year_reduction(df, **kwargs): def year_reduction(df, **kwargs):
# Take the mean with respect to all the first axis indices # Take the mean with respect to all the first axis indices
return df.mean(axis=0) return df.mean(axis=0)
for subtitle, reduction_function in self.subtitle_to_reduction_function(year_reduction, def visualize_year_trend_test(self, axes=None, marker='o', add_detailed_plots=False):
for subtitle, reduction_function in self.subtitle_to_reduction_function(self.year_reduction,
add_detailed_plot=add_detailed_plots).items(): add_detailed_plot=add_detailed_plots).items():
self.visualize_trend_test_evolution(reduction_function=reduction_function, xlabel='starting years', self.visualize_trend_test_evolution(reduction_function=reduction_function, xlabel=STARTING_YEARS_XLABEL,
xlabel_values=self.starting_years, axes=axes, marker=marker, xlabel_values=self.starting_years, axes=axes, marker=marker,
subtitle=subtitle) subtitle=subtitle)
...@@ -157,7 +166,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -157,7 +166,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
for subtitle, reduction_function in self.subtitle_to_reduction_function(self.index_reduction, for subtitle, reduction_function in self.subtitle_to_reduction_function(self.index_reduction,
level=self.altitude_index_level, level=self.altitude_index_level,
add_detailed_plot=add_detailed_plots).items(): add_detailed_plot=add_detailed_plots).items():
self.visualize_trend_test_evolution(reduction_function=reduction_function, xlabel='altitudes', self.visualize_trend_test_evolution(reduction_function=reduction_function, xlabel=ALTITUDES_XLABEL,
xlabel_values=self.altitudes, axes=axes, marker=marker, xlabel_values=self.altitudes, axes=axes, marker=marker,
subtitle=subtitle) subtitle=subtitle)
......
...@@ -17,7 +17,7 @@ class Altitude_Hypercube_Year_Visualizer(AltitudeHypercubeVisualizer): ...@@ -17,7 +17,7 @@ class Altitude_Hypercube_Year_Visualizer(AltitudeHypercubeVisualizer):
@staticmethod @staticmethod
def index_reduction(df, level, **kwargs): def index_reduction(df, level, **kwargs):
replace_zero_with_nan = kwargs.get('replace_zero_with_nan') replace_zero_with_nan = kwargs.get('year_visualization') is not None
# Take the sum with respect to the years, replace any missing data with np.nan # Take the sum with respect to the years, replace any missing data with np.nan
if replace_zero_with_nan: if replace_zero_with_nan:
df = df.sum(axis=1).replace(0.0, np.nan) df = df.sum(axis=1).replace(0.0, np.nan)
...@@ -32,6 +32,6 @@ class Altitude_Hypercube_Year_Visualizer(AltitudeHypercubeVisualizer): ...@@ -32,6 +32,6 @@ class Altitude_Hypercube_Year_Visualizer(AltitudeHypercubeVisualizer):
df = df_bool.copy() df = df_bool.copy()
df = (df * df.columns)[df_bool] df = (df * df.columns)[df_bool]
# Reduce and append # Reduce and append
serie = reduction_function(df, replace_zero_with_nan=True) serie = reduction_function(df, year_visualization=True)
series.append(serie) series.append(serie)
return series, df_bool return series, df_bool
...@@ -87,8 +87,8 @@ def fast_altitude_year_hypercube(): ...@@ -87,8 +87,8 @@ def fast_altitude_year_hypercube():
visualizer = Altitude_Hypercube_Year_Visualizer(altitude_to_visualizer, save_to_file=save_to_file, visualizer = Altitude_Hypercube_Year_Visualizer(altitude_to_visualizer, save_to_file=save_to_file,
trend_test_class=trend_test_class, nb_data_reduced_for_speed=nb_data_reduced_for_speed) trend_test_class=trend_test_class, nb_data_reduced_for_speed=nb_data_reduced_for_speed)
visualizer.visualize_year_trend_test() visualizer.visualize_year_trend_test()
visualizer.visualize_massif_trend_test() # visualizer.visualize_altitude_trend_test()
visualizer.visualize_altitude_trend_test() # visualizer.visualize_massif_trend_test()
def full_altitude_year_hypercube(): def full_altitude_year_hypercube():
...@@ -134,8 +134,8 @@ def fast_quantity_altitude_hypercube(): ...@@ -134,8 +134,8 @@ def fast_quantity_altitude_hypercube():
def main_run(): def main_run():
# fast_altitude_hypercube() # fast_altitude_hypercube()
fast_altitude_year_hypercube() # fast_altitude_year_hypercube()
# full_altitude_year_hypercube() full_altitude_year_hypercube()
# fast_quantity_altitude_hypercube() # fast_quantity_altitude_hypercube()
# full_quantity_altitude_hypercube() # full_quantity_altitude_hypercube()
......
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