-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow.py
47 lines (40 loc) · 1.2 KB
/
workflow.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
'''
workflow for convergence, sensitivity analysis etc
'''
import os
import calibration.POM as POM
import experiments.convergence as convergence
import imp
import copy
import code
import numpy as np
import pandas as pd
import pickle
import copy
def main():
exp_name = 'test'
pom_nreps = 2
pom_nsim = 100
## 1. select models from POM
# assume the POM has been run already
params = load_POM_params(exp_name, pom_nsim, pom_nreps)
print('{} model(s) from POM'.format(len(params)))
## 2. convergence analysis
nsim_req = convergence.main(params)
code.interact(local=dict(globals(), **locals()))
def load_POM_params(exp_name, pom_nsim, pom_nreps):
'''
select all parameter sets within (1-threshold)*100 percent
of the best model
the threshold is specified in the POM code.
'''
outdir = '../outputs/{}/POM/{}_{}reps/'.format(exp_name, pom_nsim, pom_nreps)
params = []
for root, dirs, files in os.walk(outdir):
for fnam in files:
if ('input_params_' in fnam) and ('.pkl' in fnam):
with open(outdir + fnam, 'rb') as f:
params.append(pickle.load(f))
return params
if __name__ == '__main__':
main()