diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2022-01-30 23:50:36 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2022-01-30 23:51:00 +0000 |
commit | f6ee0e36c9cc075e5f007c44e95dc3aaa7736a57 (patch) | |
tree | 0fb6437bf04884ca7da38299d30b37ad6f9b4ee3 /scripts/analysis/error-beta.py |
Initial commit
Diffstat (limited to 'scripts/analysis/error-beta.py')
-rwxr-xr-x | scripts/analysis/error-beta.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/analysis/error-beta.py b/scripts/analysis/error-beta.py new file mode 100755 index 0000000..c55f240 --- /dev/null +++ b/scripts/analysis/error-beta.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +import sys + +def process_file(filename, robots): + s = pd.read_csv(filename).to_numpy().reshape((-1, robots, 2, 2)) + error = s[:,:,1] - s[:,:,0] + linear = np.sqrt(error[:,:,0] ** 2 + error[:,:,1] ** 2) + return np.median(linear) + +def main(filenames, labels, robots): + for i, names in enumerate(filenames): + errors = [process_file(name, robots[i]) for name in names] + plt.plot(labels, errors, marker='o', linestyle=' ', label='{} robots'.format(robots[i])) + + plt.ylabel('Median Error (m)') + plt.xlabel('Significance of inter-robot ranging') + plt.legend() + + if input('Save? ') == 'y': + name = input('name: ') + plt.savefig(name) + + plt.show() + +if __name__ == '__main__': + if len(sys.argv) < 4: + sys.exit(1) + robots = [int(i) for i in sys.argv[1].split(' ')] + labels = sys.argv[2].split(' ') + filename_series = map(lambda s: s.split(' '), sys.argv[3:]) + main(filename_series, labels, robots) |