From bb78f168cdb6c8e099e4df12329386eb96e95f90 Mon Sep 17 00:00:00 2001 From: Recolic Keghart <admin@recolic.net> Date: Thu, 1 Jun 2017 01:08:36 +0800 Subject: [PATCH] inputer --- input/dataInput.py | 31 +++++++++++++++++ input/sound-converted.dat | 2 ++ sound/1.dat | 1 + sound/2.dat | 1 + sound/dat-origin | 10 ++++++ sound/dataInput.py | 31 +++++++++++++++++ sound/quickmap.py | 57 ++++++++++++++++++++++++++++++++ sound/try-https:-recolic.net-phy | 1 + 8 files changed, 134 insertions(+) create mode 100755 input/dataInput.py create mode 100644 input/sound-converted.dat create mode 100644 sound/1.dat create mode 100644 sound/2.dat create mode 100644 sound/dat-origin create mode 100755 sound/dataInput.py create mode 100644 sound/quickmap.py create mode 100644 sound/try-https:-recolic.net-phy diff --git a/input/dataInput.py b/input/dataInput.py new file mode 100755 index 0000000..6a7ffc8 --- /dev/null +++ b/input/dataInput.py @@ -0,0 +1,31 @@ +#!/bin/env python3 +# Type data into https://recolic.net/phy +# Edit&reuse it if you want. +# I'm making it print python code for other usage. +# Recolic Keghart. + +import sys +if len(sys.argv) < 2: + print('Usage: ./dataInput.py /path/to/dat/file | python') + exit(123) + +import numpy +dataset=numpy.loadtxt(sys.argv[1], delimiter=' ') +print('#!/bin/env python3') +print('from pykeyboard import PyKeyboard') +print('import time') +print('k=PyKeyboard()') +oneLine=False +for ar in dataset: + if type(ar) == numpy.float64: + ar=dataset #fuck numpy...... + oneLine=True + if len(ar) == 0: + continue + print('print(\'Waiting for 5 second... Please be ready for auto-typing.\')') + print('time.sleep(5)') + for i in ar: + print('k.type_string(\''+ str(i) +'\')') + print('k.tap_key(k.tab_key)') + if oneLine: + break diff --git a/input/sound-converted.dat b/input/sound-converted.dat new file mode 100644 index 0000000..d9c87a9 --- /dev/null +++ b/input/sound-converted.dat @@ -0,0 +1,2 @@ +36837 37258 36845 37345 36870 37283 36855 37327 36843 37261 +3.54 4.37 8.26 25.9 13.2 47.7 17.7 66.95 22.46 87.16 27.14 108.6 32.06 129.9 36.68 150.8 41.48 173.35 46.3 194.69 50.86 217.16 55.8 239.56 diff --git a/sound/1.dat b/sound/1.dat new file mode 100644 index 0000000..2e6073a --- /dev/null +++ b/sound/1.dat @@ -0,0 +1 @@ +36837 37258 36845 37345 36870 37283 36855 37327 36843 37261 diff --git a/sound/2.dat b/sound/2.dat new file mode 100644 index 0000000..718301e --- /dev/null +++ b/sound/2.dat @@ -0,0 +1 @@ +3.54 4.37 8.26 25.9 13.2 47.7 17.7 66.95 22.46 87.16 27.14 108.6 32.06 129.9 36.68 150.8 41.48 173.35 46.3 194.69 50.86 217.16 55.8 239.56 diff --git a/sound/dat-origin b/sound/dat-origin new file mode 100644 index 0000000..ddb0d15 --- /dev/null +++ b/sound/dat-origin @@ -0,0 +1,10 @@ +sound2 +sound3 +3.54 8.26 13.20 17.70 22.46 27.14 32.06 36.68 41.48 46.30 50.86 55.80 +4.37 25.90 47.70 66.95 87.16 108.60 129.90 150.80 173.35 194.69 217.16 239.56 + +conv +3.54 4.37 8.26 25.9 13.2 47.7 17.7 66.95 22.46 87.16 27.14 108.6 32.06 129.9 36.68 150.8 41.48 173.35 46.3 194.69 50.86 217.16 55.8 239.56 + +sound1 +36837 37258 36845 37345 36870 37283 36855 37327 36843 37261 diff --git a/sound/dataInput.py b/sound/dataInput.py new file mode 100755 index 0000000..6a7ffc8 --- /dev/null +++ b/sound/dataInput.py @@ -0,0 +1,31 @@ +#!/bin/env python3 +# Type data into https://recolic.net/phy +# Edit&reuse it if you want. +# I'm making it print python code for other usage. +# Recolic Keghart. + +import sys +if len(sys.argv) < 2: + print('Usage: ./dataInput.py /path/to/dat/file | python') + exit(123) + +import numpy +dataset=numpy.loadtxt(sys.argv[1], delimiter=' ') +print('#!/bin/env python3') +print('from pykeyboard import PyKeyboard') +print('import time') +print('k=PyKeyboard()') +oneLine=False +for ar in dataset: + if type(ar) == numpy.float64: + ar=dataset #fuck numpy...... + oneLine=True + if len(ar) == 0: + continue + print('print(\'Waiting for 5 second... Please be ready for auto-typing.\')') + print('time.sleep(5)') + for i in ar: + print('k.type_string(\''+ str(i) +'\')') + print('k.tap_key(k.tab_key)') + if oneLine: + break diff --git a/sound/quickmap.py b/sound/quickmap.py new file mode 100644 index 0000000..e0eb9bf --- /dev/null +++ b/sound/quickmap.py @@ -0,0 +1,57 @@ +#!/bin/env python3 +# -*- coding: UTF-8 -*- +# Gereric: Draw line. +# Recolic Keghart, Apr 29, 2017. + +import numpy +from scipy.optimize import leastsq +import matplotlib.pyplot as plt +from matplotlib import rcParams + +def GetMap(parrX, parrY, windowX = 12, windowY = 8, line = False, passO = False): + print('Generic-GetMap by Recolic.') + arrX, arrY = parrX, parrY + maxX, maxY = max(arrX)*1.2, max(arrY)*1.25 + + # Do calculate + # y = k x + b (I = k V + b) + print('Your input: ', arrX, '|', arrY) + print('Data collection done. Generating result...') + V, I = numpy.array(arrX), numpy.array(arrY) + def lineFunc(kb, v): + k,b=kb + if passO: + return k*v + else: + return k*v+b + + lossFunc = lambda kb, v, i : lineFunc(kb, v) - i + + # Fire! + if line: + kb0 = [10,0] + kbFinal = leastsq(lossFunc, kb0, args=(V, I)) + k,b=kbFinal[0] + print('Fit line done. Y=', k, 'X +', b) + else: + print('Drawing map without fitting a line...') + + # Draw function map. + rcParams['grid.linestyle']='-' + rcParams['grid.color'] = 'blue' + rcParams['grid.linewidth'] = 0.2 + plt.figure(figsize=(windowX, windowY)) + plt.scatter(V,I,color="red",label="Sample Point",linewidth=3) + if line: + px=numpy.linspace(0,maxX,1000) + py=k*px+b + plt.plot(px,py,color="orange",label="Fitting Line",linewidth=2) + plt.legend() + plt.grid() + plt.show() + + def toFloat(sstr): + if sstr == '': + return 0.0 + else: + return float(sstr) \ No newline at end of file diff --git a/sound/try-https:-recolic.net-phy b/sound/try-https:-recolic.net-phy new file mode 100644 index 0000000..13ed0e9 --- /dev/null +++ b/sound/try-https:-recolic.net-phy @@ -0,0 +1 @@ +try https://recolic.net/phy -- GitLab