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

Process both orientations

Both anticyclonic and cyclonic trajectories.
parent ff86b5f5
No related branches found
No related tags found
No related merge requests found
......@@ -5,24 +5,26 @@ import json
import operator
import csv
m = sio.loadmat("Trajectories_Anti_filt_v6.mat", squeeze_me=True)
traj = {}
belong = []
for orient1, orient2, orient3 in zip(["cyclo", "anti"], ["Cyclo", "Anti"],
["C", "Antic"]):
m = sio.loadmat(f"Trajectories_{orient2}_filt_v6.mat", squeeze_me=True)
traj = {}
belong = []
for t in m["Anticyclonic_Trajectories"]:
assert t.ndim == 1
assert isinstance(t[0], int)
traj[t[0]] = t[1].tolist()
for id_det in traj[t[0]]:
belong.append((id_det, t[0]))
for t in m[f"{orient3}yclonic_Trajectories"]:
assert t.ndim == 1
assert isinstance(t[0], int)
traj[t[0]] = t[1].tolist()
belong.sort(key = operator.itemgetter(0))
for id_det in traj[t[0]]:
belong.append((id_det, t[0]))
with open("traj_anti.json", "w") as f:
json.dump(traj, f, indent = 0)
belong.sort(key = operator.itemgetter(0))
with open("belong.csv", "w", newline='') as f:
writer = csv.writer(f, lineterminator = "\n")
writer.writerow(("ID_detection", "ID_traj"))
writer.writerows(belong)
with open(f"traj_{orient1}.json", "w") as f:
json.dump(traj, f, indent = 0)
with open(f"belong_{orient1}.csv", "w", newline='') as f:
writer = csv.writer(f, lineterminator = "\n")
writer.writerow(("ID_detection", "ID_traj"))
writer.writerows(belong)
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