From 6f76e4e673a8b44ad516ffdf7f5397af18fb8904 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 11 Oct 2023 13:46:28 +0200 Subject: [PATCH] Add script for time filtering of trajectories --- Trajectories/filter_traj.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 Trajectories/filter_traj.py diff --git a/Trajectories/filter_traj.py b/Trajectories/filter_traj.py new file mode 100755 index 00000000..48ed3bcc --- /dev/null +++ b/Trajectories/filter_traj.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import json +import report_graph +import bisect +import sys + +if len(sys.argv) != 4: + sys.exit("Required arguments: last-date input-file output-file") + +with open("e_overestim.txt") as f: e_overestim = int(f.read()) +last_date = int(sys.argv[1]) +last_node = report_graph.date_eddy_to_node(last_date, e_overestim, e_overestim) +with open(sys.argv[2]) as f: expanded_traj = json.load(f) +filt_traj = [] + +for t in expanded_traj: + ip = bisect.bisect(t, last_node) + if ip != 0: filt_traj.append(t[:ip]) + +with open(sys.argv[3], "w") as f: json.dump(filt_traj, f) -- GitLab