Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zbpetersbuf #23

Open
wants to merge 79 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
91c9bb2
Create code_tobenamedlatter.py
zbpetersbuf Oct 17, 2024
c5cc2dc
created file made sure codspace work
zbpetersbuf Oct 17, 2024
15cc103
edited
zbpetersbuf Oct 17, 2024
587d03c
ignr
zbpetersbuf Oct 17, 2024
33557a0
movefileintocodefolder
zbpetersbuf Oct 17, 2024
7250d38
thisfiletoo
zbpetersbuf Oct 17, 2024
4308a80
dleated
zbpetersbuf Oct 17, 2024
b929178
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 17, 2024
51c76d1
createdmardownfiles
zbpetersbuf Oct 17, 2024
98d6975
Add files via upload
zbpetersbuf Oct 17, 2024
95037ed
tryingtofindcsv
zbpetersbuf Oct 17, 2024
1a2eef7
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 17, 2024
9e4610d
message
zbpetersbuf Oct 17, 2024
ed4f56d
elevator down data
zbpetersbuf Oct 19, 2024
f56c0b6
Rename LL001_elevatordown.csv to LL002_elevatordown.csv
zbpetersbuf Oct 19, 2024
c934b19
Add files via upload
zbpetersbuf Oct 19, 2024
d871deb
Create LL003_eup.md
zbpetersbuf Oct 19, 2024
38a8e6e
Create LL004edown.md
zbpetersbuf Oct 19, 2024
a7d8ad8
updatad code
zbpetersbuf Oct 19, 2024
ff0bf2e
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 19, 2024
4d9be10
need sinc
zbpetersbuf Oct 19, 2024
0a09ee0
message
zbpetersbuf Oct 19, 2024
0606511
somthingworng
zbpetersbuf Oct 19, 2024
9e6eae5
ne
zbpetersbuf Oct 19, 2024
9d0d47c
new
zbpetersbuf Oct 19, 2024
6507278
updated
zbpetersbuf Oct 19, 2024
f56db85
Add files via upload
zbpetersbuf Oct 19, 2024
91afeab
tryinfindfile
zbpetersbuf Oct 19, 2024
8f7ef6e
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 19, 2024
db75d43
Add files via upload
zbpetersbuf Oct 19, 2024
f8ad8ba
upodat
zbpetersbuf Oct 19, 2024
3a8beca
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 19, 2024
54ebc09
savedd
zbpetersbuf Oct 19, 2024
fe99c1e
Add files via upload
zbpetersbuf Oct 21, 2024
9b1662d
Create LL06_eletot.md
zbpetersbuf Oct 21, 2024
6d14497
upd
zbpetersbuf Oct 21, 2024
e1f92b2
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 21, 2024
93381c9
updat
zbpetersbuf Oct 21, 2024
0463705
save
zbpetersbuf Oct 21, 2024
7f4ee14
updated
zbpetersbuf Oct 21, 2024
bba5d99
savechg
zbpetersbuf Oct 21, 2024
4729815
Add files via upload
zbpetersbuf Oct 22, 2024
0c9f743
Create LL08_circle.md
zbpetersbuf Oct 22, 2024
41e332d
up
zbpetersbuf Oct 22, 2024
dcbcf13
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 22, 2024
176ee2d
pylintedwalking
zbpetersbuf Oct 22, 2024
0454891
linted elevator
zbpetersbuf Oct 22, 2024
f8de13c
done for now need lunch
zbpetersbuf Oct 22, 2024
5e5bf68
mes
zbpetersbuf Oct 23, 2024
1569f20
upodat
zbpetersbuf Oct 23, 2024
1ac9b9d
refrence memeory
zbpetersbuf Oct 23, 2024
58c22a1
upd
zbpetersbuf Oct 23, 2024
7faf9b3
up
zbpetersbuf Oct 23, 2024
f5016f6
up
zbpetersbuf Oct 24, 2024
300a9d9
up
zbpetersbuf Oct 24, 2024
9cc162b
mes
zbpetersbuf Oct 24, 2024
9c92c49
mes
zbpetersbuf Oct 24, 2024
91d0141
mes
zbpetersbuf Oct 24, 2024
4e84621
update docstrings
zbpetersbuf Oct 24, 2024
323d18c
edited and added unit tests
zbpetersbuf Oct 24, 2024
7442b59
here
zbpetersbuf Oct 24, 2024
eae861e
Create LL10_triangle.md
zbpetersbuf Oct 24, 2024
9a15d31
Add files via upload
zbpetersbuf Oct 24, 2024
e0f4d3d
up
zbpetersbuf Oct 24, 2024
c215ece
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 24, 2024
b05f5fb
commit
zbpetersbuf Oct 24, 2024
046e300
almost
zbpetersbuf Oct 25, 2024
17ce9c2
update ref
zbpetersbuf Oct 25, 2024
3ca5490
updated docstrings and how to file
zbpetersbuf Oct 25, 2024
3c52701
almost done need food
zbpetersbuf Oct 25, 2024
f61efc1
don?
zbpetersbuf Oct 25, 2024
95064d7
mes
zbpetersbuf Oct 25, 2024
6a556ae
spel
zbpetersbuf Oct 25, 2024
dd8d0fa
Update refrences.md
zbpetersbuf Oct 25, 2024
002b7dc
fixed?
zbpetersbuf Oct 25, 2024
d3d9c26
Merge branch 'branch_zbpetersbuf' of https://github.com/zbpetersbuf/C…
zbpetersbuf Oct 25, 2024
05cd478
deleated these
zbpetersbuf Oct 25, 2024
739d297
tring to deleate stuff that wont go away
zbpetersbuf Dec 1, 2024
5a3e9c8
this is from something unrelated
zbpetersbuf Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added zbpetersbuf/code/Elevator velocities.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions zbpetersbuf/code/elevator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
elevator.py
This module contains the code necessary to interpret the data collected from the
elevator data collection
"""
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

def dimotion(edata):
"""exports time and velocity from the elevator csv file"""
edat = list(edata.loc[:, 'Time (s)'])
edaxyz = list(zip(edata.loc[:, 'Linear Acceleration x (m/s^2)'],
edata.loc[:, 'Linear Acceleration y (m/s^2)'],
edata.loc[:, 'Linear Acceleration z (m/s^2)']))
vel = np.zeros((edata.shape[0], 3))
for j in range(3):
for i in range(edata.shape[0]-1):
if i == 0:
t = edat[i]
else:
t = abs(edat[i]-edat[i-1])
vel[i+1,j]= vel[i,j] + t*edaxyz[i][j]
return vel,edat

def pldimot(vel):
"""graphs the elevator movements in the x y and z directions"""
plt.figure()
vel_df = pd.DataFrame(vel[0])
vmovx = vel_df.iloc[:,0].values
vmovy = vel_df.iloc[:,1].values
vmovz = vel_df.iloc[:,2].values
plt.plot(vel[1],vmovx, color='red', label='x velocity')
plt.plot(vel[1],vmovy, color='blue', label='y velocity')
plt.plot(vel[1],vmovz, color='g', label='z velocity')
plt.title('Elevator velocity')
plt.xlabel('Start from ground floor then up to top then backdown (s)')
plt.ylabel('Velocity of moving elevator (m/s)')
plt.legend()
plt.grid()
plot = input("Do you want to save the plot? (yes/no): ").strip().lower()

if plot == 'yes':
fpath = input("enter where to save: ").strip()
if not os.path.exists(fpath):
print("Directory does not exist, try again")
else:
filpath = os.path.join(fpath, "Elevator velocities.png")
plt.savefig(filpath, format='png', dpi=300)
print(f"Plot saved as {filpath}")
else:
print("Plot not saved.")
72 changes: 72 additions & 0 deletions zbpetersbuf/code/hw_to_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""
mak_plts.py
This module can be ran to the get the plot for the elevator velocities
and position plots for the circle and triangle

in the file elevator.py

How to use the function dimotion
Enter the acceleration without g data in here, it then exports the time and velocities for
the x y and z in two maxtresies, combined into one. too access the time matrix to acces the time
matrix do dimotion(edata)[1] the matrix data is dimotion(edata)[0] where the x velocity is
accessed by dimotion(edata)[0][:,0], y is dimotion(edata)[0][:,1]
and z is dimotion(edata)[0][:,2]

How to use the function pldimot
This function takes in the data that dimotion exports (ie pldimot(dimotion(edata))) and
graphs the 3 velocities on one graph also once the function is used in your comand line it
asks if you want ot save your data, if you dont type yes nothing happens and the graph is not
saved, if you typoe yes the terminal then askes where in your directery you want to save the
.png file, ie if you want to save in in the code file enter
/workspaces/CP-24-midterm/zbpetersbuf/code/ it then saves the .png in this folder as Elevator
velocities.png if a file already existes with that name in the folder it overwrites
the save and saves the most recent image

in the file imp_to_metr.py

how to use the function imptomec
Enter your mesurement value and then the kind of mesurment, ie if feet enter ft, feet or foot
if its yards enter yards, yard it then gives the equivelent value in meters

in the file uniti_con.py

how to use the function gt_unix
this code finds the time and data in the .md files for each data .csv
file and converts then exports the time in unixt time ie unix time converter

in the file workinh.py

how to use the function walkeq
takes your data you and exports the distance traveled

how to use the function distbetp
for this function if you want to know the distance between two data
coleced points only enter the smaller numuber in 'a'
ie if you want to know the distanse between points 4 and 5 only enter 4

how to use the function gpsloc
this function takes the walking data and converts it for the plwalk function to then plot

how to use the function plwalk
This function plots the location of movment across the earth the data you
input for this function is the data exporte from the function gpsloc

"""
import pandas as pd
from elevator import dimotion, pldimot
from workinh import gpsloc, plwalk

etot = pd.read_csv('zbpetersbuf/data/LL05_eletot.csv')
print(etot)
print([['Time (s)','Linear Acceleration x (m/s^2)','Linear Acceleration y (m/s^2)',
'Linear Acceleration z (m/s^2)'],[1,3,3,3],[2,1,2,2],[3,1,2,3]])
vel = dimotion(etot)
pldimot(vel)

walk = pd.read_csv('zbpetersbuf/data/LL07_circle.csv')
datforgraf = gpsloc(walk)
plwalk(datforgraf,"Behold a circle","walking_cir.png")

triwalk = pd.read_csv('zbpetersbuf/data/LL09_triangle.csv')
trwal = gpsloc(triwalk)
plwalk(trwal,"Walking in a triangle near the bus stop","walking_tri.png")
9 changes: 9 additions & 0 deletions zbpetersbuf/code/imp_to_metr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
imp_to_metr.py
this module contains the relevent cod for the feet and yard to meter convertion
"""
def imptomec(x,lenguni):
"""converts from feet or yard to meters"""
if lenguni == 'yard':
x = 3*x
return 0.305*x
25 changes: 25 additions & 0 deletions zbpetersbuf/code/test_elevator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
test_elevator.py
this moduale is the unit test for elevator.py
"""
import pandas as pd
import numpy as np
from elevator import dimotion

dta = pd.DataFrame({'Time (s)': [1,2,3], 'Linear Acceleration x (m/s^2)': [3,1,1],
'Linear Acceleration y (m/s^2)': [3,2,2],
'Linear Acceleration z (m/s^2)': [3,2,3]})

def func():
"""this just outputs the expected values in the ame manner that the function imptomec does"""
a = [[0,0,0],[3,3,3],[4,5,5]]
b = [1,2,3]
return np.array(a), b
v_and_t = func()

def test_imptomec():
"""This tests the imptomec function"""
result = dimotion(dta)
assert result[1] == v_and_t[1]

print((2024-1970)//4)
10 changes: 10 additions & 0 deletions zbpetersbuf/code/test_imp_to_metr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
test_imp_to_metr.py
this modulae is the unit test for imp_to_metr.py
"""
from imp_to_metr import imptomec

def test_imptomec():
"""This tests the ohmscur function"""
assert imptomec(2, 'yard')==1.83
assert imptomec(3, 'foot')==0.915
13 changes: 13 additions & 0 deletions zbpetersbuf/code/test_uniti_con.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
""""
test_uniti_con.py
this module is the unit test for uniti_con.py
expec_tim is the expected time given by the meda file its the system time start
"""
from uniti_con import gt_unix

EXPEC_TIM = 1729609903.749

def test_gt_unix():
"""This tests the imptomec function"""
result = gt_unix('LL08_circle.md')
assert result == EXPEC_TIM
40 changes: 40 additions & 0 deletions zbpetersbuf/code/test_workinh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
test_workinh.py
this moduale is the unit test for workinh.py
"""

import pandas as pd
import numpy as np
from workinh import walkeq, distbetp, gpsloc

dta_1 = [0,1,4,9,16,25]
matr = np.zeros(5)
i=0
while i < 5:
matr[i]=dta_1[i+1]-dta_1[i]
i+=1

def test_distbetp():
"""This tests the distbetp function"""
assert int(distbetp(matr,2)) == (4-1)
assert int(distbetp(matr,4)) == (16-9)

walk = pd.DataFrame({'Latitude (°)': [43,43.1,43.2],
'Longitude (°)': [-78.8,-78.9,-79],
'Altitude WGS84 (m)': [150,150.1,150.2]})

gpwl = gpsloc(walk)

matr_1 = np.zeros(3)
j=0
while j < 3-1:
matr_1[j+1]=(((gpwl[0][j+1]-gpwl[0][j])**(2))+((gpwl[1][j+1]-gpwl[1][j])**2))**(1/2)
j+=1

def test_walkeq():
"""This tests the distbetp function"""
resl = walkeq(walk)
assert resl[1] > matr_1[1] - 6
assert resl[1] < matr_1[1] + 6
assert resl[2] > matr_1[2] - 6
assert resl[2] < matr_1[2] + 6
28 changes: 28 additions & 0 deletions zbpetersbuf/code/uniti_con.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
uniti_con.py
This moduale contains the relevent code for the unix time convertion
"""
import re
import os
import numpy as np

def gt_unix(mod_name):
"""gives the unix time for the start of the data collection"""
fpath='zbpetersbuf/data/'.strip()
filpath = os.path.join(fpath, mod_name)

with open(filpath, 'r', encoding='utf-8') as f:
ftime = np.delete(re.findall(r'\d+', f.read()),0)

matime = np.zeros(ftime.shape[0])
for i in range(ftime.shape[0]):
matime[i] = int(ftime[i])

awf = [0,31,59,90,120,151,181,212,243,273,304,334]
dfg = awf[int(matime[1])-1]
day = 365*(matime[0] - 1970) + matime[2] + dfg + ((matime[0]-1972)//4)
hour = matime[3] + matime[7]
minit = 60*hour + matime[4]
sec = 86400*day + 60*minit + matime[5] + matime[6]*(10**(-3))

return sec
Binary file added zbpetersbuf/code/walking_cir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zbpetersbuf/code/walking_tri.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions zbpetersbuf/code/workinh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""
workinh.py
this moduale contains all the relevent code for walking gps data collection and ploting for
these equations work for both the circle and the triangel

for the test the horizontal accuracy was 4.7 m, and verticle accuracy was 3.4
"""
import os
import math as m
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

def walkeq(walkdt):
"""takes your data and exports the distance traveled"""

laloalt = list(zip(walkdt.loc[:, 'Latitude (°)'],
walkdt.loc[:, 'Longitude (°)'], walkdt.loc[:, 'Altitude WGS84 (m)']))

u = np.zeros(walkdt.shape[0])
s = np.zeros(walkdt.shape[0])

for i in range(walkdt.shape[0]):
u[i] = np.radians(m.atan((1-(np.radians(1/(298.257))))*m.tan(np.radians(laloalt[i][0]))))

for i in range(walkdt.shape[0]-1):
lam = np.radians(abs(laloalt[0][1]-laloalt[1][1]))
lamp=0
while abs(abs(lam) - abs(lamp)) > 10**(-12):
lamp = lam
sig=m.atan2(((m.cos(u[i+1])*m.sin(lam))**2+(m.cos(u[i])*
(m.sin(u[i+1]))-(m.sin(u[i]))*(m.cos(u[i+1]))*(m.cos(lam)))**2)**(1/2),
(m.sin(u[i]))*(m.sin(u[i+1]))+(m.cos(u[i]))*(m.cos(u[i+1]))*(m.cos(lam)))
alp=m.asin((m.cos(u[i])*(m.cos(u[i+1]))*(m.sin(lam)))/(m.sin(sig)))
sigm=0.5*m.acos(m.cos(sig)-2*(m.sin(u[i])*(m.sin(u[i+1])))/(m.cos(alp)**2))
c=(np.radians(1/(298.257)))*(m.cos(sig)**2)*(4+(np.radians(1/(298.257)))*
(4-3*(m.cos(alp)**2)))/16
lam=abs(laloalt[0][1]-laloalt[1][1])+(1-
c)*(np.radians(1/(298.257)))*(m.sin(sig))*(sig+c*m.sin(sig)*
(m.cos(2*sigm)+c*m.cos(sig)*(2*(m.cos(2*sigm)**2)-1)))

litu=((m.cos(alp))**2)*(((np.radians(6378140))**2-((1-(np.radians(1
/(298.257))))*np.radians(6378140))**2)/(((
1-(np.radians(1/(298.257))))*np.radians(6378140))**2))**2
biga=1+((u[i]**2)/16384)*(4096+(litu)*((litu)*(320-175*(litu))-768))
bigb=((litu)/1024)*(256+(litu)*((litu)*(74-47*(litu))-128))
dsig=(bigb*m.sin(sig))*(m.cos(2*sigm)+0.25*bigb*(m.cos(sig)*
(2*(m.cos(2*sigm))**2-1)-(1/6)*bigb*m.cos(2*sigm)*(4*
(m.sin(sig)**2)-3)*(4*(m.cos(2*sigm)**2)-3)))
s[i+1]=((1-(np.radians(1/(298.257))))*np.radians(6378140))*biga*(sig-dsig)
return s

def distbetp(dta,a):
"""Shows the distance between gps locations"""
b = max(a-1,0)
return dta[b]

def gpsloc(datta):
"""this function takes the walking data and converts it for the plwalk function to then plot"""

laloalt = list(zip(datta.loc[:, 'Latitude (°)'],
datta.loc[:, 'Longitude (°)'], datta.loc[:, 'Altitude WGS84 (m)']))

xax = np.zeros(datta.shape[0])
yax = np.zeros(datta.shape[0])

for i in range(datta.shape[0]):
xax[i]=(laloalt[i][2]
+6378137)*(m.cos((laloalt[i][0])*(m.pi/180)))*(m.cos((laloalt[i][1])*(m.pi/180)))
yax[i]=(laloalt[i][2]
+6378137)*(m.cos((laloalt[i][0])*(m.pi/180)))*(m.sin((laloalt[i][1])*(m.pi/180)))
return xax, yax

def plwalk(vel,u_title,u_name):
"""input for this function is the data exporte from the function gpsloc"""
plt.figure()
vmovx = pd.DataFrame(vel[0])
vmovy = pd.DataFrame(vel[1])
plt.plot(vmovx,vmovy, color='red')
plt.title(u_title)
plt.xlabel('xlable')
plt.ylabel('ylable')
plt.grid()
plot = input("Do you want to save the plot? (yes/no): ").strip().lower()

if plot == 'yes':
fpath = input("enter where to save: ").strip()
if not os.path.exists(fpath):
print("Directory does not exist, try again")
else:
filpath = os.path.join(fpath, u_name)
plt.savefig(filpath, format='png', dpi=600)
print(f"Plot saved as {filpath}")
else:
print("Plot not saved.")
Loading
Loading