Skip to content
Snippets Groups Projects
Commit 24b7da37 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Bug fix: test presence of `radius_4` in reader

We cannot test `"radius4" in shape_rec_outer.record`, as
`shape_rec_outer.record` is not a dictionary. We could test `"radius4"
in shape_rec_outer.record.as_dict()` but it is better to test outside
of the loop in the field names of the shapefile reader object. The bug
comes from commit 83a61016.
parent 6ef4466a
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation,
shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation,
"outermost_contour")) as outermost_contour:
n_extr = len(extremum)
field_names_outer = [f[0] for f in outermost_contour.fields[1:]]
with_radius_4 = 'radius4' in field_names_outer
for rec_extr, shape_rec_outer in zip(extremum.iterRecords(),
outermost_contour):
......@@ -35,7 +37,7 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation,
if shape_rec_outer.record.r_eq_area >= 0: n_outer += 1
if "radius4" in shape_rec_outer.record:
if with_radius_4:
if shape_rec_outer.record.radius4 == 0:
n_radius4[0] += 1
elif shape_rec_outer.record.radius4 == 1:
......@@ -43,7 +45,7 @@ with shapefile.Reader(path.join(args.SHPC, "Slice_0", args.orientation,
elif shape_rec_outer.record.radius4 >= 2:
n_radius4[2] += 1
if rec_extr.speed == 1e4 and "radius4" in shape_rec_outer.record:
if rec_extr.speed == 1e4 and with_radius_4:
if shape_rec_outer.record.radius4 == 0:
n_missing_speed[0] += 1
elif shape_rec_outer.record.radius4 == 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment