diff --git a/experiment/paper 2 - contrasting/main_spatial_relative_change_in_maxima_at_fixed_altitude.py b/experiment/paper 2 - contrasting/main_spatial_relative_change_in_maxima_at_fixed_altitude.py index b2c1c40640f2d9a7c04cd88eb5b6c0232d4194be..d98427cc1cda9ab703df1721ee83ab966f49677c 100644 --- a/experiment/paper 2 - contrasting/main_spatial_relative_change_in_maxima_at_fixed_altitude.py +++ b/experiment/paper 2 - contrasting/main_spatial_relative_change_in_maxima_at_fixed_altitude.py @@ -16,50 +16,54 @@ from experiment.paper_past_snow_loads.discussion_data_comparison_with_eurocode.c from experiment.paper_past_snow_loads.paper_utils import dpi_paper1_figure -def density_wrt_altitude(): - """ - We choose these massif because each represents a different eurocode region - we also choose them because they belong to a different climatic area - :return: - """ - save_to_file = False - study_class = [SafranTotalPrecip, SafranRainfall, SafranSnowfall, CrocusSnowLoad3Days, CrocusSnowLoadTotal][0] - # altitudes = [900, 1200, 1500, 1800, 2100, 2400, 2700, 3000][::-1] - altitudes = ALL_ALTITUDES_WITHOUT_NAN[1:] - altitudes = [900] +def test(): + study = CrocusSnowLoad3Days(altitude=1200) + study_visualizer = StudyVisualizer(study) + study_visualizer.visualize_max_graphs_poster('Queyras', altitude='noope', snow_abbreviation="ok", color='red') + plt.show() +def density_wrt_altitude(): + save_to_file = True + study_class = [SafranTotalPrecip, SafranRainfall, SafranSnowfall, CrocusSnowLoad3Days, CrocusSnowLoadTotal][-2] + altitudes = [900, 1200, 1500, 1800, 2100, 2400, 2700, 3000][::-1] for altitude in altitudes: ax = plt.gca() - study = study_class(altitude=altitude, nb_consecutive_days=3) + study = study_class(altitude=altitude) + # study = study_class(altitude=altitude, nb_consecutive_days=3) massif_name_to_value = {} for massif_name in study.study_massif_names: - s = study.observations_summer_annual_maxima.df_maxima_gev.loc[massif_name] + s = study.observations_annual_maxima.df_maxima_gev.loc[massif_name] year_limit = 1987 - print(s) - df_before, df_after = s.loc[:year_limit], s.loc[year_limit+1:] - print(df_before, df_after) - + df_before, df_after = s.loc[:year_limit], s.loc[year_limit + 1:] + # df_before, df_after = df_before.mean(), df_after.mean() df_before, df_after = df_before.median(), df_after.median() relative_change_value = 100 * (df_after - df_before) / df_before massif_name_to_value[massif_name] = relative_change_value print(massif_name_to_value) - # Plot # massif_name_to_value = {m: i for i, m in enumerate(study.study_massif_names)} max_values = max([abs(e) for e in massif_name_to_value.values()]) + 5 print(max_values) + variable_name = study.variable_name study.visualize_study(ax=ax, massif_name_to_value=massif_name_to_value, vmin=-max_values, vmax=max_values, add_colorbar=True, replace_blue_by_white=False, - label='Relative changes for \n{}\n at {}m (%)'.format(study.variable_name, study.altitude) + show=False, + label='Relative changes in mean annual maxima\n' + 'of {}\n between 1958-1987 and 1988-2017\n at {}m (%)\n' + ''.format(variable_name, study.altitude) ) - plt.show() + study_visualizer = StudyVisualizer(study, save_to_file=save_to_file) + study_visualizer.plot_name = 'relative_changes_in_maxima' + study_visualizer.show_or_save_to_file() ax.clear() + plt.close() if __name__ == '__main__': density_wrt_altitude() + # test()