-
Notifications
You must be signed in to change notification settings - Fork 3
/
temp_combine.py
66 lines (46 loc) · 1.56 KB
/
temp_combine.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
import os
import en_utilities as um
import pandas as pd
import shutil
import numpy as np
import stat
import subprocess
import en_utilities as um
# Input parameters:
# -----------------
project = 'EN2_x'
study_root = 'xenergy1_'
sites = ['F'] #, 'G'] # ,'H','I','J']
# Establish paths etc
# -------------------
new_project = project+'_hpc'
base_path = 'C:\\Users\\z5044992\\Documents\\MainDATA\\DATA_EN_4\\studies'
# Paths for hpc outputs
np_path = os.path.join(base_path, new_project)
if not os.path.exists(np_path):
os.makedirs(np_path)
i_path = os.path.join(np_path, 'inputs')
hpc_path = os.path.join(np_path, 'transfer','xenergy1')
#loop over sites
for site in sites:
study = study_root + site
# Path for combined output:
o_path = os.path.join(base_path, project, 'outputs', study)
if not os.path.exists(o_path):
os.makedirs(o_path)
so_path = os.path.join(o_path, 'scenarios')
folder_list = [f for f in os.listdir(hpc_path) if 'hpc' in f and study in f and not '.csv' in f]
# -------------------
# copy scenario files
# -------------------
for ff in folder_list:
spath = os.path.join(hpc_path, ff, 'scenarios')
if os.path.exists(spath):
slist = os.listdir(spath)
if len(slist) > 0:
for s in slist:
sf = os.path.join(spath, s)
newname = s.split('_')[0]+'_'+s.split('_')[len(s.split('_'))-1]
nf = os.path.join(so_path, newname)
shutil.move(sf, nf)
fff = os.path.join(hpc_path, ff)