Created
June 6, 2025 16:43
-
-
Save pukpr/aa5338a9f9854c90aca18ff04def72b1 to your computer and use it in GitHub Desktop.
Size of tidal factor over (Tropical, Perigee, Nodal) Brillouin zones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| # Data as multiline string (X, Y, Z, Diameter) | |
| data = """ | |
| 1 0 0 0.212566 | |
| 1 0 1 0.504368 | |
| 0 2 2 0.514627 | |
| 0 -2 2 0.089845 | |
| 0 0 2 0.135412 | |
| 2 0 1 0.51246 | |
| 2 0 0 0.413257 | |
| 2 0 2 0.248128 | |
| 1 -1 0 0.201939 | |
| 2 -2 0 0.076616 | |
| 0 0 1 0.448228 | |
| 2 2 2 0.249092 | |
| 1 1 0 0.223009 | |
| 0 2 0 0.106861 | |
| 2 -1 1 0.075938 | |
| 0 2 1 0.094287 | |
| 1 -1 1 0.068607 | |
| 1 -1 1 0.174236 | |
| 0 1 1 0.316888 | |
| 1 1 1 0.331479 | |
| 0 1 -1 0.233693 | |
| 0 -1 0 1 | |
| 0 -2 1 0.344451 | |
| 1 -1 2 0.305368 | |
| 0 -2 1 0.150287 | |
| 2 2 1 0.101558 | |
| 1 2 1 0.2333 | |
| 2 -2 1 0.14823 | |
| 1 -2 1 0.07895 | |
| """ | |
| # Parse the data | |
| lines = data.strip().split('\n') | |
| X, Y, Z, D = [], [], [], [] | |
| for line in lines: | |
| xi, yi, zi, di = map(float, line.split()) | |
| X.append(xi) | |
| Y.append(yi) | |
| Z.append(zi) | |
| D.append(di) | |
| X = np.array(X) | |
| Y = np.array(Y) | |
| Z = np.array(Z) | |
| D = np.array(D) | |
| fig = plt.figure(figsize=(10, 8)) | |
| ax = fig.add_subplot(111, projection='3d') | |
| # Plot spheres at each (X, Y, Z) location with given diameter D | |
| for xi, yi, zi, di in zip(X, Y, Z, D): | |
| # Sphere parameterization | |
| u, v = np.mgrid[0:2*np.pi:24j, 0:np.pi:12j] | |
| r = di / 2.0 # Convert diameter to radius | |
| xs = xi + r * np.cos(u) * np.sin(v) | |
| ys = yi + r * np.sin(u) * np.sin(v) | |
| zs = zi + r * np.cos(v) | |
| ax.plot_surface(xs, ys, zs, color=plt.cm.viridis(di / D.max()), alpha=0.7, linewidth=0, shade=True) | |
| # Draw line from origin to center of sphere | |
| ax.plot([0, xi], [0, yi], [0, zi], color='k', linewidth=0.8, linestyle='-') | |
| # Set grid, labels, and limits | |
| ax.set_xlabel('Tropical') | |
| ax.set_ylabel('Perigee') | |
| ax.set_zlabel('Nodal') | |
| ax.set_title('3D Integer Grid: Spheres with Given Diameters and Origin Lines') | |
| ax.set_xticks(np.unique(X)) | |
| ax.set_yticks(np.unique(Y)) | |
| ax.set_zticks(np.unique(Z)) | |
| ax.set_box_aspect([1, 1, 1]) | |
| margin = 1 | |
| ax.set_xlim(X.min()-margin, X.max()+margin) | |
| ax.set_ylim(Y.min()-margin, Y.max()+margin) | |
| ax.set_zlim(Z.min()-margin, Z.max()+margin) | |
| plt.tight_layout() | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment