summaryrefslogtreecommitdiffstats
path: root/fiz/vaje/4/preseki.py
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-11-17 00:21:55 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-11-17 00:21:55 +0100
commit0a39997c12f0d872413f6f08f16dfd65b191ccdd (patch)
treee69c170c49dbfdda50d13e21a2da5703cbd8c71a /fiz/vaje/4/preseki.py
parentpopravki fizikalne vaje (diff)
downloadsola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar.gz
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar.bz2
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar.lz
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar.xz
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.tar.zst
sola-gimb-4-0a39997c12f0d872413f6f08f16dfd65b191ccdd.zip
Diffstat (limited to '')
-rwxr-xr-xfiz/vaje/4/preseki.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/fiz/vaje/4/preseki.py b/fiz/vaje/4/preseki.py
new file mode 100755
index 0000000..7a35c66
--- /dev/null
+++ b/fiz/vaje/4/preseki.py
@@ -0,0 +1,25 @@
+#!/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 čas {(t[zero_crossings_x[len(zero_crossings_x)-1]]-t[zero_crossings_x[0]])/(len(zero_crossings_x)/2)}", file=stderr)