Skip to content

Instantly share code, notes, and snippets.

@nbecker
Created January 20, 2023 16:30
Show Gist options
  • Save nbecker/18006c9a478d1a53e7210c4969c38f3f to your computer and use it in GitHub Desktop.
Save nbecker/18006c9a478d1a53e7210c4969c38f3f to your computer and use it in GitHub Desktop.
_array2.py
import numpy as np
#pythran export getArrayFactor (complex[:], float[:], float[:], float[:,:], float[:,:], float)
#pythran export getArrayFactor (complex[:], float[:], float[:], float, float, float)
def getArrayFactor(W, px, py, theta, phi, L):
theta = np.array (theta)
phi = np.array (phi)
N = px.shape[0]
AF = np.zeros(theta.shape, dtype=complex)
kx = np.sin(theta) * np.cos(phi) * 2.0 * np.pi / L
ky = np.sin(theta) * np.sin(phi) * 2.0 * np.pi / L
for n in range(N):
AF += W[n] * np.exp(-1j * (kx * px[n] + ky * py[n]))
magAF = np.abs(AF)
return magAF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment