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 23f39bc536e37e814b1c063399e0e1ecf24b0c35..e773ac0f7bfaf80bb8c4331b12604c644b5331cb 100644 --- a/experiment/meteo_france_data/scm_models_data/abstract_study.py +++ b/experiment/meteo_france_data/scm_models_data/abstract_study.py @@ -296,7 +296,8 @@ class AbstractStudy(object): return AbstractSpatialCoordinates.from_df(df) @classmethod - def visualize_study(cls, ax=None, massif_name_to_value: Union[None, Dict[str, float]] = None, show=True, fill=True, + def visualize_study(cls, ax=None, massif_name_to_value: Union[None, Dict[str, float]] = None, + show=True, fill=True, replace_blue_by_white=True, label=None, add_text=False, cmap=None, add_colorbar=False, vmax=100, vmin=0, default_color_for_missing_massif='gainsboro', diff --git a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/main_study_visualizer.py b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/main_study_visualizer.py index 0e32a1e64b61a6f962fe07c9b7292d204025be2a..bc8a70583a36fab8274021a2c5450be36cc63781 100644 --- a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/main_study_visualizer.py +++ b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/main_study_visualizer.py @@ -36,7 +36,7 @@ SCM_STUDY_CLASS_TO_ABBREVIATION = { CrocusSwe3Days: 'SWE3', CrocusSnowLoadEurocode: 'GSL from annual maximum of HS and {}'.format(eurocode_snow_density), CrocusDepth: 'SD', - CrocusSnowLoadTotal: 'max GSL', + CrocusSnowLoadTotal: 'GSL', CrocusSnowLoad3Days: 'GSL3', CrocusSnowDensityAtMaxofSwe: '{} when the max of GSL \nis reached'.format(snow_density_str), CrocusDifferenceSnowLoadRescaledAndEurocodeToSeeSynchronization: 'max GSL rescaled - GSL from max HS \nboth with {}'.format(eurocode_snow_density), diff --git a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py index 484d0a5ac9376457670d3faa580367e0fa67ad91..132f14bb012af6f50debe5c1a2f1b3cb04771a3a 100644 --- a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py +++ b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py @@ -625,7 +625,9 @@ class StudyVisualizer(VisualizationParameters): self.plot_name = plot_name self.show_or_save_to_file() - def visualize_max_graphs_poster(self, massif_name, altitude, snow_abbreviation, color, label=None, last_plot=True, ax=None, linestyle=None, tight_pad=None): + def visualize_max_graphs_poster(self, massif_name, altitude, snow_abbreviation, color, + label=None, last_plot=True, ax=None, linestyle=None, + tight_pad=None, dpi=None): massif_names = self.study.study_massif_names # Display the graph of the max on top if ax is None: @@ -645,7 +647,9 @@ class StudyVisualizer(VisualizationParameters): if last_plot: ax.legend() - self.show_or_save_to_file(add_classic_title=False, no_title=True, tight_layout=True, tight_pad=tight_pad) + self.show_or_save_to_file(add_classic_title=False, no_title=True, + tight_layout=True, tight_pad=tight_pad, + dpi=dpi) ax.clear() @staticmethod @@ -812,7 +816,8 @@ class StudyVisualizer(VisualizationParameters): ax.get_yaxis().set_visible(False) ax.set_aspect('equal') - def show_or_save_to_file(self, add_classic_title=True, no_title=False, tight_layout=False, tight_pad=None): + def show_or_save_to_file(self, add_classic_title=True, no_title=False, tight_layout=False, tight_pad=None, + dpi=None): if tight_layout: if tight_pad is not None: plt.tight_layout(**tight_pad) @@ -836,15 +841,18 @@ class StudyVisualizer(VisualizationParameters): if not self.only_one_graph: filename += "{}".format('_'.join(self.plot_name.split())) + '_' filename += specific_title - self.savefig_in_results(filename) + self.savefig_in_results(filename, dpi=dpi) @classmethod - def savefig_in_results(cls, filename): + def savefig_in_results(cls, filename, dpi=None): filepath = op.join(AbstractStudy.result_full_path, filename + '.png') dirname = op.dirname(filepath) if not op.exists(dirname): os.makedirs(dirname, exist_ok=True) - plt.savefig(filepath) + if dpi is not None: + plt.savefig(filepath, dpi=dpi) + else: + plt.savefig(filepath) def visualize_independent_margin_fits(self, threshold=None, axes=None, show=True): # Fit either a GEV or a GPD diff --git a/experiment/paper_past_snow_loads/data/main_example_swe_total_plot.py b/experiment/paper_past_snow_loads/data/main_example_swe_total_plot.py index 934ec76bbeab4f050de1f801a5b9ee382e960036..f31f388fd0703400c2702e1dfd1ccd5e169f1e2e 100644 --- a/experiment/paper_past_snow_loads/data/main_example_swe_total_plot.py +++ b/experiment/paper_past_snow_loads/data/main_example_swe_total_plot.py @@ -33,7 +33,8 @@ def max_graph_annual_maxima_poster(): label = '{} massif at {}m'.format(massif_name, altitude) tight_pad = {'h_pad': 0.2} study_visualizer.visualize_max_graphs_poster(massif_name, altitude, snow_abbreviation, color, label, - last_plot, ax, tight_pad=tight_pad) + last_plot, ax, tight_pad=tight_pad, + dpi=1000) if __name__ == '__main__': diff --git a/experiment/paper_past_snow_loads/discussion_data_comparison_with_eurocode/main_comparison_with_eurocode.py b/experiment/paper_past_snow_loads/discussion_data_comparison_with_eurocode/main_comparison_with_eurocode.py index 154b27b53d2cb2b296958240ba64803936df0cfb..623d750c7eb683d707cebac6c00b2f4a80e22baf 100644 --- a/experiment/paper_past_snow_loads/discussion_data_comparison_with_eurocode/main_comparison_with_eurocode.py +++ b/experiment/paper_past_snow_loads/discussion_data_comparison_with_eurocode/main_comparison_with_eurocode.py @@ -60,7 +60,8 @@ def max_graph_annual_maxima_comparison(): ax.set_ylim(ylim) ax.set_xlim([1957, 2018]) ax.yaxis.set_ticks(yticks) - study_visualizer.show_or_save_to_file(no_title=True, tight_layout=True, tight_pad=tight_pad) + study_visualizer.show_or_save_to_file(no_title=True, tight_layout=True, + tight_pad=tight_pad, dpi=1000) ax.clear() diff --git a/experiment/paper_past_snow_loads/result_trends_and_return_levels/main_result_trends_and_return_levels.py b/experiment/paper_past_snow_loads/result_trends_and_return_levels/main_result_trends_and_return_levels.py index c2f4e0979f113e76384931803e8ce6da28799574..4e611d73ed45c711fb5c64daddabb44101470e0c 100644 --- a/experiment/paper_past_snow_loads/result_trends_and_return_levels/main_result_trends_and_return_levels.py +++ b/experiment/paper_past_snow_loads/result_trends_and_return_levels/main_result_trends_and_return_levels.py @@ -1,3 +1,5 @@ +from time import sleep + import matplotlib as mpl import matplotlib.pyplot as plt @@ -57,14 +59,17 @@ def major_result(): uncertainty_methods = [ConfidenceIntervalMethodFromExtremes.my_bayes, ConfidenceIntervalMethodFromExtremes.ci_mle][:] massif_names = None - non_stationary_uncertainty = [False, True][:] for study_class in paper_study_classes[:2]: + if study_class == CrocusSnowLoadEurocode: + non_stationary_uncertainty = [False] + else: + non_stationary_uncertainty = [False, True][:] intermediate_result(paper_altitudes, massif_names, non_stationary_uncertainty, uncertainty_methods, study_class) if __name__ == '__main__': # major_result() - intermediate_result(altitudes=[600, 900], massif_names=['Maurienne', 'Oisans'], + intermediate_result(altitudes=paper_altitudes, massif_names=['Maurienne'], uncertainty_methods=[ConfidenceIntervalMethodFromExtremes.my_bayes, ConfidenceIntervalMethodFromExtremes.ci_mle][:], non_stationary_uncertainty=[False, True][:]) diff --git a/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_curves.py b/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_curves.py index f1e759dfe45c0263d3e4c5a0dac7f8616261eb06..0e34087f8ab729561c3b4d9796849a5f282bc251 100644 --- a/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_curves.py +++ b/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_curves.py @@ -61,7 +61,7 @@ def plot_single_uncertainty_massif(altitude_to_visualizer: Dict[int, StudyVisual massif_names_str = massif_name model_names_str = 'NonStationarity={}'.format(non_stationary_context) visualizer.plot_name = model_names_str + '_' + massif_names_str - visualizer.show_or_save_to_file(no_title=True) + visualizer.show_or_save_to_file(no_title=True, dpi=1000) plt.close() @@ -104,6 +104,8 @@ def plot_single_uncertainty_massif_and_non_stationary_context(ax, massif_name, n ax.legend(loc=2) # ax.set_ylim([-1, 16]) + if massif_name == 'Maurienne': + ax.set_ylim([-1, 13]) massif_name_str = massif_name.replace('_', ' ') eurocode_region_str = get_display_name_from_object_type(type(eurocode_region)) is_non_stationary_model = non_stationary_context if isinstance(non_stationary_context, diff --git a/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_histogram.py b/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_histogram.py index 784b9afc611f48dc847b567f82583e747c135f7f..74b0cc004e3169a14d1e88a46dab4ce3d0366194 100644 --- a/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_histogram.py +++ b/experiment/paper_past_snow_loads/result_trends_and_return_levels/plot_uncertainty_histogram.py @@ -38,14 +38,14 @@ def plot_histogram(altitude_to_visualizer, non_stationary_context): width = 100 plot_histogram_ci_method(visualizers, non_stationary_context, ci_method, ax, bincenters, width=width) ax.set_xticks(altitudes) - ax.legend() + ax.legend(loc='upper left') ax.set_ylabel('Massifs exceeding French standards (\%)') ax.set_xlabel('Altitude (m)') ax.set_ylim([0, 100]) ax.set_yticks([10 * i for i in range(11)]) visualizer.plot_name = 'Percentages of exceedance with non_stationary={}'.format(non_stationary_context) # visualizer.show = True - visualizer.show_or_save_to_file(no_title=True) + visualizer.show_or_save_to_file(no_title=True, dpi=1000) ax.clear() diff --git a/experiment/paper_past_snow_loads/study_visualizer_for_non_stationary_trends.py b/experiment/paper_past_snow_loads/study_visualizer_for_non_stationary_trends.py index 5b9f4339a01c242bf657436504f6c4d1eeff11ce..35ee348eba695472bf1f1c6a9aed4df622607287 100644 --- a/experiment/paper_past_snow_loads/study_visualizer_for_non_stationary_trends.py +++ b/experiment/paper_past_snow_loads/study_visualizer_for_non_stationary_trends.py @@ -132,7 +132,8 @@ class StudyVisualizerForNonStationaryTrends(StudyVisualizer): ax.set_xlabel('Altitude = {}m'.format(self.study.altitude), fontsize=12) self.plot_name = 'tdlr_trends' - self.show_or_save_to_file(add_classic_title=False, tight_layout=True, no_title=True) + self.show_or_save_to_file(add_classic_title=False, tight_layout=True, no_title=True, + dpi=1000) plt.close() @property