Skip to content

Commit f73180e

Browse files
committed
Square is deprecated.
1 parent d358b98 commit f73180e

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

ridge_map/ridge_map.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ def longs(self):
9292
return (self.bbox[0], self.bbox[2])
9393

9494
def get_elevation_data(
95-
self,
96-
num_lines=80,
97-
elevation_pts=300,
98-
viewpoint_angle=0,
95+
self,
96+
num_lines=80,
97+
elevation_pts=300,
98+
viewpoint_angle=0,
9999
crop=False,
100-
interpolation=0,
101-
lock_resolution=False
100+
interpolation=0,
101+
lock_resolution=False,
102102
):
103103
"""Fetch elevation data and return a numpy array.
104104
@@ -114,25 +114,29 @@ def get_elevation_data(
114114
crop : bool
115115
If the corners are cropped when rotating
116116
interpolation : int in [0, 5]
117-
The level of interpolation. Can smooth out sharp edges, especially
117+
The level of interpolation. Can smooth out sharp edges, especially
118118
when rotating. Above 1 tends to lead to an all NaN graph.
119119
lock_resolution : bool
120-
Locks the resolution during rotation, ensuring consistent rotation
121-
deltas but producing potential scaling artifacts. These artifacts
120+
Locks the resolution during rotation, ensuring consistent rotation
121+
deltas but producing potential scaling artifacts. These artifacts
122122
can be reduced by setting num_lines = elevation_pts.
123123
124124
Returns
125125
-------
126126
np.ndarray
127127
"""
128-
if (45 < (viewpoint_angle % 360) < 135 or 225 < (viewpoint_angle % 360) < 315) and not lock_resolution:
128+
if (
129+
45 < (viewpoint_angle % 360) < 135 or 225 < (viewpoint_angle % 360) < 315
130+
) and not lock_resolution:
129131
num_lines, elevation_pts = elevation_pts, num_lines
130-
132+
131133
values = self._srtm_data.get_image(
132134
(elevation_pts, num_lines), self.lats, self.longs, 5280, mode="array"
133135
)
134-
values = rotate(values, angle=viewpoint_angle, reshape=not crop, order=interpolation)
135-
136+
values = rotate(
137+
values, angle=viewpoint_angle, reshape=not crop, order=interpolation
138+
)
139+
136140
return values
137141

138142
def preprocess(
@@ -173,7 +177,10 @@ def preprocess(
173177
values = (values - np.min(values)) / (np.max(values) - np.min(values))
174178

175179
is_water = values < np.percentile(values, water_ntile)
176-
is_lake = rank.gradient(img_as_ubyte(values), footprint_rectangle(3, 3)) < lake_flatness
180+
is_lake = (
181+
rank.gradient(img_as_ubyte(values), footprint_rectangle(3, 3))
182+
< lake_flatness
183+
)
177184

178185
values[nan_vals] = np.nan
179186
values[np.logical_or(is_water, is_lake)] = np.nan
@@ -217,23 +224,25 @@ def plot_annotation(
217224
If there is a background or not
218225
ax : matplotlib Axes
219226
You can pass your own axes, but probably best not to
220-
227+
221228
Returns
222229
-------
223230
matplotlib.Axes
224-
"""
231+
"""
225232
if ax is None and self.ax is None:
226-
raise ValueError("No axes found: Either plot_map() beforehand or pass an matplotlib.Axes value through")
233+
raise ValueError(
234+
"No axes found: Either plot_map() beforehand or pass an matplotlib.Axes value through"
235+
)
227236
elif ax is None:
228237
ax = self.ax
229-
238+
230239
highest_zorder = max(text.zorder for text in ax.texts) if ax.texts else 1
231-
240+
232241
rel_coordinates = (
233242
(coordinates[0] - self.longs[0]) / (self.longs[1] - self.longs[0]),
234243
(coordinates[1] - self.lats[0]) / (self.lats[1] - self.lats[0]),
235244
)
236-
245+
237246
annotation_color = "black"
238247
if color:
239248
annotation_color = color
@@ -265,10 +274,10 @@ def plot_annotation(
265274
ms=annotation_size,
266275
zorder=highest_zorder,
267276
)
268-
277+
269278
self.ax = ax
270279
return ax
271-
280+
272281
# pylint: disable=too-many-arguments,too-many-locals
273282
def plot_map(
274283
self,
@@ -326,7 +335,6 @@ def plot_map(
326335
-------
327336
matplotlib.Axes
328337
"""
329-
330338
if kind not in {"gradient", "elevation"}:
331339
raise TypeError("Argument `kind` must be one of 'gradient' or 'elevation'")
332340
if values is None:
@@ -383,6 +391,6 @@ def plot_map(
383391
for spine in ax.spines.values():
384392
spine.set_visible(False)
385393
ax.set_facecolor(background_color)
386-
394+
387395
self.ax = ax
388396
return ax

0 commit comments

Comments
 (0)