forked from YehyaSHARIF/Sensor_Characterization_Plateform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
traitement.py
93 lines (73 loc) · 2.8 KB
/
traitement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
@author: Yehya SHARIF
This file represents all required functions to calculate the strain
and the displacement after the data aquisition phase.
"""
def Strain_Calculation(position_list,electrical_list,lo):
"""
Description:this function calculate the strain(pourcentage) at
each step of the test
Parameters
----------
lo: float in mm
the first lenght measured by the caliper
position_list : float list in mm
the list returned by the traction and repulsion function(it can be from the slider or the laser sensor)
electrical_list : float list in kohm
the list returned by the traction and repulsion function
Returns
-------
strain_list : float list
the calculated strain in percentage
"""
strain_list=[None]*len(position_list)
z1=position_list[0] #the first position
for i in range (len(strain_list)):
z2=position_list[i]# the position at each step
strain_list[i]=round(abs(((z2-z1)*100)/lo),2)
return strain_list
def Displacement_Calculation(position_list,electrical_list):
"""
Description:
this function calculate the displacement at each step of
the test
Parameters
----------
position_list : float list in mm
the list returned by the traction and repulsion function(it can be from the slider or the laser sensor)
electrical_list : float list in kohm
the list returned by the traction and repulsion function
Returns
-------
displacement_list : float list
the calculated displacement in mm
"""
displacement_list=[None]*len(position_list)
z1=position_list[0] #the first position
for i in range(len(displacement_list)):
z2=position_list[i] #the position at each step
displacement_list[i]=round(abs(z2-z1),2)
return displacement_list
def shift(Sensor_reading_list):
"""
Description:
this function shift the measured position t obtain a full
list of positive positions to facilate the calculation of
displacement and the strain
use this function only if you obtain negative
position from the laser sensor
Parameters
----------
Sensor_reading_list : float list negative and positive one
the list that contains the negative and positive output position
measured from the laser sensor
Returns
-------
Sensor_reading_list : positive float list
the list that contains only the positive output
"""
#plus petit nombre negative
shift=abs(Sensor_reading_list[len(Sensor_reading_list)])
for i in range(len(Sensor_reading_list)):
Sensor_reading_list[i]+=shift #add the shift to obtain a positive float list
return Sensor_reading_list