-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun.py
59 lines (44 loc) · 1.47 KB
/
run.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
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 15:52:39 2020
@author: metalcorebear
"""
from model import COVID_model
import model_params
import argparse
import os
from datetime import date as datemethod
from datetime import datetime
import mesa_SIR.calculations_and_plots as c_p
# Specify arguments
def get_path():
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--output', help='Enter the output path.', required=False)
args = vars(parser.parse_args())
print (args)
output_path = str(args['output'])
return output_path
# Generate output file name parameters
output_path = get_path()
today = datemethod.strftime(datetime.utcnow(), '%Y%m%dZ%H%M%S')
# Number of steps to run model.
steps = model_params.parameters['steps']
filename = 'COVID_output_' + today + '.csv'
output_file = os.path.join(output_path, filename)
# Instantiate model
meme_model = COVID_model()
for i in range(steps):
print('Running step {}'.format(str(i)))
meme_model.step()
# Generate output
output_data = meme_model.datacollector.get_model_vars_dataframe()
c_p.save_data(output_data, output_path = output_path, filename =filename)
print (output_data)
print('Filename:')
print(filename)
print('Plotting...')
title = 'COVID ABM Model Output'
c_p.plot_SIR(output_data, title, output_path)
c_p.plot_R0(output_data, title, output_path)
c_p.plot_severe(output_data, title, output_path)
print('You are great!!')