%%capture
# Define map resolution
n_lon = 360
n_lat = 180
functional = GravityAnomaly()
# Define maximum values
zlim = 0.05
levels = np.linspace(-zlim, zlim, 101)
# Plot dummy map
ax = plotting._get_basemap_axes()
[lon, lat, z] = sh_list[0].synthesis(n_lon, n_lat, functional)
contour = ax.contourf(lon, lat, z, levels=levels, alpha=0.6, cmap='seismic', antialiased=True)
cbar = plt.colorbar(contour, ax=ax, shrink=0.5)
plotting._adjust_colorbar_ticks(cbar)
cbar.set_label("$\\Delta g$ [mGal]")
# Get ax object
ax = plt.gca()
fig = plt.gcf()
def update(frame):
global contour, cbar
# Remove previous map
contour.remove()
# Plot new map
[lon, lat, z] = sh_list[frame].synthesis(n_lon, n_lat, functional)
contour = ax.contourf(lon, lat, z, levels=levels, alpha=0.6, cmap='seismic', antialiased=True)
ax.set_title(date[frame])
# Return values
return [contour]
# Create and save animation
ani = FuncAnimation(fig, update, frames=len(sh_list), blit=True)
ani.save("aod1b-2025-01.gif", writer=PillowWriter(fps=10))