Commit 437afc1d authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[POSTER EVAN] tight layout for the first part of the poster

parent 5b990dbc
No related merge requests found
Showing with 61 additions and 32 deletions
+61 -32
...@@ -267,6 +267,7 @@ class AbstractStudy(object): ...@@ -267,6 +267,7 @@ class AbstractStudy(object):
show_label=True, show_label=True,
scaled=False, scaled=False,
fontsize=7, fontsize=7,
axis_off=False,
): ):
if ax is None: if ax is None:
ax = plt.gca() ax = plt.gca()
...@@ -302,15 +303,6 @@ class AbstractStudy(object): ...@@ -302,15 +303,6 @@ class AbstractStudy(object):
else: else:
ax.fill(*coords_list, **{'color': default_color_for_missing_massif}) 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 # Display the center of the massif
masssif_coordinate_for_display = cls.massifs_coordinates_for_display(massif_names) masssif_coordinate_for_display = cls.massifs_coordinates_for_display(massif_names)
...@@ -338,6 +330,8 @@ class AbstractStudy(object): ...@@ -338,6 +330,8 @@ class AbstractStudy(object):
if scaled: if scaled:
plt.axis('scaled') plt.axis('scaled')
if axis_off:
plt.axis('off')
if show: if show:
plt.show() plt.show()
......
...@@ -283,7 +283,9 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -283,7 +283,9 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
return title return title
def visualize_trend_test_repartition_poster(self, reduction_function, axes=None, subtitle='', isin_parameters=None, 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 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()} self.trend_type_to_series(reduction_function, isin_parameters).items()}
...@@ -313,7 +315,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -313,7 +315,7 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
massif_to_strength.update(massif_to_value_for_trend_type[0]) massif_to_strength.update(massif_to_value_for_trend_type[0])
massif_to_constant.update(massif_to_value_for_trend_type[1]) massif_to_constant.update(massif_to_value_for_trend_type[1])
else: 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, self.trend_type_to_series(reduction_function,
isin_parameters)[ isin_parameters)[
display_trend_type][1].items() display_trend_type][1].items()
...@@ -330,11 +332,12 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -330,11 +332,12 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
else: else:
massif_name_to_value = massif_to_year massif_name_to_value = massif_to_year
self.study.visualize_study(None, massif_name_to_color=massif_to_color, show=False, 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, 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 return title
...@@ -459,15 +462,19 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer): ...@@ -459,15 +462,19 @@ class AltitudeHypercubeVisualizer(AbstractHypercubeVisualizer):
def visualize_massif_trend_test_one_altitude(self, axes=None, add_detailed_plots=False, plot_title=None, def visualize_massif_trend_test_one_altitude(self, axes=None, add_detailed_plots=False, plot_title=None,
isin_parameters=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 = '' last_title = ''
for subtitle, reduction_function in self.subtitle_to_reduction_function(self.index_reduction, for subtitle, reduction_function in self.subtitle_to_reduction_function(self.index_reduction,
level=self.massif_index_level, level=self.massif_index_level,
add_detailed_plot=add_detailed_plots).items(): add_detailed_plot=add_detailed_plots).items():
last_title = self.visualize_trend_test_repartition_poster(reduction_function, axes, subtitle=subtitle, last_title = self.visualize_trend_test_repartition_poster(reduction_function, axes, subtitle=subtitle,
isin_parameters=isin_parameters, 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: 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 return last_title
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()
...@@ -26,8 +26,8 @@ class GevLocationTrendTest(GevTrendTestOneParameter): ...@@ -26,8 +26,8 @@ class GevLocationTrendTest(GevTrendTestOneParameter):
NonStationaryLocationStationModel, GevParams.LOC) NonStationaryLocationStationModel, GevParams.LOC)
def _slope_strength(self): def _slope_strength(self):
return self.non_stationary_constant_gev_params.quantile_strength_evolution_ratio(p=self.quantile_for_strength, return self.non_stationary_constant_gev_params.quantile_strength_evolution(p=self.quantile_for_strength,
mu1=self.non_stationary_linear_coef) mu1=self.non_stationary_linear_coef)
class GevScaleTrendTest(GevTrendTestOneParameter): class GevScaleTrendTest(GevTrendTestOneParameter):
...@@ -37,7 +37,7 @@ class GevScaleTrendTest(GevTrendTestOneParameter): ...@@ -37,7 +37,7 @@ class GevScaleTrendTest(GevTrendTestOneParameter):
NonStationaryScaleStationModel, GevParams.SCALE) NonStationaryScaleStationModel, GevParams.SCALE)
def _slope_strength(self): 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, p=self.quantile_for_strength,
sigma1=self.non_stationary_linear_coef) sigma1=self.non_stationary_linear_coef)
......
...@@ -20,6 +20,6 @@ class GevLocationAndScaleTrendTest(GevTrendTestTwoParameters): ...@@ -20,6 +20,6 @@ class GevLocationAndScaleTrendTest(GevTrendTestTwoParameters):
def _slope_strength(self): def _slope_strength(self):
mu1 = self.get_non_stationary_linear_coef(gev_param_name=GevParams.LOC) mu1 = self.get_non_stationary_linear_coef(gev_param_name=GevParams.LOC)
sigma1 = self.get_non_stationary_linear_coef(gev_param_name=GevParams.SCALE) 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, return self.non_stationary_constant_gev_params.quantile_strength_evolution(p=self.quantile_for_strength,
mu1=mu1, mu1=mu1,
sigma1=sigma1) sigma1=sigma1)
...@@ -166,7 +166,8 @@ class AbstractMarginFunction(object): ...@@ -166,7 +166,8 @@ class AbstractMarginFunction(object):
ax = plt.gca() ax = plt.gca()
# Special display # 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 # X axis
ax.set_xlabel('coordinate X') ax.set_xlabel('coordinate X')
...@@ -215,7 +216,7 @@ class AbstractMarginFunction(object): ...@@ -215,7 +216,7 @@ class AbstractMarginFunction(object):
grid.append(self.get_gev_params(np.array(coordinate)).summary_dict) grid.append(self.get_gev_params(np.array(coordinate)).summary_dict)
grid = {value_name: np.array([g[value_name] for g in grid]).reshape( grid = {value_name: np.array([g[value_name] for g in grid]).reshape(
[self.VISUALIZATION_RESOLUTION, self.VISUALIZATION_RESOLUTION]) [self.VISUALIZATION_RESOLUTION, self.VISUALIZATION_RESOLUTION])
for value_name in GevParams.SUMMARY_NAMES} for value_name in GevParams.SUMMARY_NAMES}
return grid return grid
# Visualization 3D # Visualization 3D
......
...@@ -45,22 +45,21 @@ class GevParams(ExtremeParams): ...@@ -45,22 +45,21 @@ class GevParams(ExtremeParams):
def __str__(self): def __str__(self):
return self.to_dict().__str__() 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) (when mu1 and sigma1 can be modified with time)
:param p: level of the quantile :param p: level of the quantile
:param mu1: temporal slope of the location parameter :param mu1: temporal slope of the location parameter
:param sigma1: temporal slope of the scale 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) quantile_annual_variation = mu1
quantity_increased = mu1
if sigma1 != 0: if sigma1 != 0:
power = np.float_power(- np.log(p), -self.shape) power = np.float_power(- np.log(p), -self.shape)
quantity_increased -= (sigma1 / self.shape) * (1 - power) quantile_annual_variation -= (sigma1 / self.shape) * (1 - power)
return quantity_increased / initial_quantile return quantile_annual_variation
# Compute some indicators (such as the mean and the variance) # Compute some indicators (such as the mean and the variance)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment