-
Notifications
You must be signed in to change notification settings - Fork 1
/
notnecessary002a_save_h5_heatloads.py
63 lines (45 loc) · 1.9 KB
/
notnecessary002a_save_h5_heatloads.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
import sys, os
BIN = os.path.expanduser("../")
sys.path.append(BIN)
import LHCMeasurementTools.TimberManager as tm
import LHCMeasurementTools.LHC_Energy as LHC_Energy
import LHCMeasurementTools.LHC_BCT as LHC_BCT
import LHCMeasurementTools.LHC_Heatloads as LHC_Heatloads
import h5py
import numpy as np
import pickle
h5folder = 'heatloads_fill_h5s'
fills_pkl_name = 'fills_and_bmodes.pkl'
with open(fills_pkl_name, 'rb') as fid:
dict_fill_bmodes = pickle.load(fid)
if not os.path.isdir(h5folder):
os.mkdir(h5folder)
for filln in sorted(dict_fill_bmodes.keys()):
print('Fill n.',filln)
h5filename = h5folder+'/heatloads_all_fill_%d.h5'%filln
if dict_fill_bmodes[filln]['flag_complete'] is False:
print("Fill incomplete --> no h5 convesion")
continue
if os.path.isfile(h5filename) and dict_fill_bmodes[filln]['flag_complete'] is True:
print("Already complete and in h5")
continue
try:
dict_fill_data = {}
dict_fill_data.update(tm.parse_timber_file('fill_basic_data_csvs/basic_data_fill_%d.csv'%filln, verbose=False))
dict_fill_data.update(tm.parse_timber_file('fill_heatload_data_csvs/heatloads_fill_%d.csv'%filln, verbose=False))
varlist = []
varlist += LHC_BCT.variable_list()
varlist += LHC_Energy.variable_list()
for kk in list(LHC_Heatloads.variable_lists_heatloads.keys()):
varlist+=LHC_Heatloads.variable_lists_heatloads[kk]
dict_to_h5 = {}
for varname in varlist:
#~ print varname
dict_to_h5[varname+'!t_stamps'] = np.float_(dict_fill_data[varname].t_stamps)
dict_to_h5[varname+'!values'] = dict_fill_data[varname].float_values()
with h5py.File(h5filename, 'w') as fid:
for kk in list(dict_to_h5.keys()):
fid[kk] = dict_to_h5[kk]
except IOError as err:
print('Skipped!!! Got:')
print(err)