-
Notifications
You must be signed in to change notification settings - Fork 2
/
Uncertainty_propagation2.py
62 lines (42 loc) · 2.07 KB
/
Uncertainty_propagation2.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
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 22 15:49:18 2017
Process setting a new automatic inference process:
1- Create a n model folder replicates eg. \Model_1 \Model_2 ... \Modeln
2- Copy an instance of Tornado.Main inside each model folder. Change inside this file Prop Name="CalcVarPrefix" Value="Model1"
3- Create a folder called \inference where Parallel_WESTRunningPyWrapper.py and ModelRun.py are located
4- Inside Parallel_WESTRunningPyWrapper.py change the model experiment name to the one chosen in the WEST model.
5- Instanciate n models and run them
Forward uncertainty propagation scheme (parallel)
@author: A. Moreno Rodenas, TUDelft
"""
#%% set modelrepository path
repPath = 'C:\Users\localadmin.TUD278183\Desktop\GitProjects\pyWest'
#%%General Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
plt.style.use('ggplot')
import sys
import timeit
import json
sys.path.insert(0, repPath + '\AutomatedCall')
from Parallel_WESTRunningPyWrapper import ModelInstances
#%% DEFINE SA TIME
Dateseries = '01-jan-2012_31-Dec-2012'
TimeWindow = '01-May-2012_30-Aug-2012'
Initial = TimeWindow[:11]
Final = TimeWindow[12:]
#%% Load parameter sampling scheme
SamplingLayout = pd.read_csv('C:\\Users\\localadmin.TUD278183\\Desktop\\GitProjects\\pyWEST\\500SamplesUP.txt', index_col = [0])
#%% CREATE Model instance with n replicates
ModelInstance = ModelInstances(['Model_dummy_1'], modelPath = repPath, modelInternalName = 'Model_dummy_1.Dynamic.ObjEval.Exp')
#%%
# Parameters
Timelist = {'StartTime':float((pd.to_datetime(Initial) - pd.to_datetime(Dateseries[:11])).days),'StopTime':float((pd.to_datetime(Final) - pd.to_datetime(Dateseries[:11])).days)}
Parameterlist = {'n':0.07, 'KBODs':0.55, 'KLmin':0.1, 'KO2':1.6, 'SOD':1}
#%% Model Run
start_timer = timeit.default_timer()
ModelInstance.model_run(Parameterlist, Timelist, ThreadingPool = 4, ParamDatabase = os.path.join(repPath, '500SamplesUPReduced.txt'))
print 'Simulation time : {} seconds'.format(timeit.default_timer() - start_timer)