From 373c3560f20dd917f5b51331837fdc71144cc686 Mon Sep 17 00:00:00 2001
From: Le Roux Erwan <erwan.le-roux@irstea.fr>
Date: Mon, 12 Apr 2021 10:42:10 +0200
Subject: [PATCH] [projection snowfall] add global temperature for 2020

---
 ... => global_mean_temperature_until_2016.py} |  5 ++--
 .../global_mean_temperature_until_2020.py     | 25 +++++++++++++++++++
 .../temperature_covariate.py                  |  4 +--
 .../test_mean_global_temperature.py           |  4 +--
 4 files changed, 32 insertions(+), 6 deletions(-)
 rename extreme_data/nasa_data/{global_mean_temperature.py => global_mean_temperature_until_2016.py} (92%)
 create mode 100644 extreme_data/nasa_data/global_mean_temperature_until_2020.py

diff --git a/extreme_data/nasa_data/global_mean_temperature.py b/extreme_data/nasa_data/global_mean_temperature_until_2016.py
similarity index 92%
rename from extreme_data/nasa_data/global_mean_temperature.py
rename to extreme_data/nasa_data/global_mean_temperature_until_2016.py
index 2b98d317..732a75a0 100644
--- a/extreme_data/nasa_data/global_mean_temperature.py
+++ b/extreme_data/nasa_data/global_mean_temperature_until_2016.py
@@ -2,6 +2,7 @@
 Source:
 https://www.jpl.nasa.gov/edu/teach/activity/graphing-global-temperature-trends/
 
+
 We took the csv file correspond to "Global annual mean temperature data"
 """
 import pandas as pd
@@ -11,8 +12,7 @@ from root_utils import get_full_path
 relative_path = r'local/NASA_data/global_annual_mean_temp_anomalies_land-ocean_1880-2016_modified.csv'
 edf_filepath = get_full_path(relative_path=relative_path)
 
-
-def load_year_to_mean_global_temperature():
+def load_year_to_mean_global_temperature_until_2016():
     df = pd.read_csv(edf_filepath)
     df = df.astype({'Year': 'float'})
     d = dict(zip(df['Year'], df['Actual Temp']))
@@ -22,3 +22,4 @@ def load_year_to_mean_global_temperature():
     #     d[2016 + idx] = d[2016]
     return d
 
+
diff --git a/extreme_data/nasa_data/global_mean_temperature_until_2020.py b/extreme_data/nasa_data/global_mean_temperature_until_2020.py
new file mode 100644
index 00000000..a34c14db
--- /dev/null
+++ b/extreme_data/nasa_data/global_mean_temperature_until_2020.py
@@ -0,0 +1,25 @@
+"""
+Source:
+https://www.jpl.nasa.gov/edu/teach/activity/graphing-global-temperature-trends/
+
+
+We took the csv file correspond to "Global annual mean temperature data"
+"""
+import pandas as pd
+
+from root_utils import get_full_path
+
+# relative_path = r'local/NASA_data/global_annual_mean_temp_anomalies_land-ocean_1880-2016_modified.csv'
+# edf_filepath = get_full_path(relative_path=relative_path)
+
+
+# def load_year_to_mean_global_temperature_until_2020():
+#     df = pd.read_csv(edf_filepath)
+#     df = df.astype({'Year': 'float'})
+#     d = dict(zip(df['Year'], df['Actual Temp']))
+#     # # Cheat for the last years
+#     # print('Warning: using fake values for the last few years !!!')
+#     # for idx in range(1, 5):
+#     #     d[2016 + idx] = d[2016]
+#     return d
+
diff --git a/spatio_temporal_dataset/coordinates/temporal_coordinates/temperature_covariate.py b/spatio_temporal_dataset/coordinates/temporal_coordinates/temperature_covariate.py
index bf4fe9b7..bb9b5fed 100644
--- a/spatio_temporal_dataset/coordinates/temporal_coordinates/temperature_covariate.py
+++ b/spatio_temporal_dataset/coordinates/temporal_coordinates/temperature_covariate.py
@@ -1,7 +1,7 @@
 from extreme_data.meteo_france_data.adamont_data.adamont_scenario import str_to_scenario
 from extreme_data.meteo_france_data.adamont_data.cmip5.climate_explorer_cimp5 import year_to_global_mean_temp
 from extreme_data.meteo_france_data.mean_alps_temperature import load_year_to_mean_alps_temperatures
-from extreme_data.nasa_data.global_mean_temperature import load_year_to_mean_global_temperature
+from extreme_data.nasa_data.global_mean_temperature_until_2016 import load_year_to_mean_global_temperature_until_2016
 from root_utils import classproperty
 from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates
 from spatio_temporal_dataset.coordinates.temporal_coordinates.abstract_temporal_covariate_for_fit import \
@@ -35,7 +35,7 @@ class MeanGlobalTemperatureCovariate(AbstractTemperatureCovariate):
 
     @classmethod
     def load_year_to_temperature_covariate(cls):
-        return load_year_to_mean_global_temperature()
+        return load_year_to_mean_global_temperature_until_2016()
 
 
 class MeanAlpsTemperatureCovariate(AbstractTemperatureCovariate):
diff --git a/test/test_extreme_data/test_nasa_data/test_mean_global_temperature.py b/test/test_extreme_data/test_nasa_data/test_mean_global_temperature.py
index 45abe11a..734da1bd 100644
--- a/test/test_extreme_data/test_nasa_data/test_mean_global_temperature.py
+++ b/test/test_extreme_data/test_nasa_data/test_mean_global_temperature.py
@@ -1,13 +1,13 @@
 import unittest
 
 from extreme_data.meteo_france_data.mean_alps_temperature import load_year_to_mean_alps_temperatures
-from extreme_data.nasa_data.global_mean_temperature import load_year_to_mean_global_temperature
+from extreme_data.nasa_data.global_mean_temperature_until_2016 import load_year_to_mean_global_temperature_until_2016
 
 
 class TestMeanGlobalTemperatures(unittest.TestCase):
 
     def test_year_to_mean_global_temperature(self):
-        d = load_year_to_mean_global_temperature()
+        d = load_year_to_mean_global_temperature_until_2016()
         self.assertNotIn(2019, d)
         self.assertIn(2009, d)
         key = list(d.keys())[0]
-- 
GitLab