blob: bafcec7b271158cfe5e28c8b131dd23ffbda422e (
plain) (
tree)
|
|
#!/usr/bin/python3
from sys import stderr
from math import log
import numpy
import csv
t = []
x = []
v = []
with open("nihanje.tsv") as file:
tsv = csv.reader(file, delimiter="\t")
i = -1
for line in tsv:
if i == -1:
i = i + 1
continue
t.append(float(line[0]))
x.append(float(line[1]))
v.append(float(line[2]))
i = i + 1
zero_crossings_x = numpy.where(numpy.diff(numpy.sign(x)))[0]
zero_crossings_v = numpy.where(numpy.diff(numpy.sign(v)))[0]
print("v\tx\tt\tabsx\tln")
for i in range(len(zero_crossings_x)-1):
print(f"{v[zero_crossings_x[i]]}\t{x[zero_crossings_v[i]]}\t{t[zero_crossings_v[i]]}\t{abs(x[zero_crossings_v[i]])}\t{log(abs(x[zero_crossings_v[i]])/0.0943867)}")
print(f"za {len(zero_crossings_x/2)} nihajev je preteklo {t[zero_crossings_x[len(zero_crossings_x)-1]]-t[zero_crossings_x[0]]} sekund, zato je nihajni cas {(t[zero_crossings_x[len(zero_crossings_x)-1]]-t[zero_crossings_x[0]])/(len(zero_crossings_x)/2)}", file=stderr)
|