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
| #! /usr/bin/env python
| import sys
| from typing import Final
| import numpy as np
| from numpy import pi
| import matplotlib.pyplot as plt
|
|
| amplitude: tuple[float, float] = (1, 1)
| # frequent, some values (-3, 5) (-3, 8) (3, 11)
| omega: tuple[float, float] = (3, 11)
|
| # phase
| phi: tuple[float, float] = (pi/2, 3*pi/4)
|
| N: Final[int] = 360*2
| T = np.linspace(0, 2*pi, num=N)
| x = amplitude[0] * np.cos(omega[0]*T + phi[0])
| y = amplitude[1] * np.cos(omega[1]*T + phi[1])
|
| # plot
| fig, ax = plt.subplots()
| ax.plot(x, y, linewidth=2.0)
|
| write_to_file = False
| if write_to_file:
| output_dir = "../../2024/python-output"
| image_filename = f"{output_dir}/{sys.argv[0].replace('.py','.pdf')}"
| plt.savefig(image_filename)
|
| plt.show()
|
|