forked from zonca/swcarpentry_inflammation_hpc
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathanalyze_inflammation.py
51 lines (36 loc) · 1.32 KB
/
analyze_inflammation.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
import numpy
# configure matplotlib with a non-interactive backend so that it can run on the workers
import matplotlib
#matplotlib.use("agg")
import matplotlib.pyplot
def analyze(filename):
"""Create plot from inflammation data
Load inflammation data from csv, create plots of average, max and min
Parameters
-----------
filename : str
filename of csv data
"""
data = numpy.loadtxt(fname=filename, delimiter=',')
fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))
axes1 = fig.add_subplot(1, 3, 1)
axes2 = fig.add_subplot(1, 3, 2)
axes3 = fig.add_subplot(1, 3, 3)
axes1.set_ylabel('average')
axes1.plot(numpy.mean(data, axis=0))
axes2.set_ylabel('max')
axes2.plot(numpy.max(data, axis=0))
axes3.set_ylabel('min')
axes3.plot(numpy.min(data, axis=0))
fig.tight_layout()
matplotlib.pyplot.savefig(filename.replace("csv", "png"))
matplotlib.pyplot.close(fig)
return filename.replace("csv", "png")
def detect_problems(filename):
data = numpy.loadtxt(fname=filename, delimiter=',')
if numpy.max(data, axis=0)[0] == 0 and numpy.max(data, axis=0)[20] == 20:
print('Suspicious looking maxima!')
elif numpy.sum(numpy.min(data, axis=0)) == 0:
print('Minima add up to zero!')
else:
print('Seems OK!')