From 967170e722f87e56fbf69ea67b3d11e42b8bc04b Mon Sep 17 00:00:00 2001
From: Le Roux Erwan <erwan.le-roux@irstea.fr>
Date: Thu, 7 Nov 2019 09:25:58 +0100
Subject: [PATCH] [Eurocode drawing] add grid. add function to compute the
 percentage of significant trend on an example

---
 .../eurocode_data/eurocode_visualizer.py      |  2 ++
 .../eurocode_data/main_eurocode_drawing.py    |  8 ++++----
 experiment/grand bornand.py                   | 16 ----------------
 ...snow_load_trends_percentage_significant.py | 19 +++++++++++++++++++
 4 files changed, 25 insertions(+), 20 deletions(-)
 delete mode 100644 experiment/grand bornand.py
 create mode 100644 experiment/paper1_steps/snow_load_trends_percentage_significant.py

diff --git a/experiment/eurocode_data/eurocode_visualizer.py b/experiment/eurocode_data/eurocode_visualizer.py
index b94b1ff1..847b09af 100644
--- a/experiment/eurocode_data/eurocode_visualizer.py
+++ b/experiment/eurocode_data/eurocode_visualizer.py
@@ -83,3 +83,5 @@ def plot_label_to_ordered_return_level_uncertainties(ax, massif_name, model_name
     ax.set_title(massif_name + ' ' + model_name)
     ax.set_ylabel('50-year return level (N $m^-2$)')
     ax.set_xlabel('Altitude (m)')
+    ax.grid()
+
diff --git a/experiment/eurocode_data/main_eurocode_drawing.py b/experiment/eurocode_data/main_eurocode_drawing.py
index 564c01ec..8cdaeb16 100644
--- a/experiment/eurocode_data/main_eurocode_drawing.py
+++ b/experiment/eurocode_data/main_eurocode_drawing.py
@@ -57,9 +57,9 @@ def main_drawing():
     # Select parameters
     massif_names = MASSIF_NAMES_ALPS[:]
     model_class_and_last_year = [
-                                    (StationaryTemporalModel, LAST_YEAR_FOR_EUROCODE),
                                     (StationaryTemporalModel, 2017),
                                     (NonStationaryLocationAndScaleTemporalModel, 2017),
+                                    # Add the temperature here
                                 ][1:]
     altitudes = EUROCODE_ALTITUDES[:]
     uncertainty_methods = [ConfidenceIntervalMethodFromExtremes.my_bayes,
@@ -68,11 +68,11 @@ def main_drawing():
 
     if fast_plot:
         show = True
-        model_class_and_last_year = model_class_and_last_year[:2]
+        model_class_and_last_year = model_class_and_last_year[:1]
         altitudes = altitudes[2:]
         # altitudes = altitudes[:]
-        massif_names = massif_names[:3]
-        uncertainty_methods = uncertainty_methods[:2]
+        massif_names = massif_names[:1]
+        uncertainty_methods = uncertainty_methods[1:]
 
     model_name_to_massif_name_to_ordered_return_level = {}
     for model_class, last_year_for_the_data in model_class_and_last_year:
diff --git a/experiment/grand bornand.py b/experiment/grand bornand.py
deleted file mode 100644
index b32dc817..00000000
--- a/experiment/grand bornand.py	
+++ /dev/null
@@ -1,16 +0,0 @@
-from experiment.meteo_france_data.scm_models_data.crocus.crocus import CrocusDepth
-import matplotlib.pyplot as plt
-
-study = CrocusDepth(altitude=1500)
-years = []
-height = []
-for year, days in study.year_to_days.items():
-    i = days.index(str(year+1) + '-04-01')
-    a = study.year_to_daily_time_serie_array[year]
-    j = study.study_massif_names.index('Aravis')
-    h = a[i, j]
-    print(h)
-    height.append(h)
-    years.append(year)
-plt.plot(years, height)
-plt.show()
\ No newline at end of file
diff --git a/experiment/paper1_steps/snow_load_trends_percentage_significant.py b/experiment/paper1_steps/snow_load_trends_percentage_significant.py
new file mode 100644
index 00000000..ba38f673
--- /dev/null
+++ b/experiment/paper1_steps/snow_load_trends_percentage_significant.py
@@ -0,0 +1,19 @@
+import numpy as np
+
+d = {
+    'mu': [8, 4, 1],
+    'sigma': [5, 2, 2],
+    "both": [9, 6, 5]
+}
+
+
+def compare(a):
+    assert a in ['mu', 'sigma']
+    percents = [new / old for old, new in zip(d[a], d['both'])]
+    print(np.mean(percents))
+
+
+if __name__ == '__main__':
+    compare('mu')
+    compare('sigma')
+    # conclusion: more than 2 times more significant trends in average
-- 
GitLab