<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 3D Spherical Harmonic Plots
This example demonstrates how to generate a simple 3-dimensional plot of the data in an SHGrid class instance. We start by generating a set of spherical harmonic coefficients that is zero, whith the exception of a single harmonic
Step1:  To plot the data, we first expand it on a grid, and then use the method plot3d()
Step2:  Let's try a somewhat more complicated function. Here we will calculate a random realization of a process whose power spectrum follows a power law with exponent -2
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from __future__ import print_function # only necessary if using Python 2.x
import numpy as np
from pyshtools import SHCoeffs
lmax = 30
coeffs = SHCoeffs.from_zeros(lmax)
coeffs.set_coeffs(values=[1], ls=[10], ms=[0])
Explanation: 3D Spherical Harmonic Plots
This example demonstrates how to generate a simple 3-dimensional plot of the data in an SHGrid class instance. We start by generating a set of spherical harmonic coefficients that is zero, whith the exception of a single harmonic:
End of explanation
grid = coeffs.expand()
fig, ax = grid.plot3d(elevation=20, azimuth=30)
Explanation: To plot the data, we first expand it on a grid, and then use the method plot3d():
End of explanation
ldata = 30
degrees = np.arange(ldata+1, dtype=float)
degrees[0] = np.inf
power = degrees**(-2)
coeffs2 = SHCoeffs.from_random(power)
grid2 = coeffs2.expand()
fig, ax = grid2.plot3d(elevation=20, azimuth=30)
Explanation: Let's try a somewhat more complicated function. Here we will calculate a random realization of a process whose power spectrum follows a power law with exponent -2:
End of explanation
<END_TASK>