mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
python: remove obsolete files
This commit is contained in:
parent
a2aca1f6f7
commit
6a39221c4b
8 changed files with 1 additions and 219 deletions
|
@ -1,65 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import csv
|
||||
import sys
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import re
|
||||
|
||||
# check if called correctly
|
||||
if len(sys.argv) < 2:
|
||||
sys.exit('Usage: %s FILE1 FILE2' % sys.argv[0])
|
||||
|
||||
plt.figure(figsize=(8,4))
|
||||
|
||||
for fn in sys.argv[1:]:
|
||||
|
||||
# m = re.match('[a-zA-Z-]+[-_](\d+)[-_](\d+).', fn)
|
||||
# rate = m.group(1)
|
||||
# values = m.group(2)
|
||||
# print 'Processing file %s (rate=%s, values=%s)' % (fn, rate, values)
|
||||
|
||||
# read data from file
|
||||
data = [ ]
|
||||
with open(fn) as f:
|
||||
reader = csv.reader(f, delimiter='\t')
|
||||
|
||||
for row in reader:
|
||||
offset = float(row[0])
|
||||
|
||||
# if fn != 'nrel-test1_offset.log':
|
||||
# offset = offset * 0.001
|
||||
|
||||
if offset > 100:
|
||||
continue
|
||||
|
||||
data.append(offset)
|
||||
|
||||
# evaluate the histogram
|
||||
values, base = np.histogram(data, bins='fd')
|
||||
|
||||
# evaluate the cumulative
|
||||
cumulative = np.cumsum(values)
|
||||
cumscaled = [ float(x) / len(data) for x in cumulative ]
|
||||
|
||||
# plot the cumulative function
|
||||
plt.plot(base[:-1], cumscaled, label=fn, linewidth=1)
|
||||
|
||||
# plot the distribution
|
||||
#valscaled = [ float(x) / len(data) for x in values ]
|
||||
#plt.plot(base[:-1], valscaled, label=fn, linewidth=1)
|
||||
|
||||
plt.xlabel('RTT (s)')
|
||||
plt.ylabel('Cum. Probability')
|
||||
plt.grid(color='0.75')
|
||||
|
||||
#plt.yscale('log')
|
||||
|
||||
#plt.ylim([0, 1.03])
|
||||
#plt.xlim([0.025, 0.05])
|
||||
|
||||
lgd = plt.legend(title='Rate (p/s)', loc='center left', bbox_to_anchor=(1, 0.5))
|
||||
|
||||
plt.show()
|
||||
|
||||
#plt.savefig('cumdist.png', dpi=600, bbox_extra_artists=(lgd,), bbox_inches='tight')
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import csv
|
||||
import sys
|
||||
import villas.human as vh
|
||||
|
||||
# check if called correctly
|
||||
if len(sys.argv) != 1:
|
||||
sys.exit('Usage: %s < IN_FILE > OUT_FILE' % sys.argv[0])
|
||||
|
||||
with sys.stdin as f:
|
||||
reader = csv.reader(f, delimiter='\t')
|
||||
|
||||
for row in reader:
|
||||
m = vh.Message.parse(row)
|
||||
|
||||
if m.ts == None or m.ts.offset == None:
|
||||
continue
|
||||
|
||||
print(m.ts.offset)
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import villas.human as vh
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: %s from to" % (sys.argv[0]))
|
||||
sys.exit(-1)
|
||||
|
||||
start = vh.Timestamp.parse(sys.argv[1])
|
||||
end = vh.Timestamp.parse(sys.argv[2])
|
||||
|
||||
for line in sys.stdin:
|
||||
msg = vh.Message.parse(line)
|
||||
|
||||
if start <= msg.ts <= end:
|
||||
print msg
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import villas.human
|
||||
|
||||
files = sys.argv[1:]
|
||||
|
||||
all = [ ]
|
||||
last = { }
|
||||
|
||||
for file in files:
|
||||
handle = sys.stdin if file == '-' else open(file, "r")
|
||||
|
||||
msgs = [ ]
|
||||
for line in handle.xreadlines():
|
||||
msgs.append(vh.Message.parse(line, file))
|
||||
|
||||
all += msgs
|
||||
last[file] = vh.Message(vh.Timestamp(), [0] * len(msgs[0].values), file)
|
||||
|
||||
all.sort()
|
||||
for msg in all:
|
||||
last[msg.source] = msg
|
||||
|
||||
values = [ ]
|
||||
for file in files:
|
||||
values += last[file].values
|
||||
|
||||
print(vh.Message(msg.ts, values, ""))
|
|
@ -32,6 +32,5 @@ setup(
|
|||
],
|
||||
setup_requires=[
|
||||
'm2r'
|
||||
],
|
||||
scripts=glob('bin/*')
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
from message import Message # noqa F401
|
||||
from timestamp import Timestamp # noqa F401
|
|
@ -1,30 +0,0 @@
|
|||
import villas.human.timestamp as ts
|
||||
from functools import total_ordering
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Message:
|
||||
"""Parsing a VILLASnode sample from a file (not a UDP package!!)"""
|
||||
|
||||
def __init__(self, ts, values, source=None):
|
||||
self.source = source
|
||||
self.ts = ts
|
||||
self.values = values
|
||||
|
||||
@classmethod
|
||||
def parse(cls, line, source=None):
|
||||
csv = line.split()
|
||||
|
||||
t = ts.Timestamp.parse(csv[0])
|
||||
v = map(float, csv[1:])
|
||||
|
||||
return Message(t, v, source)
|
||||
|
||||
def __str__(self):
|
||||
return '%s %s' % (self.ts, " ".join(map(str, self.values)))
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.ts == other.ts
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.ts < other.ts
|
|
@ -1,54 +0,0 @@
|
|||
import re
|
||||
from functools import total_ordering
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Timestamp:
|
||||
"""Parsing the VILLASnode human-readable timestamp format"""
|
||||
|
||||
def __init__(self, seconds=0, nanoseconds=None,
|
||||
offset=None, sequence=None):
|
||||
self.seconds = seconds
|
||||
self.nanoseconds = nanoseconds
|
||||
self.offset = offset
|
||||
self.sequence = sequence
|
||||
|
||||
@classmethod
|
||||
def parse(cls, ts):
|
||||
m = re.match(r'(\d+)(?:\.(\d+))?([-+]\d+(?:\.\d+)?'
|
||||
r'(?:e[+-]?\d+)?)?(?:\((\d+)\))?', ts)
|
||||
|
||||
seconds = int(m.group(1)) # Mandatory
|
||||
nanoseconds = int(m.group(2)) if m.group(2) else None
|
||||
offset = float(m.group(3)) if m.group(3) else None
|
||||
sequence = int(m.group(4)) if m.group(4) else None
|
||||
|
||||
return Timestamp(seconds, nanoseconds, offset, sequence)
|
||||
|
||||
def __str__(self):
|
||||
str = "%u" % (self.seconds)
|
||||
|
||||
if self.nanoseconds is not None:
|
||||
str += ".%09u" % self.nanoseconds
|
||||
if self.offset is not None:
|
||||
str += "+%u" % self.offset
|
||||
if self.sequence is not None:
|
||||
str += "(%u)" % self.sequence
|
||||
|
||||
return str
|
||||
|
||||
def __float__(self):
|
||||
sum = float(self.seconds)
|
||||
|
||||
if self.nanoseconds is not None:
|
||||
sum += self.nanoseconds * 1e-9
|
||||
if self.offset is not None:
|
||||
sum += self.offset
|
||||
|
||||
return sum
|
||||
|
||||
def __eg__(self, other):
|
||||
return float(self) == float(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
return float(self) < float(other)
|
Loading…
Add table
Reference in a new issue