From 0fcf42ec38f4472361ded931b5e7360ec67fdae0 Mon Sep 17 00:00:00 2001
From: Le Roux Erwan <erwan.le-roux@irstea.fr>
Date: Mon, 15 Jul 2019 14:50:00 +0200
Subject: [PATCH] [HYPERCUBE VISUALIZATION] improve display for the trend type
 & for the missing massif

---
 .../scm_models_data/abstract_study.py            |  2 +-
 .../altitude_hypercube_visualizer.py             |  6 ++++--
 .../main_files_after_conf/main_starting_years.py | 16 ++++++++++++----
 .../univariate_test/abstract_univariate_test.py  |  5 +++--
 4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/experiment/meteo_france_data/scm_models_data/abstract_study.py b/experiment/meteo_france_data/scm_models_data/abstract_study.py
index 4cf99e10..df09b2ed 100644
--- a/experiment/meteo_france_data/scm_models_data/abstract_study.py
+++ b/experiment/meteo_france_data/scm_models_data/abstract_study.py
@@ -228,7 +228,7 @@ class AbstractStudy(object):
     def visualize_study(cls, ax=None, massif_name_to_value: Union[None, Dict[str, float]] = None, show=True, fill=True,
                         replace_blue_by_white=True,
                         label=None, add_text=False, cmap=None, vmax=100, vmin=0,
-                        default_color_for_missing_massif='w',
+                        default_color_for_missing_massif='grey',
                         default_color_for_nan_values='w',
                         massif_name_to_color=None,
                         show_label=True,
diff --git a/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/altitude_hypercube_visualizer.py b/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/altitude_hypercube_visualizer.py
index 54c55926..55b1c08d 100644
--- a/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/altitude_hypercube_visualizer.py
+++ b/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/altitude_hypercube_visualizer.py
@@ -282,10 +282,12 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
         massif_to_year = {}
         poster_trend_types = [AbstractUnivariateTest.SIGNIFICATIVE_POSITIVE_TREND,
                               AbstractUnivariateTest.SIGNIFICATIVE_NEGATIVE_TREND,
-                              AbstractUnivariateTest.NON_SIGNIFICATIVE_TREND][:2]
+                              AbstractUnivariateTest.NEGATIVE_TREND,
+                              AbstractUnivariateTest.POSITIVE_TREND,
+                              ][:]
         for display_trend_type, style in self.display_trend_type_to_style.items():
             if display_trend_type in poster_trend_types:
-                color = style[:1]
+                color = style[:-1]
                 serie = trend_type_to_serie[display_trend_type]
                 massif_to_color_for_trend_type = {k: color for k, v in dict(serie).items() if not np.isnan(v)}
                 massif_to_color.update(massif_to_color_for_trend_type)
diff --git a/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files_after_conf/main_starting_years.py b/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files_after_conf/main_starting_years.py
index 2125580e..4ac6423c 100644
--- a/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files_after_conf/main_starting_years.py
+++ b/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files_after_conf/main_starting_years.py
@@ -30,7 +30,7 @@ def get_fast_altitude_visualizer(altitude_hypercube_class):
     return visualizer
 
 
-def main_fast_spatial_repartition():
+def main_fast_old_spatial_repartition():
     # Simply the main graph
     get_fast_altitude_visualizer(Altitude_Hypercube_Year_Visualizer).visualize_massif_trend_test_one_altitude()
 
@@ -51,19 +51,27 @@ def get_full_altitude_visualizer(altitude_hypercube_class, exact_starting_year=N
 FULL_ALTITUDES = [900, 1500, 2100, 2700]
 
 
+def main_fast_spatial_repartition():
+    for altitude in FULL_ALTITUDES[-1:]:
+        vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude,
+                                                  exact_starting_year=1958)
+        vizualiser.visualize_massif_trend_test_one_altitude()
+
+
 def main_full_spatial_repartition():
     for altitude in FULL_ALTITUDES[:]:
         # Compute for the most likely starting year
         vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude)
         vizualiser.visualize_massif_trend_test_one_altitude()
         # Compute the trend for a linear trend
-        vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude, exact_starting_year=1958)
+        vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude,
+                                                  exact_starting_year=1958)
         vizualiser.visualize_massif_trend_test_one_altitude()
 
 
 def main_run():
-    main_full_spatial_repartition()
-    # main_fast_spatial_repartition()
+    # main_full_spatial_repartition()
+    main_fast_spatial_repartition()
 
 
 if __name__ == '__main__':
diff --git a/experiment/trend_analysis/univariate_test/abstract_univariate_test.py b/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
index e0b1e3ec..52863f98 100644
--- a/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
+++ b/experiment/trend_analysis/univariate_test/abstract_univariate_test.py
@@ -56,8 +56,8 @@ class AbstractUnivariateTest(object):
     @classmethod
     def display_trend_type_to_style(cls):
         d = OrderedDict()
-        # d[cls.POSITIVE_TREND] = 'g--'
-        # d[cls.NEGATIVE_TREND] = 'r--'
+        d[cls.POSITIVE_TREND] = 'lightgreen-'
+        d[cls.NEGATIVE_TREND] = 'lightcoral-'
         d[cls.ALL_TREND] = 'k-'
         d[cls.NON_SIGNIFICATIVE_TREND] = 'b-'
         # d[cls.SIGNIFICATIVE_ALL_TREND] = 'k-'
@@ -66,6 +66,7 @@ class AbstractUnivariateTest(object):
         # d[cls.NO_TREND] = 'k--'
         return d
 
+
     @classmethod
     def get_display_trend_type(cls, real_trend_type):
         if cls.SIGNIFICATIVE in real_trend_type:
-- 
GitLab