import numpy as np # noqa import xarray as xr import dask.dataframe as dd import holoviews as hv from holoviews import streams # noqa import hvplot.dask # noqa import hvplot.pandas # noqa import hvplot.xarray # noqa: adds hvplot method to xarray objects df = dd.read_parquet('../../data/earthquakes.parq') df.time = df.time.astype('datetime64[ns]') cleaned_df = df.copy() cleaned_df['mag'] = df.mag.where(df.mag > 0) cleaned_reindexed_df = cleaned_df.set_index(cleaned_df.time) cleaned_reindexed_df = cleaned_reindexed_df.persist() most_severe = cleaned_reindexed_df[cleaned_reindexed_df.mag >= 7].compute() ds = xr.open_dataarray('../../data/gpw_v4_population_density_rev11_2010_2pt5_min.nc') cleaned_ds = ds.where(ds.values != ds.nodatavals).sel(band=1) cleaned_ds.name = 'population' pop_density = ... # Use hvplot here to visualize the data in cleaned_ds and customize it with .opts pop_density # Display it quake_points = ... # Use hvplot here to visualize the data in most_severe and customize it with .opts quake_points selection_stream = ... def circles_callback(index): circles = [] if len(index) == 0: return hv.Overlay([]) for i in index: row = most_severe.iloc[i] # noqa circle = ... # Define the appropriate Ellipse element here circles.append(circle) return hv.Overlay(circles) # Uncomment when the above function is complete # circle_marker = hv.DynamicMap(circles_callback, streams=[selection_stream])