-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrent_data_conversion_to_complex.py
More file actions
28 lines (21 loc) · 1 KB
/
Copy pathcurrent_data_conversion_to_complex.py
File metadata and controls
28 lines (21 loc) · 1 KB
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
import math
import numpy as np
import pandas as pd
def make_complex_value(angle, if_module):
return if_module * complex(real=math.cos(math.radians(angle)), imag=math.sin(math.radians(angle)))
files_name_list = [f'ByPhasisCurrentData/Phasis-{index}.xlsx' for index in range(2, 4)]
for file_name in files_name_list:
file = pd.ExcelFile(file_name)
distortions = pd.read_excel(file, file.sheet_names[0])
angles = pd.read_excel(file, file.sheet_names[1])
data = []
for line in range(0, len(distortions.columns)):
data_line = []
for i in range(len(distortions)):
distortion = distortions[distortions.columns[line]][i]
angle = angles[angles.columns[line]][i]
data_line.append(make_complex_value(angle=angle, if_module=distortion))
data.append(data_line)
new_df = pd.DataFrame(data=np.array(data).T.tolist())
with pd.ExcelWriter(file_name, mode='a') as writer:
new_df.to_excel(writer, sheet_name="Complex Currents", index=False)