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 898b98b60cc91e896af55792314f278a1d1f198f..ea6d7a674b073572ca2e7abeff1805066485aa3a 100644 --- a/experiment/meteo_france_data/scm_models_data/abstract_study.py +++ b/experiment/meteo_france_data/scm_models_data/abstract_study.py @@ -267,6 +267,7 @@ class AbstractStudy(object): show_label=True, scaled=False, fontsize=7, + axis_off=False, ): if ax is None: ax = plt.gca() @@ -302,15 +303,6 @@ class AbstractStudy(object): else: ax.fill(*coords_list, **{'color': default_color_for_missing_massif}) - # else: - # fill_kwargs = {} - - # x , y = list(self.massifs_coordinates.df_all_coordinates.loc[massif_name]) - # x , y= coords_list[0][0], coords_list[0][1] - # print(x, y) - # print(massif_name) - # ax.scatter(x, y) - # ax.text(x, y, massif_name) # Display the center of the massif masssif_coordinate_for_display = cls.massifs_coordinates_for_display(massif_names) @@ -338,6 +330,8 @@ class AbstractStudy(object): if scaled: plt.axis('scaled') + if axis_off: + plt.axis('off') if show: plt.show() 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 eba9f36a612310707fd4176ffc670d1ec5e359e5..f288db92fd291e7f07ebbf7e55a1dfcb07a2a171 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 @@ -283,7 +283,9 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): return title def visualize_trend_test_repartition_poster(self, reduction_function, axes=None, subtitle='', isin_parameters=None, - plot_title=None): + plot_title=None, + poster_plot=False, + write_text_on_massif=True): trend_type_to_serie = {k: v[0].replace(0.0, np.nan) for k, v in self.trend_type_to_series(reduction_function, isin_parameters).items()} @@ -313,7 +315,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): massif_to_strength.update(massif_to_value_for_trend_type[0]) massif_to_constant.update(massif_to_value_for_trend_type[1]) else: - massif_to_value_for_trend_type = {k: int(v) for k, v in + massif_to_value_for_trend_type = {k: "$t_0=$" + str(int(v)) for k, v in self.trend_type_to_series(reduction_function, isin_parameters)[ display_trend_type][1].items() @@ -330,11 +332,12 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): else: massif_name_to_value = massif_to_year self.study.visualize_study(None, massif_name_to_color=massif_to_color, show=False, - show_label=False, scaled=True, add_text=add_text, + show_label=False, scaled=True, add_text=write_text_on_massif, massif_name_to_value=massif_name_to_value, - fontsize=4) + fontsize=4, + axis_off=True) - title = self.set_trend_test_reparition_title(subtitle, set=True) + title = self.set_trend_test_reparition_title(subtitle, set=not poster_plot) return title @@ -459,15 +462,19 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): def visualize_massif_trend_test_one_altitude(self, axes=None, add_detailed_plots=False, plot_title=None, isin_parameters=None, - show_or_save_to_file=True): + show_or_save_to_file=True, + poster_plot=False, + write_text_on_massif=True): last_title = '' for subtitle, reduction_function in self.subtitle_to_reduction_function(self.index_reduction, level=self.massif_index_level, add_detailed_plot=add_detailed_plots).items(): last_title = self.visualize_trend_test_repartition_poster(reduction_function, axes, subtitle=subtitle, isin_parameters=isin_parameters, - plot_title=plot_title) + plot_title=plot_title, + poster_plot=poster_plot, + write_text_on_massif=write_text_on_massif) if show_or_save_to_file: - self.show_or_save_to_file(specific_title=last_title, dpi=1000) + self.show_or_save_to_file(specific_title=last_title, dpi=1000, tight=poster_plot) return last_title diff --git a/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files/main_poster.py b/experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files/main_poster_IMSC2019.py similarity index 100% rename from experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files/main_poster.py rename to experiment/meteo_france_data/scm_models_data/visualization/hypercube_visualization/main_files/main_poster_IMSC2019.py diff --git a/experiment/paper1_steps/poster_EVAN2019/__init__.py b/experiment/paper1_steps/poster_EVAN2019/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/experiment/paper1_steps/poster_EVAN2019/main_poster_EVAN2019.py b/experiment/paper1_steps/poster_EVAN2019/main_poster_EVAN2019.py new file mode 100644 index 0000000000000000000000000000000000000000..541c719a4398a2f08a0a56af22ffe89da2bcd106 --- /dev/null +++ b/experiment/paper1_steps/poster_EVAN2019/main_poster_EVAN2019.py @@ -0,0 +1,28 @@ +from experiment.meteo_france_data.scm_models_data.visualization.hypercube_visualization.altitude_year_hypercube_visualizer import \ + Altitude_Hypercube_Year_Visualizer +from experiment.trend_analysis.univariate_test.gev_trend_test_one_parameter import GevScaleTrendTest, \ + GevLocationTrendTest +from experiment.trend_analysis.univariate_test.gev_trend_test_two_parameters import GevLocationAndScaleTrendTest +from experiment.paper1_steps.utils import get_full_altitude_visualizer + +POSTER_ALTITUDES = [900, 1800, 2700] + + +def main_poster_A_non_stationary_model_choice(): + nb = 1 + for altitude in POSTER_ALTITUDES[:nb]: + for trend_test_class in [GevLocationTrendTest, GevScaleTrendTest, GevLocationAndScaleTrendTest][-nb:]: + vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude, + exact_starting_year=1958, reduce_strength_array=False, + trend_test_class=trend_test_class, + ) + # vizualiser.save_to_file = False + vizualiser.visualize_massif_trend_test_one_altitude(poster_plot=True, write_text_on_massif=False) + + +def main_poster_B_starting_years_analysis(): + pass + + +if __name__ == '__main__': + main_poster_A_non_stationary_model_choice() diff --git a/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py b/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py index 3456aac86812d32964b6b8ce4b4ce579dc4b11c0..b27320f7b12506816e16ea244c1fab807fea9485 100644 --- a/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py +++ b/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py @@ -26,8 +26,8 @@ class GevLocationTrendTest(GevTrendTestOneParameter): NonStationaryLocationStationModel, GevParams.LOC) def _slope_strength(self): - return self.non_stationary_constant_gev_params.quantile_strength_evolution_ratio(p=self.quantile_for_strength, - mu1=self.non_stationary_linear_coef) + return self.non_stationary_constant_gev_params.quantile_strength_evolution(p=self.quantile_for_strength, + mu1=self.non_stationary_linear_coef) class GevScaleTrendTest(GevTrendTestOneParameter): @@ -37,7 +37,7 @@ class GevScaleTrendTest(GevTrendTestOneParameter): NonStationaryScaleStationModel, GevParams.SCALE) def _slope_strength(self): - return self.non_stationary_constant_gev_params.quantile_strength_evolution_ratio( + return self.non_stationary_constant_gev_params.quantile_strength_evolution( p=self.quantile_for_strength, sigma1=self.non_stationary_linear_coef) diff --git a/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py b/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py index 2cae037828fc392ada133a8740c2503d29e1ce28..bbd2c8ef958d1c6fbd7f1fb5a8f30de69ed7b04e 100644 --- a/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py +++ b/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py @@ -20,6 +20,6 @@ class GevLocationAndScaleTrendTest(GevTrendTestTwoParameters): def _slope_strength(self): mu1 = self.get_non_stationary_linear_coef(gev_param_name=GevParams.LOC) sigma1 = self.get_non_stationary_linear_coef(gev_param_name=GevParams.SCALE) - return self.non_stationary_constant_gev_params.quantile_strength_evolution_ratio(p=self.quantile_for_strength, - mu1=mu1, - sigma1=sigma1) + return self.non_stationary_constant_gev_params.quantile_strength_evolution(p=self.quantile_for_strength, + mu1=mu1, + sigma1=sigma1) diff --git a/extreme_estimator/extreme_models/margin_model/margin_function/abstract_margin_function.py b/extreme_estimator/extreme_models/margin_model/margin_function/abstract_margin_function.py index 571507699fc16695f9bbc00f87566ac34acdab93..2115b1733c2571fb49dcaa65e67077ecb23c9b0b 100644 --- a/extreme_estimator/extreme_models/margin_model/margin_function/abstract_margin_function.py +++ b/extreme_estimator/extreme_models/margin_model/margin_function/abstract_margin_function.py @@ -166,7 +166,8 @@ class AbstractMarginFunction(object): ax = plt.gca() # Special display - imshow_shifted(ax, gev_param_name, self.grid_2D(temporal_step)[gev_param_name], self.visualization_extend, self.mask_2D) + imshow_shifted(ax, gev_param_name, self.grid_2D(temporal_step)[gev_param_name], self.visualization_extend, + self.mask_2D) # X axis ax.set_xlabel('coordinate X') @@ -215,7 +216,7 @@ class AbstractMarginFunction(object): grid.append(self.get_gev_params(np.array(coordinate)).summary_dict) grid = {value_name: np.array([g[value_name] for g in grid]).reshape( [self.VISUALIZATION_RESOLUTION, self.VISUALIZATION_RESOLUTION]) - for value_name in GevParams.SUMMARY_NAMES} + for value_name in GevParams.SUMMARY_NAMES} return grid # Visualization 3D diff --git a/extreme_estimator/margin_fits/gev/gev_params.py b/extreme_estimator/margin_fits/gev/gev_params.py index 650d4dca019caf3f1ee1cbbf5506df12dc69f44f..88f48c55b9a738513a2f2c3181da15ec63b88912 100644 --- a/extreme_estimator/margin_fits/gev/gev_params.py +++ b/extreme_estimator/margin_fits/gev/gev_params.py @@ -45,22 +45,21 @@ class GevParams(ExtremeParams): def __str__(self): return self.to_dict().__str__() - def quantile_strength_evolution_ratio(self, p=0.99, mu1=0.0, sigma1=0.0): + def quantile_strength_evolution(self, p=0.99, mu1=0.0, sigma1=0.0): """ - Compute the relative evolution of some quantile with respect to time. + Compute the variation of some quantile with respect to time. (when mu1 and sigma1 can be modified with time) :param p: level of the quantile :param mu1: temporal slope of the location parameter :param sigma1: temporal slope of the scale parameter - :return: A string summarizing the evolution ratio + :return: A float that equals evolution ratio """ - initial_quantile = self.quantile(p) - quantity_increased = mu1 + quantile_annual_variation = mu1 if sigma1 != 0: power = np.float_power(- np.log(p), -self.shape) - quantity_increased -= (sigma1 / self.shape) * (1 - power) - return quantity_increased / initial_quantile + quantile_annual_variation -= (sigma1 / self.shape) * (1 - power) + return quantile_annual_variation # Compute some indicators (such as the mean and the variance)