import numpy as np import panel as pn import holoviews as hv from holoviews import opts # noqa pn.extension('katex') hv.extension('bokeh') import dask.dataframe as dd df = dd.read_parquet('../../data/earthquakes.parq') df = df[~df.mag.isna()].persist() logo_url = '../../assets/usgs_logo.png' ## Define a panel component containing the logo logo = ... ## Display it equation_string = '$M_L = log_{10}A - log_{10} A_0(\delta)$' ## Define a panel component containing the equation (Hint: Use the LaTeX pane) equation = ... ## Display it year = 2000 def strongest_earthquakes_fn(year): year_df = df[(df.time.dt.year == year) & (df.mag > 7)].compute() return year_df.sort_values('mag', ascending=False).iloc[:5][['time', 'place', 'mag']].reset_index(drop=True) ## Create a panel component by calling the function with a particular year strongest_earthquakes = ... ## Display it def gmap_fn(year): yearly_df = df[(df.time.dt.year == year)].compute() index = np.argmax(yearly_df.mag.values) strongest = yearly_df.iloc[index] lon, lat = strongest.longitude, strongest.latitude return """ """.format(lat=lat, lon=lon) ## Create a panel component by calling the function with a particular year and wrapping it in the appropriate pane gmap = ... ## Display it year_df = df[df.time.dt.year == year].compute() ## Create a plot and assign it to the plot variable plot = ... ## Display it def strongest_earthquakes_fn(year): # noqa: redefined on purpose year_df = df[df.time.dt.year == year].compute() return year_df.sort_values('mag', ascending=False).iloc[:5][['time', 'place', 'mag']].reset_index(drop=True) def gmap_fn(year): # noqa: redefined on purpose yearly_df = df[(df.time.dt.year == year)].compute() index = np.argmax(yearly_df.mag.values) strongest = yearly_df.iloc[index] lon, lat = strongest.longitude, strongest.latitude return pn.pane.HTML(""" """.format(lat=lat, lon=lon), height=300, width=300)