Commit 02e456ca authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[TREND ANALYSIS] add tdlr map with markers on it

parent 80137755
No related merge requests found
Showing with 27 additions and 15 deletions
+27 -15
......@@ -304,6 +304,7 @@ class AbstractStudy(object):
axis_off=False,
massif_name_to_hatch_boolean_list=None,
norm=None,
massif_name_to_marker_style=None,
):
if ax is None:
ax = plt.gca()
......@@ -323,6 +324,7 @@ class AbstractStudy(object):
massif_name_to_fill_kwargs = {massif_name: {'color': color} for massif_name, color in
massif_name_to_color.items()}
massif_names = list(massif_name_to_fill_kwargs.keys())
masssif_coordinate_for_display = cls.massifs_coordinates_for_display(massif_names)
for coordinate_id, coords_list in cls.idx_to_coords_list.items():
# Retrieve the list of coords (x,y) that define the contour of the massif of id coordinate_id
......@@ -337,6 +339,13 @@ class AbstractStudy(object):
# Potentially, fill the inside of the polygon with some color
if fill and coordinate_id in cls.coordinate_id_to_massif_name:
massif_name = cls.coordinate_id_to_massif_name[coordinate_id]
if massif_name in massif_name_to_marker_style:
massif_coordinate = masssif_coordinate_for_display.df_all_coordinates.loc[massif_name, :].values
if massif_name in ['Maurienne', 'Mercantour']:
massif_coordinate[1] -= 5000
ax.plot(massif_coordinate[0],
massif_coordinate[1], **massif_name_to_marker_style[massif_name])
if massif_name_to_fill_kwargs is not None and massif_name in massif_name_to_fill_kwargs:
fill_kwargs = massif_name_to_fill_kwargs[massif_name]
ax.fill(*coords_list, **fill_kwargs)
......@@ -354,11 +363,7 @@ class AbstractStudy(object):
# if is_hatch:
# ax.add_patch(Polygon(xy=a, fill=False, hatch=hatch))
# Display the center of the massif
masssif_coordinate_for_display = cls.massifs_coordinates_for_display(massif_names)
ax.scatter(masssif_coordinate_for_display.x_coordinates,
masssif_coordinate_for_display.y_coordinates, s=1)
if show_label:
# Improve some explanation on the X axis and on the Y axis
ax.set_xlabel('Longitude (km)')
......
......@@ -25,6 +25,7 @@ class StudyVisualizerForNonStationaryTrends(StudyVisualizer):
transformation_class, verbose, multiprocessing, complete_non_stationary_trend_analysis,
normalization_under_one_observations, score_class)
self.non_stationary_trend_test = [GevLocationTrendTest, GevScaleTrendTest, GevLocationAndScaleTrendTest]
self.non_stationary_trend_test_to_marker = dict(zip(self.non_stationary_trend_test, ["s", "^", "D"]))
# Utils
......@@ -64,27 +65,33 @@ class StudyVisualizerForNonStationaryTrends(StudyVisualizer):
def plot_trends(self):
v = max(abs(min(self.massif_name_to_tdrl_value.values())), max(self.massif_name_to_tdrl_value.values()))
vmin, vmax = -v, v
vmin, vmax = -v, v
self.study.visualize_study(massif_name_to_value=self.massif_name_to_tdrl_value, vmin=vmin, vmax=vmax,
replace_blue_by_white=False, axis_off=True, show_label=False,
add_colorbar=True)
add_colorbar=True,
massif_name_to_marker_style=self.massif_name_to_marker_style)
@cached_property
def massif_name_to_tdrl_value(self):
return {m: t.time_derivative_of_return_level for m, t in self.massif_name_to_minimized_aic_non_stationary_trend_test.items()}
return {m: t.time_derivative_of_return_level for m, t in
self.massif_name_to_minimized_aic_non_stationary_trend_test.items()}
@property
def massif_name_to_minimized_aic_model_class(self):
return {m: t.unconstrained_model_class for m, t in self.massif_name_to_minimized_aic_non_stationary_trend_test.items()}
@property
def massif_name_to_model_significance_symbol(self):
return {}
def massif_name_to_marker_style(self):
d = {}
for m, t in self.massif_name_to_minimized_aic_non_stationary_trend_test.items():
d[m] = {'marker': self.non_stationary_trend_test_to_marker[type(t)],
'color': 'k',
'markersize': 5,
'fillstyle': 'full' if t.is_significant else 'none'}
return d
# Part 1 - Uncertainty return level plot
@property
def massif_name_to_minimized_aic_model_class(self):
return {m: t.unconstrained_model_class for m, t in
self.massif_name_to_minimized_aic_non_stationary_trend_test.items()}
def massif_name_to_uncertainty(self):
pass
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