forked from djgroen/facs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
46 lines (35 loc) · 1.17 KB
/
generator.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
import argparse
import os
import numpy as np
import yaml
def population_generator(region, config_file, output_file):
with open(config_file, "r") as ff:
pars = yaml.safe_load(ff)
pop = []
while len(pop) < int(pars["population"]):
rr = np.random.normal(
float(pars["mu"]), float(pars["sigma"]), int(pars["population"])
)
rr = [x for x in rr if x > 0 and x < 91]
pop.extend(rr)
pop = pop[: pars["population"]]
pop = [int(x) for x in pop]
with open(output_file, "w") as gg:
gg.write("Age,{}".format(region))
gg.write("\n")
for i in range(91):
gg.write("{},{}".format(i, pop.count(i)))
gg.write("\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--location", action="store", default="test_calarasi", help="Name of location."
)
parser.add_argument(
"--cwd", action="store", default=".", help="Current working directory"
)
args = parser.parse_args()
print(args)
population_generator(
args.location, "covid_data/population_generator.yml", "covid_data/age-distr.csv"
)