-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_csv.py
43 lines (32 loc) · 1.01 KB
/
create_csv.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
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
colors = list(mcolors.TABLEAU_COLORS)
def show_points(b, n, m):
plt.scatter(b.T[0], b.T[1], c=colors[:n], s=m)
plt.xlim(-5, 5)
plt.ylim(-5, 5)
plt.show()
def state_to_DataFrame(S, n, m):
x = S[:n]
y = S[n:2 * n]
vx = S[2 * n:3 * n]
vy = S[3 * n:4 * n]
dic = {'x': x, 'y': y, 'vx': vx, 'vy': vy, 'm': m}
df = pd.DataFrame(dic)
return df
def main():
n = int(input('enter n: '))
b = 2 * np.array([[np.cos(2.0 * np.pi * i / n),
np.sin(2.0 * np.pi * i / n)] for i in range(n)])
v = np.array([[-np.sin(2.0 * np.pi * i / n),
np.cos(2.0 * np.pi * i / n)] for i in range(n)])
m = np.ones(n)
show_points(b, n, m)
S0 = np.concatenate((b[:, 0], b[:, 1], v[:, 0], v[:, 1]))
df = state_to_DataFrame(S0, n, m)
print(df)
df.to_csv(str(n) + 'th-root_of_unity.csv', index=False)
if __name__ == '__main__':
main()