-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbode_plot.py
More file actions
35 lines (31 loc) · 1021 Bytes
/
bode_plot.py
File metadata and controls
35 lines (31 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Author: RedFantom
License: GNU GPLv3
Copyright (c) RedFantom 2019
Convert the results of a Bode Plot analysis of the bode plot utility
into a three-column CSV-file. Columns:
1. Test Frequency (Hz)
2. Gain (dB)
3. Phase (degrees)
"""
import pandas
import os
folder = "INSERT_PATH_TO_BODE_LOG_DATA"
os.chdir(folder)
for file in os.listdir(os.getcwd()):
if not file.endswith(".txt"):
continue
print("Processing: {}...".format(file), end=" ", flush=True)
with open(file, "r") as fi:
# First three lines are meta-data
lines = fi.readlines()[3:]
data = {"frequency": list(), "gain": list(), "phase": list()}
for line in lines:
elements = [e for e in line.split(" ") if e != ""]
freq, gain, phase = [float(e.replace(",", ".")) for e in elements]
data["frequency"].append(freq)
data["gain"].append(gain)
data["phase"].append(phase)
d = pandas.DataFrame(data)
d.to_csv("{}_bode.csv".format(file.split(".")[0]))
print("Done.")