Skip to content

Commit cad8179

Browse files
author
evgkanias
committed
Add script for data from South Africa.
1 parent 0afde6a commit cad8179

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

templates/plot_sa_all.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
plot_all.py
3+
4+
Brittle script to produce all plots from the tod and canopy recordings. The
5+
directory structure is assumed so this will break if anything changes.
6+
"""
7+
8+
import os
9+
# import onedrivesdk as od
10+
import shutil
11+
import plot_bagfile as pb
12+
import matplotlib.pyplot as plt
13+
14+
15+
if __name__ == "__main__":
16+
data_dir = os.path.join(os.getcwd(), os.path.join('..', 'sardinia_data'))
17+
out_base_dir = os.path.join(os.getcwd(), os.path.join('..', 'plots'))
18+
19+
# client = od.get_default_client()
20+
# data_dir = os.path.join(r"C:", "Users", "Odin", "OneDrive - University of Edinburgh", "Projects",
21+
# "2022-InsectNeuroNano", "SA2022 data")
22+
23+
# Make plot directory if it doesn't exist. Existing files will
24+
# be overwritten.
25+
if not os.path.exists(out_base_dir):
26+
os.mkdir(out_base_dir)
27+
28+
# Change into data directory - tod_data, canopy_data
29+
datasets = os.listdir(data_dir)
30+
for s in datasets:
31+
os.chdir(os.path.join(data_dir, s))
32+
33+
days = os.listdir(os.getcwd())
34+
for d in days:
35+
os.chdir(os.path.join(data_dir, s, d))
36+
37+
# Plots are split by experiment and day
38+
# e.g. ../plots/tod_data/Friday_13-05-22/x.pdf
39+
output_file_base = os.path.join(out_base_dir, s, d)
40+
if not os.path.exists(output_file_base):
41+
os.makedirs(output_file_base)
42+
rec_sessions = os.listdir(os.getcwd())
43+
for r in rec_sessions:
44+
session_path = os.path.join(data_dir, s, d, r)
45+
if not os.path.isdir(session_path):
46+
continue
47+
48+
fig, outfile = pb.plot_bagfile(session_path, mode="eigenvectors")
49+
# fig, outfile = pb.plot_bagfile(session_path, mode="intensity+polarisation")
50+
# fig, outfile = pb.plot_bagfile(session_path, mode="intensity-only")
51+
# fig, outfile = pb.plot_bagfile(session_path, mode="polarisation-only")
52+
outpath = os.path.abspath(os.path.join(output_file_base, outfile.replace(".pdf", ".png")))
53+
54+
print(outpath)
55+
fig.savefig(outpath, bbox_inches="tight")
56+
plt.close(fig)
57+

0 commit comments

Comments
 (0)