forked from windelbouwman/lognplot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_data.py
More file actions
33 lines (26 loc) · 757 Bytes
/
Copy pathdemo_data.py
File metadata and controls
33 lines (26 loc) · 757 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
""" Create some random data for demo purposes.
"""
import math
from .tsdb import LogLevel, LogRecord
def create_demo_samples(num_points, offset=0):
""" Create sin wave with superposed cosine wave """
# Parameters:
F = 1
A = 25.0
omega = math.pi * 2 * F
F2 = 50
A2 = 3.14
omega2 = math.pi * 2 * F2
samples = []
for t in range(num_points):
x = t * 0.001
y = offset + A * math.sin(omega * x) + A2 * math.cos(omega2 * x)
samples.append((x, y))
return samples
def create_demo_log_messages(num_records):
samples = []
for i in range(num_records):
t = i * 3
record = LogRecord(LogLevel.WARNING, f"Warning {i}")
samples.append((t, record))
return samples