1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

python/tools: remove more obsolete tools

This commit is contained in:
Steffen Vogel 2020-07-06 13:54:02 +02:00
parent 6a39221c4b
commit 73d393a967
12 changed files with 0 additions and 365 deletions

View file

@ -1,63 +0,0 @@
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')

View file

@ -1,22 +0,0 @@
import csv
import sys
import re
# check if called correctly
if len(sys.argv) != 2:
sys.exit('Usage: %s FILE' % sys.argv[0])
prog = re.compile('(\d+)(?:\.(\d+))?([-+]\d+(?:\.\d+)?(?:e[+-]?\d+)?)?(?:\((\d+)\))?')
with open(sys.argv[1]) as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
m = prog.match(row[0])
if m == None or m.group(3) == None:
continue
offset = float(m.group(3))
print(offset)

View file

@ -1,23 +0,0 @@
#!/usr/bin/env python
import sys
import villas
from villas import *
def main():
if len(sys.argv) != 3:
print "Usage: %s from to" % (sys.argv[0])
sys.exit(-1)
start = villas.Timestamp.parse(sys.argv[1])
end = villas.Timestamp.parse(sys.argv[2])
for line in sys.stdin:
msg = villas.Message.parse(line)
if start <= msg.ts <= end:
print msg
if __name__ == "__main__":
main()

View file

@ -1,35 +0,0 @@
#!/usr/bin/env python
import sys
import villas
from villas import *
def main():
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(villas.Message.parse(line, file))
all += msgs
last[file] = villas.Message(villas.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 villas.Message(msg.ts, values, "")
if __name__ == "__main__":
main()

View file

@ -1,42 +0,0 @@
#!/bin/bash
#
# Query FIWARE Orion Context Broker
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
# @license GNU General Public License (version 3)
#
# VILLASnode
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
(curl http://46.101.131.212:1026/v1/queryContext -s -S \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "type_one",
"isPattern": "false",
"id": "rtds_sub3"
},
{
"type": "type_two",
"isPattern": "false",
"id": "rtds_sub4"
}
]
}
EOF

View file

@ -1,50 +0,0 @@
#!/bin/bash
#
# Update context of FIRWARE ORION Context Broker.
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
# @license GNU General Public License (version 3)
#
# VILLASnode
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##################################################################################
(curl http://46.101.131.212:1026/v1/updateContext -s -S \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"contextElements": [
{
"type": "type_one",
"isPattern": "false",
"id": "rtds_sub3",
"attributes": [
{
"name": "v1",
"type": "float",
"value": "26.5"
},
{
"name": "v2",
"type": "float",
"value": "763"
}
]
}
],
"updateAction": "UPDATE"
}
EOF

View file

@ -1,27 +0,0 @@
#!/usr/bin/env python3
import sys
import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
def read_datafile(file_name):
# the skiprows keyword is for heading, but I don't know if trailing lines
# can be specified
data = np.loadtxt(file_name, delimiter='\t', skiprows=1)
return data
filename = sys.argv[1]
data = read_datafile(filename)
print(data[:,0])
fig, ax1 = plt.subplots()
ax1.plot(data[:,0], data[:,1])
ax2 = ax1.twinx()
ax2.plot(data[:,0], data[:,2], c='red')
fig.tight_layout()
plt.show()

View file

@ -1,17 +0,0 @@
#!/usr/bin/python
import sys
import villas.dataprocessing.readtools as rt
import villas.dataprocessing.plottools as pt
import matplotlib.pyplot as plt
if len(sys.argv) != 2:
sys.exit(-1)
filename = sys.argv[1]
timeseries = rt.read_timeseries_villas(filename)
pt.plot_timeseries(1, timeseries)
plt.show()

View file

@ -1,86 +0,0 @@
#!/bin/bash
# Wrapper around villas-pipe which uses the signal generator node-type
#
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
# @license GNU General Public License (version 3)
#
# VILLASnode
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################################
function usage() {
echo "Usage: villas-signal [OPTIONS] SIGNAL"
echo " SIGNAL is on of the following signal types:"
echo " mixed"
echo " random"
echo " sine"
echo " triangle"
echo " square"
echo " ramp"
echo " constants"
echo " counter"
echo ""
echo " OPTIONS is one or more of the following options:"
echo " -d LVL set debug level"
echo " -f FMT set the format"
echo " -v NUM specifies how many values a message should contain"
echo " -r HZ how many messages per second"
echo " -n non real-time mode. do not throttle output."
echo " -F HZ the frequency of the signal"
echo " -a FLT the amplitude"
echo " -D FLT the standard deviation for 'random' signals"
echo " -o OFF the DC bias"
echo " -l NUM only send LIMIT messages and stop"
echo
echo "VILLASnode $(villas-node -v)"
echo " Copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC"
echo " Steffen Vogel <StVogel@eonerc.rwth-aachen.de>"
exit 1
}
OPTS=()
while getopts "v:r:f:l:a:D:no:h" OPT; do
case $OPT in
n) OPTS+=("-o realtime=false") ;;
l) OPTS+=("-o limit=$OPTARG") ;;
v) OPTS+=("-o values=$OPTARG") ;;
r) OPTS+=("-o rate=$OPTARG") ;;
o) OPTS+=("-o offset=$OPTARG") ;;
f) OPTS+=("-o frequency=$OPTARG") ;;
a) OPTS+=("-o amplitude=$OPTARG") ;;
D) OPTS+=("-o stddev=$OPTARG") ;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
esac
done
# and shift them away
shift $((OPTIND - 1))
if (( $# != 1 )); then
usage
exit 1
fi
echo villas-pipe -r -t signal -o signal=$1 ${OPTS[@]}