Commit f662f7b9 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[SCM] fix vertical plot of kde to take into acccount latest improvement

parent 63d9d31f
No related merge requests found
Showing with 14 additions and 10 deletions
+14 -10
...@@ -19,13 +19,13 @@ from utils import get_full_path, cached_property ...@@ -19,13 +19,13 @@ from utils import get_full_path, cached_property
class AbstractStudy(object): class AbstractStudy(object):
ALTITUDES = [1800, 2400] ALTITUDES = [1800, 2400]
def __init__(self, variable_class, altitude=1800): def __init__(self, variable_class: type, altitude: int = 1800):
assert altitude in self.ALTITUDES assert altitude in self.ALTITUDES
self.altitude = altitude self.altitude = altitude
self.model_name = None self.model_name = None
self.variable_class = variable_class self.variable_class = variable_class
def write_to_file(self, df): def write_to_file(self, df: pd.DataFrame):
if not op.exists(self.result_full_path): if not op.exists(self.result_full_path):
os.makedirs(self.result_full_path, exist_ok=True) os.makedirs(self.result_full_path, exist_ok=True)
df.to_csv(op.join(self.result_full_path, 'merged_array_{}_altitude.csv'.format(self.altitude))) df.to_csv(op.join(self.result_full_path, 'merged_array_{}_altitude.csv'.format(self.altitude)))
...@@ -82,7 +82,7 @@ class AbstractStudy(object): ...@@ -82,7 +82,7 @@ class AbstractStudy(object):
return year_to_daily_time_serie return year_to_daily_time_serie
@property @property
def _year_to_max_daily_time_serie(self): def _year_to_max_daily_time_serie(self) -> OrderedDict:
return self._year_to_daily_time_serie return self._year_to_daily_time_serie
########## ##########
...@@ -92,7 +92,7 @@ class AbstractStudy(object): ...@@ -92,7 +92,7 @@ class AbstractStudy(object):
return self.original_safran_massif_names return self.original_safran_massif_names
@property @property
def original_safran_massif_names(self): def original_safran_massif_names(self) -> List[str]:
# Load the names of the massif as defined by SAFRAN # Load the names of the massif as defined by SAFRAN
return safran_massif_names_from_datasets(list(self.year_to_dataset_ordered_dict.values()), self.altitude) return safran_massif_names_from_datasets(list(self.year_to_dataset_ordered_dict.values()), self.altitude)
......
...@@ -34,10 +34,10 @@ def study_iterator(study_class, only_first_one=False, both_altitude=False, verbo ...@@ -34,10 +34,10 @@ def study_iterator(study_class, only_first_one=False, both_altitude=False, verbo
def extended_visualization(): def extended_visualization():
save_to_file = True save_to_file = True
only_first_one = False only_first_one = True
for study_class in SCM_EXTENDED_STUDIES[:]: for study_class in SCM_EXTENDED_STUDIES[:1]:
for study in study_iterator(study_class, only_first_one=only_first_one): for study in study_iterator(study_class, only_first_one=only_first_one):
study_visualizer = StudyVisualizer(study, save_to_file=save_to_file, only_one_graph=True) study_visualizer = StudyVisualizer(study, save_to_file=save_to_file, only_one_graph=True, year_for_kde_plot=1958, vertical_kde_plot=True)
# study_visualizer.visualize_all_mean_and_max_graphs() # study_visualizer.visualize_all_mean_and_max_graphs()
study_visualizer.visualize_all_experimental_law() study_visualizer.visualize_all_experimental_law()
# for study_class in SCM_EXTENDED_STUDIES[:]: # for study_class in SCM_EXTENDED_STUDIES[:]:
......
...@@ -102,10 +102,14 @@ class StudyVisualizer(object): ...@@ -102,10 +102,14 @@ class StudyVisualizer(object):
all_massif_data = np.sort(all_massif_data) all_massif_data = np.sort(all_massif_data)
# Display an histogram on the background (with 100 bins, for visibility, and to check 0.9 quantiles) # Display an histogram on the background (with 100 bins, for visibility, and to check 0.9 quantiles)
ax2 = ax.twinx() ax2 = ax.twiny() if self.vertical_kde_plot else ax.twinx()
color_hist = 'k' color_hist = 'k'
ax2.hist(all_massif_data, bins=50, density=True, histtype='step', color=color_hist) orientation = "horizontal" if self.vertical_kde_plot else 'vertical'
ax2.set_ylabel('normalized histogram', color=color_hist) ax2.hist(all_massif_data, bins=50, density=True, histtype='step', color=color_hist, orientation=orientation)
label_function = ax2.set_xlabel if self.vertical_kde_plot else ax2.set_ylabel
# Do not display this label in the vertical plot
if not self.vertical_kde_plot:
label_function('normalized histogram', color=color_hist)
# Kde plot, and retrieve the data forming the line # Kde plot, and retrieve the data forming the line
color_kde = 'b' color_kde = 'b'
......
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