Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit fe51d7fc authored by Ed Rogers's avatar Ed Rogers
Browse files

Implement replotting of results after test

parent cf32d048
......@@ -124,7 +124,7 @@ def mean_two_arrays(a: np.ndarray, b: np.ndarray):
class HearingResults:
def __init__(self):
self._data = np.array((0,))
self._data = []
self.load_results()
self._counter = 0
......@@ -134,3 +134,6 @@ class HearingResults:
def load_results(self):
data = np.loadtxt('data.csv', delimiter=',')
self._data = [data[i, :] for i in range(0, data.shape[0])]
def append(self, new_result):
self._data.append(new_result)
\ No newline at end of file
......@@ -23,27 +23,26 @@ class HearingResultsCanvas(FigureCanvas):
self.plot_results(results)
def plot_results(self, results: HearingResults):
self.axes.clear()
results_list = results.as_list()
n = len(results_list)
pink = np.array((1., 0.7, 0.8))
freqs = self.parent.parent.library.freqs
for i, result in enumerate(results_list):
if n - i > 10:
if n - i > 5:
color = pink
else:
reduction = (n - i) / 10
reduction = (n - i) / 5
color = (pink[0], pink[1] * reduction, pink[2] * reduction)
print(color)
self.axes.semilogx(freqs, result, color=color)
spacing = (HearingTest.upper_lim - HearingTest.lower_lim) / 10
self.axes.set_ylim(HearingTest.lower_lim - spacing, HearingTest.upper_lim + spacing)
labels = [str(b) for b in freqs]
# labels.insert(0, '')
# self.axes.log
self.axes.set_xticks(freqs)
self.axes.set_xticklabels(labels)
self.axes.set_yticks([])
self.draw()
class ResultsWindow(QMainWindow):
......
......@@ -210,6 +210,8 @@ class TestWindow(QMainWindow):
self.log.append("Writing test result to file")
thresholds = self.test.thresholds
thresholds = thresholds.reshape(thresholds.shape[0], -1) # convert to 2d
self.results.append(thresholds)
self.results_window.graph.plot_results(self.results)
with open('data.csv', 'ba') as file:
np.savetxt(file, thresholds.T, fmt='%.2f', delimiter=',')
score_str = self.test.get_score_text()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment