diff --git a/extreme_data/meteo_france_data/scm_models_data/abstract_study.py b/extreme_data/meteo_france_data/scm_models_data/abstract_study.py index 1f89b79e0e1b9e2b0bd9a5e487c751a4153ce0bd..d706fcf9a9b6eda9c7622f16d409302ea5b59019 100644 --- a/extreme_data/meteo_france_data/scm_models_data/abstract_study.py +++ b/extreme_data/meteo_france_data/scm_models_data/abstract_study.py @@ -340,10 +340,11 @@ class AbstractStudy(object): for year in self.ordered_years: # Check daily data daily_time_serie = self.year_to_variable_object[year].daily_time_serie_array + print(daily_time_serie.shape) assert daily_time_serie.shape[0] in [365, 366] assert daily_time_serie.shape[1] == len(self.column_mask) # Filter only the data corresponding: - # 1: to the start_index and last_index of the season + # 1: to treturnhe start_index and last_index of the season # 2: to the massifs for the altitude of interest first_index, last_index = self.year_to_first_index_and_last_index[year] daily_time_serie = daily_time_serie[first_index:last_index + 1, self.column_mask] diff --git a/extreme_data/meteo_france_data/scm_models_data/visualization/main_study_visualizer.py b/extreme_data/meteo_france_data/scm_models_data/visualization/main_study_visualizer.py index e8d68e3bda9c71da78e1bed1c3358c70b3356e5d..276d670676f387333afdfb7329c5e69352780c20 100644 --- a/extreme_data/meteo_france_data/scm_models_data/visualization/main_study_visualizer.py +++ b/extreme_data/meteo_france_data/scm_models_data/visualization/main_study_visualizer.py @@ -34,7 +34,7 @@ SCM_STUDIES_NAMES = [get_display_name_from_object_type(k) for k in SCM_STUDIES] SCM_STUDY_NAME_TO_SCM_STUDY = dict(zip(SCM_STUDIES_NAMES, SCM_STUDIES)) SCM_STUDY_CLASS_TO_ABBREVIATION = { SafranSnowfall: 'SF3', - SafranSnowfall1Day: 'SF1', + SafranSnowfall1Day: 'daily snowfall', SafranSnowfall3Days: 'SF3', SafranSnowfall5Days: 'SF5', SafranSnowfall7Days: 'SF7', diff --git a/projects/altitude_spatial_model/altitudes_fit/altitudes_studies.py b/projects/altitude_spatial_model/altitudes_fit/altitudes_studies.py index 73dda0cc9fcec446f8c911b1d38a015c0d36480e..22ee2cec4fe96e964ac06b0cc09ca2e97753af15 100644 --- a/projects/altitude_spatial_model/altitudes_fit/altitudes_studies.py +++ b/projects/altitude_spatial_model/altitudes_fit/altitudes_studies.py @@ -140,7 +140,7 @@ class AltitudesStudies(object): ax.legend(handles[::-1], labels[::-1]) plot_name = 'Annual maxima of {} in {}'.format(SCM_STUDY_CLASS_TO_ABBREVIATION[self.study_class], massif_name.replace('_', ' ')) - # ax.set_ylabel('{} ({})'.format(plot_name, self.study.variable_unit), fontsize=15) + ax.set_ylabel('{} ({})'.format(plot_name, self.study.variable_unit), fontsize=15) # ax.set_xlabel('years', fontsize=15) plot_name = 'time series/' + plot_name self.show_or_save_to_file(plot_name=plot_name, show=show, no_title=True, tight_layout=True) diff --git a/projects/altitude_spatial_model/altitudes_fit/main_altitudes_studies.py b/projects/altitude_spatial_model/altitudes_fit/main_altitudes_studies.py index 5b66f6d2ab4796c4712f99d686bfd5c0463fea79..e82328e34e99a991840e60d5523dd5478165e484 100644 --- a/projects/altitude_spatial_model/altitudes_fit/main_altitudes_studies.py +++ b/projects/altitude_spatial_model/altitudes_fit/main_altitudes_studies.py @@ -55,9 +55,9 @@ def main_loop(altitudes_list, massif_names, seasons, study_classes): def plot_visualizers(massif_names, visualizer_list): - plot_histogram_all_trends_against_altitudes(massif_names, visualizer_list) - # for relative in [True, False]: - # plot_shoe_plot_changes_against_altitude(massif_names, visualizer_list, relative=relative) + # plot_histogram_all_trends_against_altitudes(massif_names, visualizer_list) + for relative in [True, False]: + plot_shoe_plot_changes_against_altitude(massif_names, visualizer_list, relative=relative) # plot_coherence_curves(massif_names, visualizer_list) pass @@ -70,7 +70,7 @@ def plot_visualizer(massif_names, visualizer): # for change in [True, False, None]: # studies.plot_mean_maxima_against_altitude(massif_names=massif_names, std=std, change=change) # 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) pass diff --git a/projects/altitude_spatial_model/altitudes_fit/plots/plot_coherence_curves.py b/projects/altitude_spatial_model/altitudes_fit/plots/plot_coherence_curves.py index ad63c7f812bbe768b66999384d4438200901e437..73c371d3b328167e5da4fc8cbef1fe1331b1fe3a 100644 --- a/projects/altitude_spatial_model/altitudes_fit/plots/plot_coherence_curves.py +++ b/projects/altitude_spatial_model/altitudes_fit/plots/plot_coherence_curves.py @@ -15,7 +15,7 @@ def plot_coherence_curves(massif_names, visualizer_list: List[AltitudesStudiesVi for massif_name in all_valid_names: # For plotting the legend - legend = False + legend = True if legend: ax = plt.gca() axes = [ax for _ in range(4)] @@ -27,7 +27,7 @@ def plot_coherence_curves(massif_names, visualizer_list: List[AltitudesStudiesVi ax.set_yticks([]) axes = [ax if i % 2 == 0 else ax.twinx() for i, ax in enumerate(axes)] colors = ['blue', 'yellow', 'green'] - labels = ['Elevational-temporal model in 2019', 'Elevational-temporal model in 1969', 'Stationary distribution'] + labels = ['Elevational-temporal model in 2019', 'Elevational-temporal model in 1969', 'Pointwise distribution'] altitudinal_model = [True, True, False] years = [2019, 1969, None] for color, global_label, boolean, year in list(zip(colors, labels, altitudinal_model, years))[::2]: @@ -53,12 +53,12 @@ def plot_coherence_curve(axes, massif_name, visualizer_list: List[AltitudesStudi label_plot = global_label if j == 0 else None if is_altitudinal: if legend and legend_line: - ax.plot(x_list, value_list_i, linestyle='solid', color=color, label=label_plot) + ax.plot(x_list, value_list_i, linestyle='solid', color=color, label=label_plot, linewidth=5) else: ax.plot(x_list, value_list_i, linestyle='solid', color=color) else: if legend and legend_line: - ax.plot(x_list, value_list_i, linestyle='None', color=color, label=label_plot, marker='o') + ax.plot(x_list, value_list_i, linestyle='None', color=color, label=label_plot, marker='o', markersize=10) else: ax.plot(x_list, value_list_i, linestyle='None', color=color, marker='o') ax.plot(x_list, value_list_i, linestyle='dotted', color=color) @@ -77,7 +77,7 @@ def plot_coherence_curve(axes, massif_name, visualizer_list: List[AltitudesStudi if len(bounds) > 0: lower_bound, upper_bound = bounds if legend and not legend_line: - model_name = 'elevational-temporal model' if is_altitudinal else 'stationary distribution' + model_name = 'elevational-temporal model' if is_altitudinal else 'pointwise distribution' fill_label = "95\% confidence interval for the {}".format(model_name) if j == 0 else None ax.fill_between(x_list, lower_bound, upper_bound, color=color, alpha=0.2, label=fill_label) else: @@ -86,7 +86,7 @@ def plot_coherence_curve(axes, massif_name, visualizer_list: List[AltitudesStudi if is_altitudinal: min, max = ax.get_ylim() ax.set_ylim([min, 2 * max]) - size = 17 if legend_line else 11 + size = 15 if legend_line else 11 ax.legend(prop={'size': size}) ax.set_ylabel(label) diff --git a/projects/altitude_spatial_model/altitudes_fit/plots/plot_histogram_altitude_studies.py b/projects/altitude_spatial_model/altitudes_fit/plots/plot_histogram_altitude_studies.py index 7967c27be501cfed14923512931b8ea8a914e3f3..b49429882bcafcb7df591790caad083a8e1d8af7 100644 --- a/projects/altitude_spatial_model/altitudes_fit/plots/plot_histogram_altitude_studies.py +++ b/projects/altitude_spatial_model/altitudes_fit/plots/plot_histogram_altitude_studies.py @@ -122,7 +122,7 @@ def plot_shoe_plot_changes_against_altitude(massif_names, visualizer_list: List[ all_changes = [v.all_changes(massif_names, relative=relative) for v in visualizer_list] all_changes = list(zip(*all_changes)) - labels = ['All models', 'Non-stationary models', 'Non-stationary and significant models'] + labels = ['All models', 'Temporally non-stationary models', 'Temporally non-stationary models which are significant'] colors = ['darkgreen', 'forestgreen', 'limegreen'] nb_massifs = [len(v.get_valid_names(massif_names)) for v in visualizer_list] @@ -151,7 +151,7 @@ def plot_shoe_plot_changes_against_altitude(massif_names, visualizer_list: List[ ax.set_ylabel('{} of {}-year return levels between 1969 and 2019 ({})'.format(start, OneFoldFit.return_period, unit), fontsize=legend_fontsize) - ax.set_xlabel('Elevation', fontsize=legend_fontsize) + ax.set_xlabel('Elevation', fontsize=legend_fontsize + 5) ax.tick_params(axis='both', which='major', labelsize=labelsize) ax.set_xticks(x) ax.yaxis.grid() diff --git a/projects/altitude_spatial_model/preliminary_analysis.py b/projects/altitude_spatial_model/preliminary_analysis.py index f22563203b39c953d0f8e3f3e695fbfea36f4ae2..b8e540757969378065c2ca9d71ef4328b7d1037f 100644 --- a/projects/altitude_spatial_model/preliminary_analysis.py +++ b/projects/altitude_spatial_model/preliminary_analysis.py @@ -22,7 +22,11 @@ class PointwiseGevStudyVisualizer(AltitudesStudies): self.altitudes_for_temporal_hypothesis = [600, 1500, 2400, 3300] def plot_gev_params_against_altitude(self): - for j, param_name in enumerate(GevParams.PARAM_NAMES + [100]): + legend = True + param_names = GevParams.PARAM_NAMES + [100] + if legend: + param_names = param_names[:1] + for j, param_name in enumerate(param_names): ax = plt.gca() massif_name_to_linear_coef = {} @@ -41,8 +45,6 @@ class PointwiseGevStudyVisualizer(AltitudesStudies): fontsize_label = 15 ax.tick_params(labelsize=fontsize_label) - # ax.set_xlabel('Altitude') - # Compute the y label if param_name in GevParams.PARAM_NAMES: ylabel = GevParams.full_name_from_param_name(param_name) + ' parameter' @@ -75,11 +77,14 @@ class PointwiseGevStudyVisualizer(AltitudesStudies): plot_name = '{} change with altitude'.format(param_name) # # Display the legend - # ax.legend(labelspacing=2.5, ncol=8, handlelength=12, markerscale=0.7, bbox_to_anchor=(1.05, 1), loc='upper left', - # prop={'size': 2}, fontsize='x-large') - # plt.gcf().subplots_adjust(right=0.15) - # ax.set_yticks([]) - # ax.set_ylabel('') + if legend: + # ax.legend(labelspacing=2.5, ncol=8, handlelength=12, markerscale=0.7, bbox_to_anchor=(1.05, 1), loc='upper left', + # prop={'size': 2}, fontsize='x-large') + ax.legend(labelspacing=2.5, ncol=8, handlelength=10, markerscale=0.7, bbox_to_anchor=(1.05, 1), loc='upper left', + prop={'size': 2}, fontsize='xx-large') + plt.gcf().subplots_adjust(right=0.15) + ax.set_yticks([]) + ax.set_ylabel('') # plt.show() self.show_or_save_to_file(plot_name, no_title=True, tight_layout=tight_layout, show=False)