Created
August 8, 2013 13:09
-
-
Save dzhibas/6184425 to your computer and use it in GitHub Desktop.
checks acelometer measurements and says if device is in free-fall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from math import sqrt | |
import csv | |
f = open("train.csv", "rb") | |
r = csv.reader(f) | |
header = r.next() | |
print(header) | |
loop = 0 | |
for l in r: | |
try: | |
if l[1] == '0' and l[2] == '0' and l[3] == '0': | |
# ignore | |
continue | |
x = float(l[1]) | |
y = float(l[2]) | |
z = float(l[3]) | |
except ValueError: | |
print("error in converting line: ", l) | |
v = sqrt(x**2 + y**2 + z**2) | |
if v <= 0.05: | |
print("Device is in free-fall", l) | |
loop += 1 | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment