<jupyter_start><jupyter_text>Bokeh Tutorial  1.7 Animate **Exercise: Animate the climate map**Create a loop that updates the data source of the `climate_map` through time (for every month and year). You'll need to use the bokeh-server.*Note: when using the output_server make sure that your data source doesn't contain `nans`*<jupyter_code># Imports
import numpy as np
import netCDF4

from bokeh.plotting import vplot, hplot, cursession, output_server, show

from viz import climate_map, timeseries, legend, get_slice  
# Data
data = netCDF4.Dataset('data/Land_and_Ocean_LatLong1.nc')
t = data.variables['temperature']
# Output option
output_server("climate")
# Plots
climate_map = climate_map()
timeseries = timeseries()
legend = legend()
# Create layout
map_legend = hplot(climate_map, legend)
layout = vplot(map_legend, timeseries)
# Show
show(layout)
# Select data source for climate_map
renderer = climate_map.select(dict(name="image"))
ds = renderer[0].data_source
# Create a loop that goes through month and year and updates the image data
import time

for year_index in np.arange(2000, 2015, 1):
    for month_index in np.arange(1, 13, 1):
        image = get_slice(t, year_index, month_index)
        ds.data["image"] = [image]
        cursession().store_objects(ds)
        time.sleep(0.2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09781790820165538, 'fraction_numerical': 0.01580135440180587, 'mean_word_length': 5.214953271028038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '453373', 'license': 'MIT', 'n_tokens_mistral': 446, 'n_tokens_neox': 428, 'n_words': 137, 'path': '1.7 Animate (solution).ipynb', 'repo_name': 'adarsh0806/scipy2015-blaze-bokeh', 'size': '1329'}