# The rotation can also be applied to spherical harmonic data objects
# using the overloaded multiplication operator. This includes the
# class object itself as well as
# :class:`~spharpy.SphericalHarmonicFrequencyData`,
# :class:`~spharpy.SphericalHarmonicTimeData`, and
# :class:`~spharpy.SphericalHarmonicSignal`.
#
# The following example demonstrates the application to an arbitrary
# :class:`~spharpy.SphericalHarmonicFrequencyData` object containing the
# same series expansion in `frequency_data.freq` as above:
#
frequency_data = spharpy.SphericalHarmonicFrequencyData(
    np.atleast_2d(coefficients).T, frequencies=1e3,
    basis_type=definition.basis_type,
    normalization=definition.normalization,
    channel_convention=definition.channel_convention,
    condon_shortley=definition.condon_shortley)
#
# The rotation can now be applied using the `apply` method
#
rotated_frequency_data = R.apply(frequency_data)
#
# or the `*` operator
#
rotated_frequency_data = R * frequency_data
#
# The effect of the rotation can again be visualized by evaluating the
# series expansion on the unit sphere:
#
_, axs = plt.subplots(
    1, 2, subplot_kw={'projection': '3d'}, figsize=(5, 2.5),
    layout='constrained')
spharpy.plot.balloon_wireframe(
    sampling, np.squeeze(Y.basis @ frequency_data.freq),
    ax=axs[0], colorbar=False)
spharpy.plot.balloon_wireframe(
    sampling, np.squeeze(Y.basis @ rotated_frequency_data.freq),
    ax=axs[1], colorbar=False)
