Commit 32ed5bef authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[contrasting] Final modifications for the plot for the v4 of the article

parent fe055eb7
No related merge requests found
Showing with 53 additions and 51 deletions
+53 -51
......@@ -10,7 +10,7 @@ from extreme_data.meteo_france_data.scm_models_data.safran.safran_max_snowf impo
SafranSnowfall2020
from projects.altitude_spatial_model.altitudes_fit.plots.plot_histogram_altitude_studies import \
plot_shoe_plot_changes_against_altitude, plot_histogram_all_trends_against_altitudes, \
plot_shoe_plot_ratio_interval_size_against_altitude
plot_shoe_plot_ratio_interval_size_against_altitude, plot_histogram_all_models_against_altitudes
from extreme_fit.model.result_from_model_fit.result_from_extremes.abstract_extract_eurocode_return_level import \
AbstractExtractEurocodeReturnLevel
......@@ -44,10 +44,10 @@ def main():
model_must_pass_the_test = False
AbstractExtractEurocodeReturnLevel.ALPHA_CONFIDENCE_INTERVAL_UNCERTAINTY = 0.2
fast = True
fast = False
if fast is None:
massif_names = ['Vanoise']
altitudes_list = altitudes_for_groups[:]
massif_names = None
altitudes_list = altitudes_for_groups[2:3]
elif fast:
AbstractExtractEurocodeReturnLevel.NB_BOOTSTRAP = 10
massif_names = ['Vanoise', 'Haute-Maurienne', 'Vercors'][:1]
......@@ -80,6 +80,7 @@ def main_loop(altitudes_list, massif_names, seasons, study_classes, model_must_p
def plot_visualizers(massif_names, visualizer_list):
plot_histogram_all_models_against_altitudes(massif_names, visualizer_list)
# plot_histogram_all_trends_against_altitudes(massif_names, visualizer_list)
# plot_shoe_plot_ratio_interval_size_against_altitude(massif_names, visualizer_list)
# for relative in [True, False]:
......@@ -95,7 +96,7 @@ def plot_visualizer(massif_names, visualizer):
# visualizer.studies.plot_maxima_time_series(['Vanoise'])
# Plot the results for the model that minimizes the individual aic
plot_individual_aic(visualizer)
# plot_individual_aic(visualizer)
# Plot the results for the model that minimizes the total aic
# plot_total_aic(model_classes, visualizer)
......
......@@ -517,13 +517,14 @@ class AltitudesStudiesVisualizerForNonStationaryModels(StudyVisualizer):
coordinate_for_filter = (altitude, None)
unconstrained_empirical_quantiles = one_fold_fit.best_estimator.sorted_empirical_standard_gumbel_quantiles(coordinate_for_filter=coordinate_for_filter)
n = len(unconstrained_empirical_quantiles)
assert n == 61
standard_gumbel_quantiles = one_fold_fit.standard_gumbel_quantiles(n=n)
ax.plot(standard_gumbel_quantiles, unconstrained_empirical_quantiles, linestyle='None',
label='{} m'.format(altitude), marker='o')
all_quantiles.extend(standard_gumbel_quantiles)
all_quantiles.extend(unconstrained_empirical_quantiles)
if n > 0:
assert n == 61
standard_gumbel_quantiles = one_fold_fit.standard_gumbel_quantiles(n=n)
ax.plot(standard_gumbel_quantiles, unconstrained_empirical_quantiles, linestyle='None',
label='{} m'.format(altitude), marker='o')
all_quantiles.extend(standard_gumbel_quantiles)
all_quantiles.extend(unconstrained_empirical_quantiles)
size_label = 20
ax.set_xlabel("Theoretical quantile", fontsize=size_label)
......
......@@ -14,7 +14,7 @@ from projects.exceeding_snow_loads.utils import dpi_paper1_figure
def plots(visualizer: AltitudesStudiesVisualizerForNonStationaryModels):
# visualizer.plot_shape_map()
visualizer.plot_shape_map()
# visualizer.plot_moments()
visualizer.plot_qqplots()
# for std in [True, False]:
......
......@@ -40,44 +40,44 @@ def plot_histogram_all_models_against_altitudes(massif_names, visualizer_list: L
print(model_name_to_mean_percentage[model_name], model_name_to_mean_percentage_significant[model_name],
model_name)
# Plot part
ax = plt.gca()
width = 5
size = 8
legend_fontsize = 10
labelsize = 10
linewidth = 1
tick_list = np.array([((len(visualizer_list) + 2) * i + (1 + len(visualizer_list) / 2)) * width
for i in range(len(sorted_model_names))])
for tick_middle, model_name in zip(tick_list, sorted_model_names):
x_shifted = [tick_middle + width * shift / 2 for shift in range(-3, 5, 2)]
percentages = model_name_to_percentages[model_name]
percentages_significant = model_name_to_percentages_significant[model_name]
colors = ['white', 'yellow', 'orange', 'red']
labels = ['{} m - {} m (\% out of {} massifs)'.format(1000 * i, 1000 * (i + 1),
len(v.get_valid_names(massif_names))) for i, v in
enumerate(visualizer_list)]
for x, color, percentage, label, percentage_significant in zip(x_shifted, colors, percentages, labels,
percentages_significant):
ax.bar([x], [percentage], width=width, label=label,
linewidth=2 * linewidth, edgecolor='black', color=color)
heights = list(range(0, math.ceil(percentage_significant), 1))[::-1]
for height in heights:
ax.bar([x], [height], width=width, linewidth=linewidth, edgecolor='black', color=color)
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles[:len(visualizer_list)], labels[:len(visualizer_list)], prop={'size': size})
ax.set_xticklabels(sorted_model_names)
ax.set_xticks(tick_list)
ax.set_ylabel('Percentage of massifs (\%) ', fontsize=legend_fontsize)
ax.set_xlabel('Models', fontsize=legend_fontsize)
ax.set_ylim(bottom=0)
ax.yaxis.grid()
ax.tick_params(axis='both', which='major', labelsize=labelsize)
visualizer.plot_name = 'All models'
visualizer.show_or_save_to_file(add_classic_title=False, no_title=True)
plt.close()
# # Plot part
# ax = plt.gca()
# width = 5
# size = 8
# legend_fontsize = 10
# labelsize = 10
# linewidth = 1
# tick_list = np.array([((len(visualizer_list) + 2) * i + (1 + len(visualizer_list) / 2)) * width
# for i in range(len(sorted_model_names))])
# for tick_middle, model_name in zip(tick_list, sorted_model_names):
# x_shifted = [tick_middle + width * shift / 2 for shift in range(-3, 5, 2)]
# percentages = model_name_to_percentages[model_name]
# percentages_significant = model_name_to_percentages_significant[model_name]
# colors = ['white', 'yellow', 'orange', 'red']
# labels = ['{} m - {} m (\% out of {} massifs)'.format(1000 * i, 1000 * (i + 1),
# len(v.get_valid_names(massif_names))) for i, v in
# enumerate(visualizer_list)]
# for x, color, percentage, label, percentage_significant in zip(x_shifted, colors, percentages, labels,
# percentages_significant):
# ax.bar([x], [percentage], width=width, label=label,
# linewidth=2 * linewidth, edgecolor='black', color=color)
# heights = list(range(0, math.ceil(percentage_significant), 1))[::-1]
# for height in heights:
# ax.bar([x], [height], width=width, linewidth=linewidth, edgecolor='black', color=color)
#
# handles, labels = ax.get_legend_handles_labels()
# ax.legend(handles[:len(visualizer_list)], labels[:len(visualizer_list)], prop={'size': size})
# ax.set_xticklabels(sorted_model_names)
# ax.set_xticks(tick_list)
# ax.set_ylabel('Percentage of massifs (\%) ', fontsize=legend_fontsize)
# ax.set_xlabel('Models', fontsize=legend_fontsize)
# ax.set_ylim(bottom=0)
# ax.yaxis.grid()
# ax.tick_params(axis='both', which='major', labelsize=labelsize)
#
# visualizer.plot_name = 'All models'
# visualizer.show_or_save_to_file(add_classic_title=False, no_title=True)
# plt.close()
def plot_histogram_all_trends_against_altitudes(massif_names, visualizer_list: List[
......
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