-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonset0.asy
100 lines (84 loc) · 2.44 KB
/
onset0.asy
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import graph;
size(40cm, 10cm, false);
void drawbar(real x, real y, pen p = defaultpen, pen f = invisible) {
real w = 1.0 / 3.0;
pair p0 = (x - w, 0);
pair p1 = (x + w, 0);
pair p2 = (x + w, y);
pair p3 = (x - w, y);
filldraw(p0--p1--p2--p3--cycle, f, p);
}
// offset for placement of sp text
real offset = 0.005;
// end of warmup from the observations
real[] sobs;
// presence of periodicity as per observations
real[] pobs;
{
string filename;
filename = getstring("FSfilename");
file f = input(filename).line();
real[][] a = f.dimension(0, 0);
a = transpose(a);
for(int i = 0; i < 62; ++i) {
sobs.push(a[18][i]); // S #TailStart
pobs.push(a[17][i] > 1 ? 1 : 0); // R #CycleLength
}
}
real[] x = sequence(sobs.length);
// draw an invisible graph to set up the axes
draw(graph(x, sobs), invisible);
for(int i = 0; i < sobs.length; ++i) {
drawbar(x[i], sobs[i], red, red + opacity(0.25));
if(sobs[i] >= 0) {
if(pobs[i] > 0)
label("\small{sp}",(x[i], sobs[i]), offset * NW, red);
else
label("\small{s}",(x[i], sobs[i]), offset * NW, red);
}
}
// reference end of warmup
real[] wref;
{
file f = input("ref/ref.csv").line();
real[][] b = f.dimension(0, 0);
b = transpose(b);
wref = b[0];
}
// invisible graph to set up axes
real[] rx = sequence(wref.length);
draw(graph(rx, wref), invisible);
// presence of periodicity (reference)
real[] pref;
{
file f = input("ref/pref.csv").line();
real[][] prr = f.dimension(0, 0);
prr = transpose(prr);
pref = prr[0];
}
// presence of stationarity (reference)
real[] sref;
{
file f = input("ref/sref.csv").line();
real[][] a = f.dimension(0, 0);
a = transpose(a);
sref = a[0];
}
for(int i = 0; i < wref.length; ++i) {
drawbar(rx[i], wref[i], blue, blue + opacity(0.25));
if(sref[i] == 1) {
if(pref[i] == 1)
label("\small{sp}",(rx[i], wref[i]), offset * NE, blue);
else
label("\small{s}", (rx[i], wref[i]), offset * NE, blue);
}
}
xaxis(BottomTop);
for(int i=0; i < rx.length; ++i) {
label(string(i+1), rx[i], S);
}
yaxis("End of warmpu period", LeftRight, RightTicks);
real xmean = 0.5 * (min(x[0],rx[0]) + max(x[x.length -1], rx[rx.length -1]));
real ymax = max(max(sobs), max(wref));
label("Comparison between detected (red) and reference (blue) onset of stationarity.", (xmean, -0.1 * ymax));
label("The label ``s\" indicated stationarity was detected, ``sp\" indicates a periodic stationary state.", (xmean, -0.1 * ymax), 4 * S);