-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
83 lines (67 loc) · 2.02 KB
/
main.py
File metadata and controls
83 lines (67 loc) · 2.02 KB
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
import matplotlib.pyplot as plt
import seaborn as sns
import json
import numpy as np
# xpoints = np.array([0,5])
# ypoints = np.array([0,250])
#
# plt.plot(xpoints, ypoints)
# plt.show()
# open json file
# pre: file name (in json)
def loadJson(jsonFile):
with open(jsonFile, 'r') as fileData:
data = fileData.read()
obj = json.loads(data)
# Output a graph based on values
# pre: numpy arrays that represent x and y data points
# post: plots the data
# Allows graphing PV and FV
# PV-plot -> graph(volume, pressure)
# FV-plot -> graph(volume, flow)
def graph(xValues, yValues):
plt.plot(xValues, yValues)
plt.show()
# def createDic(volume, time, flow, pressure, volTime):
# if volume.length == time.length :
# for x in range(0, volume.length - 1):
# volTime[time[x]] = volume[x], flow[x], pressure[x]
def compliance(pressure, volume):
deltaV = volume[len(volume) - 1] - volume[0]
deltaP = pressure[len(pressure) - 1] - pressure[0]
compliance = deltaV / deltaP
return compliance
def peakInspirationPressure(pressure):
maxValue = 0
for x in range(len(pressure)):
if pressure[x] > maxValue:
maxValue = pressure[x]
return maxValue
# Residual volume is for Flow V Volume
# pre: a NumPy array (x axis) of Volume(t)
# a NumPy array (y-axis) of Flow
# def residualVolume(volume, flow):
# for (x, y) in zip(volume, flow):
# if x != 0 and y == 0 :
# return x
#
# return "no data found"
#
# # Total Lung Capacity
# # pre: a numpy array (x-axis) of Time
# # a numpy array (y-axis) of volume
# def totalLungCapacity(volume):
# return max(volume)
# pressure volume code
# Testing
volume = np.array([0,1,2,3,4,5])
flow = np.array([0,1,3,5,6,0])
time = np.array([1,2,3,4,5,6])
pressure = np.array([0,1,3,5,6,0])
volTime = {}
# cock = residualVolume(volume, flow)
# print(cock)
#given volume(t), pressure(t), and flow(t)
# need to create flow(volume)
# json data: time increments of 0.1 or
# volume, flow, or pressure