15
15
keep_at_destination , reset_destinations
16
16
from population import initialize_population , initialize_destination_matrix ,\
17
17
set_destination_bounds , save_data , save_population , Population_trackers
18
- from visualiser import build_fig , draw_tstep , set_style
18
+ from visualiser import build_fig , draw_tstep , set_style , plot_sir
19
19
20
20
#set seed for reproducibility
21
21
#np.random.seed(100)
@@ -33,11 +33,8 @@ def __init__(self, *args, **kwargs):
33
33
self .pop_tracker = Population_trackers ()
34
34
35
35
#initalise destinations vector
36
- self .destinations = initialize_destination_matrix (self .Config .pop_size , 1 )
36
+ self .destinations = initialize_destination_matrix (self .Config .pop_size , 1 )
37
37
38
- self .fig , self .spec , self .ax1 , self .ax2 = build_fig (self .Config )
39
-
40
- #set_style(self.Config)
41
38
42
39
43
40
def population_init (self ):
@@ -50,6 +47,10 @@ def tstep(self):
50
47
'''
51
48
takes a time step in the simulation
52
49
'''
50
+
51
+ if self .frame == 0 and self .Config .visualise :
52
+ #initialize figure
53
+ self .fig , self .spec , self .ax1 , self .ax2 = build_fig (self .Config )
53
54
54
55
#check destinations if active
55
56
#define motion vectors if destinations active and not everybody is at destination
@@ -187,6 +188,12 @@ def run(self):
187
188
print ('total infectious: %i' % len (self .population [(self .population [:,6 ] == 1 ) |
188
189
(self .population [:,6 ] == 4 )]))
189
190
print ('total unaffected: %i' % len (self .population [self .population [:,6 ] == 0 ]))
191
+
192
+
193
+ def plot_sir (self , size = (6 ,3 ), include_fatalities = False ,
194
+ title = 'S-I-R plot of simulation' ):
195
+ plot_sir (self .Config , self .pop_tracker , size , include_fatalities ,
196
+ title )
190
197
191
198
192
199
0 commit comments