Commit 51052c8f authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[HYPERCUBE] add df_hypercube_trend_nllh as attribute to the hypercube

parent 41929604
No related merge requests found
Showing with 15 additions and 8 deletions
+15 -8
...@@ -62,15 +62,22 @@ class AbstractHypercubeVisualizer(object): ...@@ -62,15 +62,22 @@ class AbstractHypercubeVisualizer(object):
self.nb_data_for_fast_mode) self.nb_data_for_fast_mode)
for study_visualizer in self.tuple_to_study_visualizer.values()] for study_visualizer in self.tuple_to_study_visualizer.values()]
def _df_hypercube_trend_meta(self, idx) -> pd.DataFrame:
df_spatio_temporal_trend_strength = [e[idx] for e in self.df_trends_spatio_temporal]
return pd.concat(df_spatio_temporal_trend_strength, keys=list(self.tuple_to_study_visualizer.keys()), axis=0)
@cached_property @cached_property
def df_hypercube_trend_type(self) -> pd.DataFrame: def df_hypercube_trend_type(self) -> pd.DataFrame:
df_spatio_temporal_trend_types = [e[0] for e in self.df_trends_spatio_temporal] return self._df_hypercube_trend_meta(idx=0
return pd.concat(df_spatio_temporal_trend_types, keys=list(self.tuple_to_study_visualizer.keys()), axis=0) )
@cached_property @cached_property
def df_hypercube_trend_strength(self) -> pd.DataFrame: def df_hypercube_trend_strength(self) -> pd.DataFrame:
df_spatio_temporal_trend_strength = [e[1] for e in self.df_trends_spatio_temporal] return self._df_hypercube_trend_meta(idx=1)
return pd.concat(df_spatio_temporal_trend_strength, keys=list(self.tuple_to_study_visualizer.keys()), axis=0)
@cached_property
def df_hypercube_trend_nllh(self) -> pd.DataFrame:
return self._df_hypercube_trend_meta(idx=2)
# Some properties # Some properties
......
...@@ -444,11 +444,11 @@ class StudyVisualizer(VisualizationParameters): ...@@ -444,11 +444,11 @@ class StudyVisualizer(VisualizationParameters):
nb_massif_for_change_point_test) nb_massif_for_change_point_test)
for massif_name, gev_change_point_test_results in massif_name_to_gev_change_point_test_results.items(): for massif_name, gev_change_point_test_results in massif_name_to_gev_change_point_test_results.items():
trend_test_res, best_idxs = gev_change_point_test_results trend_test_res, best_idxs = gev_change_point_test_results
trend_test_res = [(a, b) if i in best_idxs else (np.nan, np.nan) trend_test_res = [(a, b, c) if i in best_idxs else (np.nan, np.nan, c)
for i, (a, b, *_) in enumerate(trend_test_res)] for i, (a, b, c, *_) in enumerate(trend_test_res)]
massif_name_to_trend_res[massif_name] = list(zip(*trend_test_res)) massif_name_to_trend_res[massif_name] = list(zip(*trend_test_res))
nb_res = len(list(massif_name_to_trend_res.values())[0]) nb_res = len(list(massif_name_to_trend_res.values())[0])
assert nb_res == 2 assert nb_res == 3
all_massif_name_to_res = [{k: v[idx_res] for k, v in massif_name_to_trend_res.items()} all_massif_name_to_res = [{k: v[idx_res] for k, v in massif_name_to_trend_res.items()}
for idx_res in range(nb_res)] for idx_res in range(nb_res)]
return [pd.DataFrame(massif_name_to_res, index=self.starting_years_for_change_point_test).transpose() return [pd.DataFrame(massif_name_to_res, index=self.starting_years_for_change_point_test).transpose()
......
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