Skip to content
A

Live: CPTViewer

Loading the Python runtime…

This page runs Python in your browser through marimo WebAssembly islands. The cells below form one reactive notebook: the code is editable, and a change reruns the dependent cells. The first run downloads the Python runtime and the packages, which can take a minute.

brodata fetches a sounding from the public BRO API and parses the XML.

Edit the id above to fetch another public CPT: every cell that reads cpt reruns with the new sounding.

The parsed BRO/XML keeps every value as a string, we need to convert certain columns to floats. Next we pick the channels to plot, and compute the elevation in NAP.

The DataFrame follows the data contract: tidy columns of equal length, one row per depth sample. The constructor does the rest: NaN becomes None, and the rows sort so the shallowest sample renders first.

The multiselect is a marimo UI element. This page is a reactive notebook, so because the viewer cell reads its value, changing the selection automatically redraws the chart.

The viewer takes the tidy data, the selected channels, and one annotation: the groundwater level recorded in this CPT’s file (groundwaterLevel, in m below the surface), converted to NAP through the offset.

groundwaterLevel is optional in a BRO/XML, so some CPTs lack it.

Try the interactions from getting started: hold Ctrl (Cmd on macOS) and turn the mouse wheel to zoom, drag to pan, Shift-drag along the axis to zoom to a range, double-click to reset, and hover to read values.

The BRO column names carry built-in display defaults, which is why the viewer needed no channel bindings here. The CPTViewer reference covers bindings for other names, axis limits, overlays, and the editable layer column.