From d1a5e76d177043148ec0c30341e5b012dfee22a2 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 20 Nov 2019 17:18:50 +0100 Subject: [PATCH] Option renumber in `filter.py` Add possibility to renumber eddies in script `filter.py`. --- Analysis/filter.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Analysis/filter.py b/Analysis/filter.py index 903f58e3..c6c31ab9 100755 --- a/Analysis/filter.py +++ b/Analysis/filter.py @@ -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) -- GitLab