Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
n (int): dimension is n x n
mode (str): sampling mode; DH or GLQ
Returns:
theta, phi (1D arrays): polar and azimuthal angles
"""
assert n % 2 == 0
j = np.arange(0, n)
if mode == 'DH':
return j*np.pi/n, j*2*np.pi/n
elif mode == 'ours':
return (2*j+1)*np.pi/2/n, j*2*np.pi/n
elif mode == 'GLQ':
from pyshtools.shtools import GLQGridCoord
phi, theta = GLQGridCoord(n-1)
# convert latitude to [0, np.pi/2]
return np.radians(phi+90), np.radians(theta)
elif mode == 'naive':
# repeat first and last points; useful for plotting
return np.linspace(0, np.pi, n), np.linspace(0, 2*np.pi, n)