-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.py
More file actions
36 lines (30 loc) · 1.11 KB
/
Example.py
File metadata and controls
36 lines (30 loc) · 1.11 KB
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
36
import numpy as np
import matplotlib.pyplot as plt
import pyNNST
T = 20
fs = 400
dt = 1 / fs
x = np.random.rand(T * fs)
time = np.linspace(0, T - dt, T * fs)
std = np.std(x, ddof = 1)
mean = np.mean(x)
example = pyNNST.nnst(x, nperseg = 100, noverlap = 0, confidence = 95)
example.idns()
segments_std, bound_dw, bound_up = example.get_segments()
time_segments = np.linspace(0, T - dt, len(segments_std))
limits = example.get_limits()
outcome = example.get_outcome()
index = example.get_index()
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(time, x, color = 'darkgray', zorder = 0, label = 'Signal')
ax.plot(time_segments, mean + segments_std, color = 'C0', zorder = 1, label = 'Segments std')
ax.hlines(mean + std, 0, T, colors='C1', linestyles='solid', zorder = 2, label = 'Signal std')
ax.hlines(mean + bound_dw, 0, T, colors='C3', linestyles='dashed', zorder = 3, label = 'Boundaries')
ax.hlines(mean + bound_up, 0, T, colors='C3', linestyles='dashed', zorder = 4)
ax.grid()
ax.legend(loc = 4)
ax.set_xlabel('Time [s]')
ax.set_ylabel('Amplitude [\]')
ax.set_title('Index: '+ str(index) + '%\n' + outcome)
plt.show()