# Posture of dragonflies around lights vs. a dorsal-light-response flight model — reproduction material

Code, results and reproduction notes for the paper in `paper.md`:
*A dorsal light response flight model matches the overall medians but does not reproduce, within distance and speed bins, the dragonfly postures that change with light condition: a test with the public motion capture of Fabian et al. (2024)*.

Version of the code: git commit `990ed8e9d34a1cad0bec32d902f9f97cd5830128` of https://github.com/tomo3141592653/self-driving-ai-prototype (the repository is private; the same files are published here, with SHA-256 per file in `manifest.json`).

## Contents

| Place | What |
|---|---|
| `paper.md` | the paper (English) |
| `code/*.py` | every script that makes a number or table of the paper, plus `fabian_io.py` (the only place that reads the data and fixes axes and units) and `fabian_model.py` (the flight model of Fabian et al. 2024 and the extended variants) |
| `data/*.json` | outputs of the scripts below (the `.md` files are the comparison tables printed by `compare_table.py`) |
| `manifest.json` | SHA-256 and size of every file |

## Data

Public data of Fabian et al. (2024): https://doi.org/10.6084/m9.figshare.24771978 (CC BY 4.0). `Supporting Data.zip` (250 MB; SHA-256 `cda635acc2dd6f56d1e56f7a174640d047d85d83deaf39a21680e092be23a088` for the copy retrieved on 2026-11-11). Unzip it and call the folder `Motion Capture Data` below `$D`.

```bash
D="/path/to/Motion Capture Data"
```

## Running

Python 3.12 or later with numpy, pandas and scipy. Run from `code/`. Scripts that print results write JSON to standard output or to the file named in the variable shown. At most two computations are run at the same time (set inside each script); random seeds are 1, 2, 3.

```bash
cd code
uv run --no-project --with numpy --with pandas --with scipy python test_axes.py "$D"   # checks the angle formulas and the axes and units of the data
```

Observation side (each prints a summary and writes the JSON of the same name next to the code):

```bash
for s in force_vs_back dlr_nose_sign force_by_speed rec_sequence white_up az_by_speed inv_by_speed inv_motion inv_force inv_onset thrust_tilt; do
  uv run --no-project --with numpy --with pandas --with scipy python $s.py "$D"
done
```

Model side:

```bash
TABLE_JSON=compare_table_20261111.json uv run --no-project --with numpy --with pandas --with scipy python compare_table.py "$D" > compare_table_20261111.md   # Table 2
DORS=17.3 TABLE_JSON=compare_table_dors173_20261112.json uv run --no-project --with numpy --with pandas --with scipy python compare_table.py "$D" > compare_table_dors173_20261112.md
uv run --no-project --with numpy python table3.py > table3_20261111.json                 # Table 3
uv run --no-project --with numpy --with pandas --with scipy python robust.py "$D" > robust_20261111.json
uv run --no-project --with numpy python dt_check.py > dt_check_20261111.json
uv run --no-project --with numpy python model_variants.py                                  # model_variants.json
VARS=B_fcapv  OUTJSON=model_variants_fcapv.json  uv run --no-project --with numpy python model_variants.py
VARS=B_fcapv2 OUTJSON=model_variants_fcapv2.json uv run --no-project --with numpy python model_variants.py
uv run --no-project --with numpy python az_model_by_speed.py
EXTRA=FCAP=30,FCAP_V0=1.0,FCAP_V1=1.8 OUTJSON=az_model_by_speed_fcapv.json uv run --no-project --with numpy python az_model_by_speed.py
uv run --no-project --with numpy python model_airforce.py
VARS=B_fcapv2 OUTJSON=model_airforce_fcapv2.json uv run --no-project --with numpy python model_airforce.py
uv run --no-project --with numpy python nose_acc_reversal.py
DETREND=1 uv run --no-project --with numpy python nose_acc_reversal.py                      # nose_acc_reversal_detrend.json
for s in fallgate wta alt k3; do uv run --no-project --with numpy python $s.py > ${s}_20261111.json; done   # exploratory variants discussed in Section 4
```

Scripts call each other and `fabian_io.py` by relative path, so keep them in one folder. The numbers in the paper were inserted from these JSON files by a script that depends on the Japanese draft and is not included; each number can be read from the JSON named in the script that produces it.

## What is not included

The Motion Capture Data itself (see Data), and the Japanese draft with its number-insertion script.
