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

Option renumber in `filter.py`

Add possibility to renumber eddies in script `filter.py`.
parent c4e2da23
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ parser = argparse.ArgumentParser()
parser.add_argument("input_dir", help = "containing the three input shapefiles")
parser.add_argument("output_dir",
help = "containing the three filtered shapefiles")
parser.add_argument("--renumber", help = "reset indices of eddies",
action = "store_true")
args = parser.parse_args()
with shapefile.Reader(path.join(args.input_dir, "extremum")) as extremum, \
......@@ -24,16 +26,18 @@ with shapefile.Reader(path.join(args.input_dir, "extremum")) as extremum, \
extremum_filt.fields = extremum.fields[1:]
outermost_cont_filt.fields = outermost_cont.fields[1:]
max_speed_cont_filt.fields = max_speed_cont.fields[1:]
if args.renumber: eddy_index = 0
for shape_rec_extr, shape_rec_outer, shape_rec_max \
in zip(extremum, outermost_cont, max_speed_cont):
if 6 <= shape_rec_extr.shape.points[0][0] <= 12 \
and - 33 <= shape_rec_extr.shape.points[0][1] <= - 27:
extremum_filt.record(*shape_rec_extr.record)
extremum_filt.shape(shape_rec_extr.shape)
outermost_cont_filt.record(*shape_rec_outer.record)
outermost_cont_filt.shape(shape_rec_outer.shape)
max_speed_cont_filt.record(*shape_rec_max.record)
max_speed_cont_filt.shape(shape_rec_max.shape)
if args.renumber: eddy_index += 1
for sr, w in zip([shape_rec_extr, shape_rec_outer, shape_rec_max],
[extremum_filt, outermost_cont_filt,
max_speed_cont_filt]):
r = sr.record
if args.renumber: r["eddy_index"] = eddy_index
w.record(*r)
w.shape(sr.shape)
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