-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimize_generation_transport.py
74 lines (53 loc) · 2.26 KB
/
optimize_generation_transport.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
62
63
64
65
66
67
68
69
70
# %%
from src.GenerationAttenuationOptimizer import GenerationAttenuationOptimizer
from pathlib import Path
import sys
import datetime
# %%
cwd = Path.cwd()
# %%
args = sys.argv[1:]
contaminant = args[0]
#conca = args[1:]
conca = args[1]
if len(contaminant) == 0:
raise ValueError('Especifica valor de contaminant')
if len(conca) == 0:
raise ValueError('Especifica valor de conques a generar simulacio')
#txtinout_path = Path().resolve() / 'data' / 'txtinouts' / f'Txtinout_{conca}'
#compound_generator_path = Path().resolve().parent / 'traca' / 'traca'/ 'inputs compound generator'
txtinout_path = Path().resolve() / 'scripts' / 'traca_contaminacio' / 'data' / 'txtinouts' / f'TxtInOut_{conca}'
compound_generator_path = Path().resolve() / 'scripts' / 'traca' / 'traca'/ 'inputs compound generator'
removal_rate_path = compound_generator_path / 'inputs' / 'atenuacions_generacions.xlsx'
channels_geom_path = cwd / 'data' / 'rivs1' / 'canals_tot_ci.shp'
recall_points_path = compound_generator_path / 'inputs' / 'recall_points.xlsx'
edar_data_path = compound_generator_path / 'inputs' / 'edar_data.xlsx'
#make folder name day with day and time
current_datetime = datetime.datetime.now()
parent_dir = '/home/jsalo/calibracio_contaminants/scripts/tmp/'
folder_name = contaminant + '_' + conca + '_' + current_datetime.strftime("%Y-%m-%d_%H-%M-%S")
folder_path = Path(parent_dir + folder_name)
folder_path.mkdir(parents=True, exist_ok=True)
#make file for saving results
results_file = folder_name + '.txt'
results_file_path = Path(parent_dir + results_file)
results_file_path.touch(exist_ok=True)
a = GenerationAttenuationOptimizer(
conca,
contaminant,
txtinout_folder = txtinout_path,
removal_rate_path = removal_rate_path,
compound_generator_path = compound_generator_path,
recall_points_path = recall_points_path,
edar_data_path = edar_data_path,
results_file_path = results_file_path,
channels_geom_path = cwd/'scripts'/'traca_contaminacio'/'data'/'rivs1'/'canals_tot_ci.shp',
tmp_path = folder_path,
compound_features_path = cwd/'scripts'/'traca_contaminacio'/'data'/'compound_features.xlsx',
lod_path = cwd/'scripts'/'traca_contaminacio'/'data'/'lod.xlsx',
n_gen = 800,
n_workers = 4,
)
# %%
res = a.minimize()
print(res)