Skip to content

Commit b994dfc

Browse files
committed
Addressing flake8 errors.
1 parent 38a5455 commit b994dfc

File tree

10 files changed

+93
-103
lines changed

10 files changed

+93
-103
lines changed

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

demos/obj_tracking.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import numpy as np
1919
from scipy.ndimage import gaussian_filter, find_objects
2020

21-
from hagelslag.data import ModelOutput
22-
from hagelslag.processing import STObject
21+
from hagelslag.data.ModelOutput import ModelOutput
22+
from hagelslag.processing.STObject import STObject
2323
from hagelslag.processing.EnhancedWatershedSegmenter import EnhancedWatershed
2424
from hagelslag.processing.ObjectMatcher import ObjectMatcher, closest_distance
25+
from netCDF4 import Dataset
26+
2527

2628
# In[2]:
2729

@@ -49,7 +51,8 @@
4951
# data_increment (int): quantization interval. Use 1 if you don't want to quantize
5052
# max_thresh (int): values greater than maxThresh are treated as the maximum threshold
5153
# size_threshold_pixels (int): clusters smaller than this threshold are ignored.
52-
# delta (int): maximum number of data increments the cluster is allowed to range over. Larger d results in clusters over larger scales.
54+
# delta (int): maximum number of data increments the cluster is allowed to range over. Larger d results in
55+
# clusters over larger scales.
5356

5457
# From ahij's config file.
5558
if field == "MAX_UPDRAFT_HELICITY" or field == "UP_HELI_MAX03":
@@ -61,11 +64,10 @@
6164
levels = params['min_thresh'] * np.arange(1, 8)
6265
levels = np.append(levels, params['min_thresh'] * 15)
6366
model_watershed_params = (
64-
params['min_thresh'], params['step'], params['max_thresh'], params["max_size"], params["delta"])
67+
params['min_thresh'], params['step'], params['max_thresh'], params["max_size"], params["delta"])
6568

6669
end_date = start_date + timedelta(hours=0)
6770

68-
from netCDF4 import Dataset
6971

7072
model_grid = ModelOutput(ensemble_name,
7173
member,
@@ -149,15 +151,16 @@ def get_forecast_objects(model_grid, ew_params, min_size, gaussian_window):
149151
num_slices = len(obj_slices)
150152
model_objects.append([])
151153
if num_slices > 0:
152-
fig, ax = plt.subplots()
153-
t = plt.contourf(model_grid.lon, model_grid.lat, hour_labels, np.arange(0, num_slices + 1) + 0.5,
154+
plt.subplots()
155+
plt.contourf(model_grid.lon, model_grid.lat, hour_labels, np.arange(0, num_slices + 1) + 0.5,
154156
extend="max", cmap="Set1", latlon=True, title=str(run_date) + " " + field + " " + str(h))
155-
ret = plt.savefig(odir + "enh_watershed_ex/ew{0:02d}.png".format(h))
157+
plt.savefig(odir + "enh_watershed_ex/ew{0:02d}.png".format(h))
156158
for s, sl in enumerate(obj_slices):
157159
model_objects[-1].append(STObject(model_grid.data[h][sl],
158160
# np.where(hour_labels[sl] > 0, 1, 0),
159161
# For some objects (especially long, diagonal ones), the rectangular
160-
# slice encompasses part of other objects (i.e. non-zero elements of slice).
162+
# slice encompasses part of other objects
163+
# (i.e. non-zero elements of slice).
161164
# We don't want them in our mask.
162165
np.where(hour_labels[sl] == s + 1, 1, 0),
163166
model_grid.x[sl],
@@ -198,7 +201,7 @@ def track_forecast_objects(input_model_objects, model_grid, object_matcher):
198201
elif len(past_time_objs) > 0 and len(model_objects[h]) > 0:
199202
assignments = object_matcher.match_objects(past_time_objs, model_objects[h], h - 1, h)
200203
print("assignments:", assignments)
201-
unpaired = range(len(model_objects[h]))
204+
unpaired = list(range(len(model_objects[h])))
202205
for pair in assignments:
203206
past_time_objs[pair[0]].extend(model_objects[h][pair[1]])
204207
unpaired.remove(pair[1])

0 commit comments

Comments
 (0)