diff --git a/experiment/meteo_france_SCM_study/crocus/crocus.py b/experiment/meteo_france_SCM_study/crocus/crocus.py index c68a04fbf6b7c68a8f821a1d80ad8ba9ad72bdc0..b14c2fdb0d09c1d23d3ab41ab6ee5044a601d40d 100644 --- a/experiment/meteo_france_SCM_study/crocus/crocus.py +++ b/experiment/meteo_france_SCM_study/crocus/crocus.py @@ -37,7 +37,7 @@ class ExtendedCrocusDepth(AbstractExtendedStudy, CrocusDepth): if __name__ == '__main__': for variable_class in [CrocusSweVariable, CrocusDepthVariable]: study = Crocus(variable_class=variable_class) - # d = study.year_to_dataset_ordered_dict[1960] + d = study.year_to_dataset_ordered_dict[1960] # print(d) a = study.year_to_daily_time_serie[1960] print(a.shape) diff --git a/experiment/meteo_france_SCM_study/crocus/crocus_variables.py b/experiment/meteo_france_SCM_study/crocus/crocus_variables.py index 5ba0707ef3925da01d631a1352dd44621c425ff5..516221c9ea93bfea4062f99286eeec3019d863b7 100644 --- a/experiment/meteo_france_SCM_study/crocus/crocus_variables.py +++ b/experiment/meteo_france_SCM_study/crocus/crocus_variables.py @@ -19,6 +19,7 @@ class CrocusSweVariable(CrocusVariable): NAME = 'Snow Water Equivalent' def __init__(self, dataset): + # Units are kg m-2 super().__init__(dataset, 'SNOWSWE') @@ -26,4 +27,5 @@ class CrocusDepthVariable(CrocusVariable): NAME = 'Snow Depth' def __init__(self, dataset): + # Units are m super().__init__(dataset, "SNOWDEPTH") diff --git a/experiment/meteo_france_SCM_study/main_visualize.py b/experiment/meteo_france_SCM_study/main_visualize.py index 180ea81b399e266a14e7dda6a571d25c41eb54b6..e1a63c51a4dffb5c64f9fd4743713e8b3140f67a 100644 --- a/experiment/meteo_france_SCM_study/main_visualize.py +++ b/experiment/meteo_france_SCM_study/main_visualize.py @@ -33,11 +33,16 @@ def study_iterator(study_class, only_first_one=False, both_altitude=False, verbo def extended_visualization(): - for study_class in SCM_EXTENDED_STUDIES[:]: - for study in study_iterator(study_class, only_first_one=False): - study_visualizer = StudyVisualizer(study, single_massif_graph=True, save_to_file=True) + for study_class in SCM_EXTENDED_STUDIES[:1]: + for study in study_iterator(study_class, only_first_one=True): + study_visualizer = StudyVisualizer(study, only_first_row=True, save_to_file=False) # study_visualizer.visualize_all_kde_graphs() study_visualizer.visualize_all_experimental_law() + # for study_class in SCM_EXTENDED_STUDIES[:]: + # for study in study_iterator(study_class, only_first_one=False): + # study_visualizer = StudyVisualizer(study, single_massif_graph=True, save_to_file=True) + # # study_visualizer.visualize_all_kde_graphs() + # study_visualizer.visualize_all_experimental_law() def normal_visualization(): diff --git a/experiment/meteo_france_SCM_study/safran/safran_visualizer.py b/experiment/meteo_france_SCM_study/safran/safran_visualizer.py index 8e3b0f91783b48232848036f4cf77dc6bd8b52c8..6d0af70fed45db5614066d46cf23bd0c3c4a7e81 100644 --- a/experiment/meteo_france_SCM_study/safran/safran_visualizer.py +++ b/experiment/meteo_france_SCM_study/safran/safran_visualizer.py @@ -28,13 +28,19 @@ from utils import get_display_name_from_object_type, VERSION_TIME, float_to_str_ class StudyVisualizer(object): - def __init__(self, study: AbstractStudy, show=True, save_to_file=False, single_massif_graph=False): - self.single_massif_graph = single_massif_graph + def __init__(self, study: AbstractStudy, show=True, save_to_file=False, only_one_graph=False, only_first_row=False): + self.only_first_row = only_first_row + self.only_one_graph = only_one_graph self.save_to_file = save_to_file self.study = study self.show = False if self.save_to_file else show self.window_size_for_smoothing = 21 - self.figsize = (16.0, 10.0) + if self.only_one_graph: + self.figsize = (6.0, 4.0) + elif self.only_first_row: + self.figsize = (16.0, 6.0) + else: + self.figsize = (16.0, 10.0) @property def observations(self): @@ -51,18 +57,23 @@ class StudyVisualizer(object): # Graph for each massif / or groups of massifs def visualize_massif_graphs(self, visualize_function): - if self.single_massif_graph: + if self.only_one_graph: fig, ax = plt.subplots(1, 1, figsize=self.figsize) visualize_function(ax, 0) else: nb_columns = 5 - nb_rows = math.ceil(len(self.study.safran_massif_names) / nb_columns) + nb_rows = 1 if self.only_first_row else math.ceil(len(self.study.safran_massif_names) / nb_columns) fig, axes = plt.subplots(nb_rows, nb_columns, figsize=self.figsize) fig.subplots_adjust(hspace=1.0, wspace=1.0) - for massif_id, massif_name in enumerate(self.study.safran_massif_names): - row_id, column_id = massif_id // nb_columns, massif_id % nb_columns - ax = axes[row_id, column_id] - visualize_function(ax, massif_id) + if self.only_first_row: + for massif_id, massif_name in enumerate(self.study.safran_massif_names[:nb_columns]): + ax = axes[massif_id] + visualize_function(ax, massif_id) + else: + for massif_id, massif_name in enumerate(self.study.safran_massif_names): + row_id, column_id = massif_id // nb_columns, massif_id % nb_columns + ax = axes[row_id, column_id] + visualize_function(ax, massif_id) def visualize_all_experimental_law(self): self.visualize_massif_graphs(self.visualize_experimental_law) @@ -93,13 +104,15 @@ class StudyVisualizer(object): ax.scatter([xi], [yi], color=color, marker="o", label=name) ax.set_ylabel('Probability Density function f(x)', color=color_kde) - ax.set_xlabel('x = {}'.format(self.study.title)) + xlabel = 'x = {}'.format(self.study.title) if self.only_one_graph else 'x' + ax.set_xlabel(xlabel) extraticks = [float(float_to_str_with_only_some_significant_digits(x, nb_digits=2)) for x in sorted(list(x_level_to_color.keys()))] - if not self.single_massif_graph: + if not self.only_one_graph: extraticks = [extraticks[0], extraticks[-1]] ax.set_xticks(extraticks) - ax.set_title(self.study.safran_massif_names[massif_id]) + if not self.only_one_graph: + ax.set_title(self.study.safran_massif_names[massif_id]) ax.legend() def visualize_all_mean_and_max_graphs(self): @@ -160,11 +173,15 @@ class StudyVisualizer(object): def show_or_save_to_file(self, plot_name): title = self.study.title title += '\n' + plot_name - plt.suptitle(title) + if not self.only_one_graph: + plt.suptitle(title) if self.show: plt.show() if self.save_to_file: - filename = "{}/{}/{}".format(VERSION_TIME, '_'.join(self.study.title.split()), '_'.join(plot_name.split())) + filename = "{}/{}".format(VERSION_TIME, '_'.join(self.study.title.split())) + if not self.only_one_graph: + filename += "/{}".format('_'.join(plot_name.split())) + filepath = op.join(self.study.result_full_path, filename + '.png') dir = op.dirname(filepath) if not op.exists(dir):