Skip to content

Commit 09af3ae

Browse files
change keyword name and improve docstring descriptions
1 parent d256588 commit 09af3ae

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

climada/engine/impact.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ def plot_rp_imp(
11781178
return_periods=(25, 50, 100, 250),
11791179
log10_scale=True,
11801180
axis=None,
1181-
mask_relative_distance=None,
1181+
mask_distance=None,
11821182
kwargs_local_exceedance_impact=None,
11831183
**kwargs,
11841184
):
@@ -1195,10 +1195,10 @@ def plot_rp_imp(
11951195
plot impact as log10(impact). Default: True
11961196
smooth : bool, optional
11971197
smooth plot to plot.RESOLUTIONxplot.RESOLUTION. Default: True
1198-
mask_relative_distance: float, optional
1199-
Relative distance (with respect to maximal map extent in longitude or latitude) to data
1200-
points above which plot should not display values. For instance, to only plot values
1201-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
1198+
mask_distance: float, optional
1199+
Only regions are plotted that are closer to any of the data points than this distance,
1200+
relative to overall plot size. For instance, to only plot values
1201+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
12021202
Default is None.
12031203
kwargs_local_exceedance_impact: dict
12041204
Dictionary of keyword arguments for the method impact.local_exceedance_impact.
@@ -1252,7 +1252,7 @@ def plot_rp_imp(
12521252
title,
12531253
column_labels,
12541254
axis=axis,
1255-
mask_relative_distance=mask_relative_distance,
1255+
mask_distance=mask_distance,
12561256
**kwargs,
12571257
)
12581258
return axis, impacts_stats_vals

climada/hazard/plot.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def plot_rp_intensity(
4040
self,
4141
return_periods=(25, 50, 100, 250),
4242
axis=None,
43-
mask_relative_distance=None,
43+
mask_distance=None,
4444
kwargs_local_exceedance_intensity=None,
4545
**kwargs,
4646
):
@@ -57,10 +57,10 @@ def plot_rp_intensity(
5757
axis to use
5858
kwargs_local_exceedance_intensity: dict
5959
Dictionary of keyword arguments for the method hazard.local_exceedance_intensity.
60-
mask_relative_distance: float, optional
61-
Relative distance (with respect to maximal map extent in longitude or latitude) to data
62-
points above which plot should not display values. For instance, to only plot values
63-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
60+
mask_distance: float, optional
61+
Only regions are plotted that are closer to any of the data points than this distance,
62+
relative to overall plot size. For instance, to only plot values
63+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
6464
Default is None.
6565
kwargs: optional
6666
arguments for pcolormesh matplotlib function used in event plots
@@ -99,7 +99,7 @@ def plot_rp_intensity(
9999
title,
100100
column_labels,
101101
axis=axis,
102-
mask_relative_distance=mask_relative_distance,
102+
mask_distance=mask_distance,
103103
**kwargs,
104104
)
105105
return axis, inten_stats.values[:, 1:].T.astype(float)
@@ -111,7 +111,7 @@ def plot_intensity(
111111
smooth=True,
112112
axis=None,
113113
adapt_fontsize=True,
114-
mask_relative_distance=None,
114+
mask_distance=None,
115115
**kwargs,
116116
):
117117
"""Plot intensity values for a selected event or centroid.
@@ -135,10 +135,10 @@ def plot_intensity(
135135
in module `climada.util.plot`)
136136
axis: matplotlib.axes._subplots.AxesSubplot, optional
137137
axis to use
138-
mask_relative_distance: float, optional
139-
Relative distance (with respect to maximal map extent in longitude or latitude) to data
140-
points above which plot should not display values. For instance, to only plot values
141-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
138+
mask_distance: float, optional
139+
Only regions are plotted that are closer to any of the data points than this distance,
140+
relative to overall plot size. For instance, to only plot values
141+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
142142
Default is None.
143143
kwargs: optional
144144
arguments for pcolormesh matplotlib function
@@ -165,7 +165,7 @@ def plot_intensity(
165165
crs_epsg,
166166
axis,
167167
adapt_fontsize=adapt_fontsize,
168-
mask_relative_distance=mask_relative_distance,
168+
mask_distance=mask_distance,
169169
**kwargs,
170170
)
171171
if centr is not None:
@@ -181,7 +181,7 @@ def plot_fraction(
181181
centr=None,
182182
smooth=True,
183183
axis=None,
184-
mask_relative_distance=None,
184+
mask_distance=None,
185185
**kwargs,
186186
):
187187
"""Plot fraction values for a selected event or centroid.
@@ -205,10 +205,10 @@ def plot_fraction(
205205
in module `climada.util.plot`)
206206
axis: matplotlib.axes._subplots.AxesSubplot, optional
207207
axis to use
208-
mask_relative_distance: float, optional
208+
mask_distance: float, optional
209209
Relative distance (with respect to maximal map extent in longitude or latitude) to data
210210
points above which plot should not display values. For instance, to only plot values
211-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
211+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
212212
Default is None.
213213
kwargs: optional
214214
arguments for pcolormesh matplotlib function
@@ -232,7 +232,7 @@ def plot_fraction(
232232
col_label,
233233
smooth,
234234
axis,
235-
mask_relative_distance=mask_relative_distance,
235+
mask_distance=mask_distance,
236236
**kwargs,
237237
)
238238
if centr is not None:
@@ -252,7 +252,7 @@ def _event_plot(
252252
axis=None,
253253
figsize=(9, 13),
254254
adapt_fontsize=True,
255-
mask_relative_distance=None,
255+
mask_distance=None,
256256
**kwargs,
257257
):
258258
"""Plot an event of the input matrix.
@@ -274,10 +274,10 @@ def _event_plot(
274274
axis to use
275275
figsize: tuple, optional
276276
figure size for plt.subplots
277-
mask_relative_distance: float, optional
278-
Relative distance (with respect to maximal map extent in longitude or latitude) to data
279-
points above which plot should not display values. For instance, to only plot values
280-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
277+
mask_distance: float, optional
278+
Only regions are plotted that are closer to any of the data points than this distance,
279+
relative to overall plot size. For instance, to only plot values
280+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
281281
Default is None.
282282
kwargs: optional
283283
arguments for pcolormesh matplotlib function
@@ -326,7 +326,7 @@ def _event_plot(
326326
figsize=figsize,
327327
proj=crs_espg,
328328
adapt_fontsize=adapt_fontsize,
329-
mask_relative_distance=mask_relative_distance,
329+
mask_distance=mask_distance,
330330
**kwargs,
331331
)
332332

climada/util/plot.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def geo_im_from_array(
338338
axes=None,
339339
figsize=(9, 13),
340340
adapt_fontsize=True,
341-
mask_relative_distance=None,
341+
mask_distance=None,
342342
**kwargs,
343343
):
344344
"""Image(s) plot defined in array(s) over input coordinates.
@@ -370,10 +370,10 @@ def geo_im_from_array(
370370
adapt_fontsize : bool, optional
371371
If set to true, the size of the fonts will be adapted to the size of the figure. Otherwise
372372
the default matplotlib font size is used. Default is True.
373-
mask_relative_distance: float, optional
374-
Relative distance (with respect to maximal map extent in longitude or latitude) to data
375-
points above which plot should not display values. For instance, to only plot values
376-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
373+
mask_distance: float, optional
374+
Only regions are plotted that are closer to any of the data points than this distance,
375+
relative to overall plot size. For instance, to only plot values
376+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
377377
Default is None.
378378
**kwargs
379379
arbitrary keyword arguments for pcolormesh matplotlib function
@@ -456,15 +456,14 @@ def geo_im_from_array(
456456
fill_value=min_value,
457457
)
458458
# Compute distance of each grid point to the nearest known point
459-
if mask_relative_distance is not None:
459+
if mask_distance is not None:
460460
tree = cKDTree(np.array((coord[:, 1], coord[:, 0])).T)
461461
distances, _ = tree.query(
462462
np.c_[grid_x.ravel(), grid_y.ravel()],
463463
p=2, # for plotting squares and not sphere around centroids use p=np.inf
464464
)
465465
threshold = (
466-
max(extent[1] - extent[0], extent[3] - extent[2])
467-
* mask_relative_distance
466+
max(extent[1] - extent[0], extent[3] - extent[2]) * mask_distance
468467
)
469468
grid_im[(distances.reshape(grid_im.shape) > threshold)] = min_value
470469
else:
@@ -1105,7 +1104,7 @@ def plot_from_gdf(
11051104
axis=None,
11061105
figsize=(9, 13),
11071106
adapt_fontsize=True,
1108-
mask_relative_distance=None,
1107+
mask_distance=None,
11091108
**kwargs,
11101109
):
11111110
"""Plot several subplots from different columns of a GeoDataFrame, e.g., for
@@ -1128,10 +1127,10 @@ def plot_from_gdf(
11281127
adapt_fontsize: bool, optional
11291128
If set to true, the size of the fonts will be adapted to the size of the figure.
11301129
Otherwise the default matplotlib font size is used. Default is True.
1131-
mask_relative_distance: float, optional
1130+
mask_distance: float, optional
11321131
Relative distance (with respect to maximal map extent in longitude or latitude) to data
11331132
points above which plot should not display values. For instance, to only plot values
1134-
at the centroids, use mask_relative_distance=0.01. If None, the plot is not masked.
1133+
at the centroids, use mask_distance=0.01. If None, the plot is not masked.
11351134
Default is None.
11361135
kwargs: optional
11371136
Arguments for pcolormesh matplotlib function used in event plots.
@@ -1193,7 +1192,7 @@ def plot_from_gdf(
11931192
axes=axis,
11941193
figsize=figsize,
11951194
adapt_fontsize=adapt_fontsize,
1196-
mask_relative_distance=mask_relative_distance,
1195+
mask_distance=mask_distance,
11971196
**kwargs,
11981197
)
11991198

0 commit comments

Comments
 (0)