-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataLoadFunc_v2.py
52 lines (39 loc) · 1.55 KB
/
DataLoadFunc_v2.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
data file readout in the appropriate form
@author: Ksenija Kovalenka
"""
import numpy as np
def load_data(file_path, npartitions, nkx, nky, nkz):
nkpt = nkx*nky*nkz
reals = np.zeros(shape=(nkpt,npartitions))
complexs = np.zeros(shape=(nkpt,npartitions))
alpha = np.zeros(shape=(nkpt,npartitions))
data = open(file_path, 'r')
for a in range(0, npartitions):
for kz in range(0, nkpt):
reals[kz,a] = float(data.read(10))
complexs[kz,a] = float(data.read(13))
alpha[kz,a] = float(data.read(7))
data.close()
data_tensor = np.zeros((npartitions, 2*nkz, nkx, nky))
alpha_tensor = np.zeros((npartitions))
phases_classification = np.zeros((npartitions,1))
for i in range(npartitions):
reals_1 = np.reshape(reals[::2,i], (11,11))
reals_0 = np.reshape(reals[1::2,i], (11,11))
complexs_1 = np.reshape(complexs[::2,i], (11,11))
complexs_0 = np.reshape(complexs[1::2,i], (11,11))
data_tensor[i, 0] = reals_1
data_tensor[i, 1] = reals_0
data_tensor[i, 2] = complexs_1
data_tensor[i, 3] = complexs_0
alpha_tensor[i] = alpha[0,i]
if alpha[0,i] < 0.77:
phases_classification[i] = 0
else:
phases_classification[i] = 1
#print(phases_classification[5000-5:5000+5])
return data_tensor, phases_classification, alpha_tensor
#data, classifications = load_data('NN_data_equal_v0.dat', 10000, 11, 11, 2)