-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmerge.py
46 lines (35 loc) · 1.18 KB
/
merge.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
import time
import numpy as np
import sys
import pickle
import os
import scipy.io
#scipy.io.savemat('/home/myfiles/mydata.mat', mdict={'whatever_data': whatever_data})
def main():
if len(sys.argv) > 1:
_, L, n_step, T = sys.argv
L = int(L); n_step = int(n_step)
T = float(T)
else:
assert False, "error"
tot_number_interval = 32
n_elements = 2**n_step // tot_number_interval
#hx_int = [n_elements*interval_slice, n_elements*(interval_slice+1)]
for interval_slice in range(tot_number_interval):
param = {'L' : L, 'T': T, 'n_step': n_step, 'slice': interval_slice}
file_name = make_file_name(param)
with open(file_name,'rb') as f:
data=pickle.load(f)
mat_file=make_file_name_2(param,ext=".mat")
scipy.io.savemat(mat_file, mdict={'slice_%i'%interval_slice: data})
def make_file_name(param, root="",ext=".pkl",prefix=""):
key_format = {
'L':'{:0>2}',
'T':'{:.3f}',
'slice':'{:0>2}',
'n_step':'{:0>2}'
}
f = [k+"-"+key_format[k].format(param[k]) for k in sorted(key_format)]
return root+prefix+'ES_'+"_".join(f)+ext
if __name__ == "__main__":
main()