# Notebooks

> Jupyter notebooks that each answer one question about Asense data, from reading a Parquet export to running a foundation model.

> **Coming soon:** The notebooks' repositories are not public yet, and they run on your own machine for now. Running them in the browser from this page is planned but not tested.

## How they are written

Each notebook asks one question, and the question is its title, such as "Is this sensor still tilting?". It reads the [public dataset](https://asense.semitronica.pt/docs/dataset/) of ASENSE00000005 with DuckDB, answers the question in a few cells, and says plainly what this data can and cannot show. ASENSE00000005 is a reference unit on a bench, so its vibration is mostly the sensor's own noise, while its tilt and temperature are real.

The notebooks are generated from short Python scripts. Each script is the master copy, so a notebook and its script always agree.

## The notebooks

### Reading and analysing the data

From `asense-duckdb-examples`, using DuckDB and Polars (see [Parquet and DuckDB](https://asense.semitronica.pt/docs/parquet-duckdb/)):

| Notebook | Question |
|---|---|
| 01 | What does this device's export hold, and over which dates? |
| 02 | How does raw vibration look hour by hour, and tilt day by day? |
| 03 | At which frequencies does the device vibrate most, hour by hour? |
| 04 | Is this sensor still tilting? |
| 05 | What does the vibration spectrum look like? |
| 06 | How loud is it by day, evening and night? This one needs an Environmental Sensor's records |

All six are run on the export each time they change.

### Foundation models

From `asense-tsfm` (see [Foundation models on Asense data](https://asense.semitronica.pt/docs/foundation-models/)):

| Notebook | Question |
|---|---|
| 01 | Can a foundation model forecast a sensor's tilt from temperature? |
| 02 | Which days in a tilt record look unusual? |
| 03 | Does fine-tuning Chronos-2 on your own sensor make its forecasts better? |
| 04 | Which vibration records look odd? |

These load models of a few hundred megabytes and take from under a minute to several minutes, so they are not re-run on every change. The results they print are recorded in each guide.

### Planned

A notebook running [operational modal analysis](https://asense.semitronica.pt/docs/oma/) on one 10-minute record is planned.

## Running them

Get the dataset, point `ASENSE_DATA` at its `data` folder, and open a notebook in Jupyter:

```sh
export ASENSE_DATA=/path/to/asense-dataset/data
uv run --with jupyterlab --with duckdb --with polars --with pyarrow jupyter lab notebooks/
```

The foundation-model notebooks need their repository's `requirements.txt` as well.

Source page: https://asense.semitronica.pt/docs/notebooks/
