import spharpy
import pyfar as pf
import matplotlib.pyplot as plt
import numpy as np
definition = spharpy.SphericalHarmonicDefinition(n_max=7)
soundfield = spharpy.SphericalHarmonics.from_definition(
    definition, pf.Coordinates(1, 0, 0))
a_nm = soundfield.basis
steering = spharpy.SphericalHarmonics.from_definition(
    definition, pf.Coordinates.from_spherical_elevation(
        np.linspace(0, 2*np.pi, 500), 0, 1))
Y_steering = steering.basis
d_nm = spharpy.beamforming.rE_max_weights(definition.n_max)
beamformer = np.squeeze(Y_steering @ np.diag(d_nm))
beamformer_output = beamformer @ a_nm.T
ax = plt.axes(projection='polar')
ax.plot(steering.coordinates.azimuth,
        20*np.log10(np.abs(beamformer_output)))
ax.set_rticks([-50, -25, 0])
ax.set_theta_zero_location('N')
ax.set_xlabel('Azimuth in degree')
