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 2b98d317ef2f171139918244599fbe395126bf59..732a75a0a9f22948f57576a235e5d9046b68b71a 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 0000000000000000000000000000000000000000..a34c14db5cf4995d3fef37a6151c20086242e35e --- /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 bf4fe9b76c1901e43c533bfea40296562c364289..bb9b5fed132f16466dffd33ea0b365dd8766d4e7 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 45abe11af269cc084b03e6b5a19dfbb850f156ac..734da1bdb89942ec7d782205bf8ac9783cc6aef9 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]