Minor bug fixes

This commit is contained in:
2023-02-11 21:55:26 +01:00
parent c5a9c2649b
commit 0683979b3b
2 changed files with 22 additions and 24 deletions
+5 -5
View File
@@ -113,9 +113,9 @@ class ExecCSVThread(Thread):
def read_csv_to_array(filepath): # convert a given csv file to a numpy array
# csv format: time [s], xField [T], yField [T], zField [T] (german excel)
# decimal or period commas. Do not use these characters as a thousands seperator!
# decimal or period commas. Do not use these characters as a thousands separator!
with open(filepath, 'r') as csv_file:
# Normalize seperators
# Normalize separators
csv_string = csv_file.read()
# read csv file without column headers
file = pandas.read_csv(StringIO(csv_string), sep=',', decimal='.', header=0)
@@ -163,12 +163,12 @@ def plot_field_sequence(array, width, height): # create plot of fixed size (pix
# modify data to show instantaneous jumps in field to reflect test bench operation
new_array = np.array([[0, 0, 0, 0]], dtype=float) # initialize modified array, zeros to show start from no fields
last_vals = [0, 0, 0] # [x,y,z] field values from last data point (zero here), used to create step in data
last_values = [0, 0, 0] # [x,y,z] field values from last data point (zero here), used to create step in data
for row in array[:, 0:4]: # go through each row in the original array
# create extra datapoint at current timestamp, with field values from last to create a "step" in the plot:
new_array = np.append(new_array, [[row[0], *last_vals]], axis=0)
new_array = np.append(new_array, [[row[0], *last_values]], axis=0)
new_array = np.append(new_array, [row], axis=0) # add actual datapoint for current timestamp
last_vals = row[1:4] # save values from current timestamp for next
last_values = row[1:4] # save values from current timestamp for next
new_array = np.append(new_array, [[new_array[-1, 0], 0, 0, 0]], axis=0) # append last datapoint with 0 fields
# extract data and plot: