-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpetcResults.py
143 lines (104 loc) · 4.95 KB
/
petcResults.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 11 12:44:28 2014
Copyright (C) 2014-2015 Anna Matuszyńska, Oliver Ebenhöh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (license.txt). If not, see <http://www.gnu.org/licenses/>.
"""
import matplotlib.pyplot as plt
import numpy as np
from misc import pH
from simulate import Sim
class PETCResults(Sim):
def __init__(self,s):
self.model = s.model
self.results = s.results
self.par = s.model.par
def plotph(self, r=None):
""" plot lumenal pH """
if r == None:
r = range(len(self.results))
for i in r:
plt.plot(self.results[i]['t'],pH(self.results[i]['y'][:,5]))
def plotRel(self, r=None):
""" plot results of integration
six plots for reduced PQ, PC, Fd, and concentration of ATP and NADPH + cross section of PSII
"""
if r == None:
r = range(len(self.results))
for i in r:
t = self.results[i]['t']
y = self.results[i]['y']
if i == 0: # unique labels
plt.plot(t, 1 - y[:,0]/self.par.PQtot, color='red', label = 'PQred') # PQred
plt.plot(t, 1 - y[:,1]/self.par.PCtot, color='blue', label = 'PCred') # PC
plt.plot(t, 1 - y[:,2]/self.par.Fdtot, color='yellow', label = 'Fdred') # Fd
plt.plot(t, y[:,3]/self.par.APtot, color='magenta', label = 'ATP') # ATP
plt.plot(t, y[:,4]/self.par.NADPtot, color='cyan', label = 'NADPH') # NADPH
plt.plot(t, y[:,6], color='green', label = 'CSII') # antennae on photosystem II
else:
plt.plot(t, 1 - y[:,0]/self.par.PQtot, color='red') # PQred
plt.plot(t, 1 - y[:,1]/self.par.PCtot, color='blue') # PC
plt.plot(t, 1 - y[:,2]/self.par.Fdtot, color='yellow') # Fd
plt.plot(t, y[:,3]/self.par.APtot, color='magenta') # ATP
plt.plot(t, y[:,4]/self.par.NADPtot, color='cyan') # NADPH
plt.plot(t, y[:,6], color='green') # antennae on photosystem II
plt.xlabel('time')
plt.title('Temporal evolution of state variables')
plt.legend(loc= 'best')
def plotV(self, v, r=None):
""" plot selected reaction rate """
if r == None:
r = range(len(self.results))
for i in r:
t = self.results[i]['t']
y = self.results[i]['y']
l = self.results[i]['lfn']
V = [self.model.rates(y[i],l.lightintensity(t[i]))[v] for i in range(len(t))]
plt.plot(t,V)
def fluo(self, r=None):
""" return values required for plotting fluorescence traces
return: time vector, overall fluorescence from PSII, fluorescence emitted from open reaction centres,
fluorescence emitted from closed reaction centres and state of the PSII
"""
if r == None:
r = range(len(self.results))
FM = []
F0 = []
F = []
T = []
Bst = np.array([]).reshape(0, 4)
for i in r:
t = self.results[i]['t']
y = self.results[i]['y']
l = self.results[i]['lfn']
P = y[:,0]
anT = y[:,6] # NEVER USE T for antennae. it is reserved for time
L = y[:,7]
H = y[:,5]
Q = self.model.quencher(L, H)
cs2 = self.model.crossSectionSimple(anT)
B_ = [self.model.ps2states(P[i], Q[i], cs2[i] * l.lightintensity(t[i])) for i in range(len(t))]
B = np.array(B_)
Fzero = cs2 * self.par.kF / (self.par.kF + self.par.kH0 + self.par.kH * Q + self.par.k2) * B[:, 0]
Fm = cs2 * self.par.kF / (self.par.kF + self.par.kH0 + self.par.kH * Q) * B[:, 2]
T = np.hstack([T, t])
F0 = np.hstack([F0, Fzero])
FM = np.hstack([FM, Fm])
Bst = np.vstack([Bst, B])
F = [x + y for x, y in zip(FM, F0)] # could hstack but was comparing two methods
return T, F, FM, F0, Bst
def plotFluo(self):
""" plot fluorescence trace, uses function fluo to calculate FM and F0 """
T, F, _, _, _= self.fluo()
plt.plot(T, F/max(F), 'r')
plt.xlabel('time')
plt.title('Fluorescence trace')