Download this notebook

Step 7: Prepare and Launch Dashboards

This notebook prepares the files used by the interactive Spatial-VTK dashboards. You will export dashboard-ready Parquet data, create summary tables, and build portable commands for the metrics and QC dashboards.

Imports

These helpers write dashboard datasets and make readable dashboard table previews.

[1]:
from spatial_vtk.config.notebook import notebook_timer, register_svtk_cell_timer

with notebook_timer():
    import pandas as pd

    from spatial_vtk.config import SpatialVTKConfig
    from spatial_vtk.io import load_output_table, write_output_table
    from spatial_vtk.visualize.dashboard import (
        display_table,
        write_dashboard_metric_dataset,
        write_dashboard_summary_dataset,
    )
    register_svtk_cell_timer()
Run time: 320.1 ms

Configuration

Load the config and choose dashboard output folders and ports.

[2]:
from pathlib import Path

# Use the repository root so paths match the public source checkout.
from spatial_vtk.tutorials import tutorial_root
repo_root = tutorial_root()
# Metadata table paths are project-relative.
import os
os.chdir(repo_root)
config_path = repo_root / "data/examples/configuration/example_spatial_vtk_config.yaml"

# Load the tutorial run scenario and make it the active config for later package calls.
cfg = SpatialVTKConfig.from_file(config_path, run_scenario="tutorial").activate()

notebook_overrides = {"metrics_port": 8501, "qc_port": 8502}
Run time: 13.0 ms

Write Dashboard Datasets

The metrics dashboard reads Parquet files. Summary tables keep common filters and views fast.

[3]:
# Read the enriched metrics table for the metrics dashboard.
metrics = load_output_table("metrics_enriched")

# Read the QC inventory for the QC dashboard.
qc_summary = load_output_table("qc_inventory")

# Write the dashboard-ready metrics dataset.
write_dashboard_metric_dataset(metrics, partitioned=False)

# Write dashboard summary tables used by the Streamlit app.
write_dashboard_summary_dataset(format="parquet")

# Save the QC trace summary for the QC dashboard.
# Preserve the trace-level summary written by Step 2.

metrics.head()
[3]:
event_id station component model passband metric_group metric period_s value_obs value_syn ... dip rake usgs_url observed_pickle event_json synthetic_mseed selected_station_count overlapping_broadband_station_count network event_count
0 ci38038071 BFS R cvmsi_20260506_material_0p6x1p2_asdf 1-2 sec amplitude PGA NaN 0.384463 NaN ... 79.0 178.0 https://earthquake.usgs.gov/earthquakes/eventp... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/synthe... 30 52 CI 4
1 ci38038071 BFS R cvmsi_20260506_material_0p6x1p2_asdf 1-2 sec amplitude PGV NaN 0.005630 NaN ... 79.0 178.0 https://earthquake.usgs.gov/earthquakes/eventp... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/synthe... 30 52 CI 4
2 ci38038071 BFS R cvmsi_20260506_material_0p6x1p2_asdf 1-2 sec amplitude PGD NaN 0.000863 NaN ... 79.0 178.0 https://earthquake.usgs.gov/earthquakes/eventp... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/synthe... 30 52 CI 4
3 ci38038071 BFS R cvmsi_20260506_material_0p6x1p2_asdf 2-3 sec amplitude PGA NaN 0.019404 NaN ... 79.0 178.0 https://earthquake.usgs.gov/earthquakes/eventp... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/synthe... 30 52 CI 4
4 ci38038071 BFS R cvmsi_20260506_material_0p6x1p2_asdf 2-3 sec amplitude PGV NaN 0.000859 NaN ... 79.0 178.0 https://earthquake.usgs.gov/earthquakes/eventp... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/observ... data/examples/example_five_event_subset/synthe... 30 52 CI 4

5 rows × 66 columns

Run time: 1.29 s

Preview the Metrics Table

The same label lookup used by the dashboards can also make notebook previews easier to read.

[4]:
# Show a dashboard-style preview with readable metric names, period bands, and column headers.
display_table(
    metrics,
    columns=[
        "event_id",
        "station",
        "component",
        "band",
        "metric",
        "value_obs",
        "value_syn",
        "ln_residual",
        "anderson_2004_gof",
    ],
    max_rows=5,
)
[4]:
Event ID Station Component Period Band Metric Observed Value Synthetic Value Ln Residual Anderson 2004 GOF
0 ci38038071 BFS R 1-2 sec Peak acceleration (PGA) 0.384463 NaN NaN NaN
1 ci38038071 BFS R 1-2 sec Peak velocity (PGV) 0.005630 NaN NaN NaN
2 ci38038071 BFS R 1-2 sec Peak displacement (PGD) 0.000863 NaN NaN NaN
3 ci38038071 BFS R 2-3 sec Peak acceleration (PGA) 0.019404 NaN NaN NaN
4 ci38038071 BFS R 2-3 sec Peak velocity (PGV) 0.000859 NaN NaN NaN
Run time: 7.8 ms

Build Launch Commands

Run these commands in a terminal when you want to open the interactive dashboards.

[5]:
# Build explicit commands; a terminal does not share the notebook's active config.
from spatial_vtk.config import resolve_output_path
import shlex
metrics_root = resolve_output_path("metrics_dashboard", kind="dashboard")
summary_root = resolve_output_path("dashboard_summaries", kind="dashboard")
trace_path = resolve_output_path("qc_trace_summary", kind="table")
metrics_command = f"svtk dashboard metrics --metrics-root {shlex.quote(str(metrics_root))} --summary-root {shlex.quote(str(summary_root))} --port {notebook_overrides['metrics_port']}"
qc_command = f"svtk dashboard qc --trace-summary {shlex.quote(str(trace_path))} --port {notebook_overrides['qc_port']}"
print(metrics_command)
print(qc_command)

svtk dashboard metrics --metrics-root /home/runner/work/spatial-vtk/spatial-vtk/outputs/tutorials/dashboards/metrics_dashboard --summary-root /home/runner/work/spatial-vtk/spatial-vtk/outputs/tutorials/dashboards/dashboard_summaries --port 8501
svtk dashboard qc --trace-summary /home/runner/work/spatial-vtk/spatial-vtk/outputs/tutorials/tables/qc_trace_summary.csv --port 8502
Run time: 36.3 ms