# Code and data: control-patch dependence of the gorget red shift in *Heliodoxa* thin-film models

Reproduction archive for the manuscript "Whether the gorget-specific red shift of thin-film models in *Heliodoxa* hummingbirds survives common corrections depends on the choice of control patch".

Environment used: Python 3.13.5, NumPy 2.2.6 (Pillow is needed only because one module reads the published Fig. 4 image at import; matplotlib only for the figures). No GPU. Code comments and printed labels are in Japanese; this file explains what to run and what to expect.

## Inputs (in `src/`)
- `dryad/SI_color_dataset.csv`, `dryad/SI_morphological_dataset.csv`: from Eliason et al. 2023, Dryad doi:10.5061/dryad.pk0p2ngs7 (CC0), downloaded 2026-11-24. SHA-256 3766e1e4b4f54843feeb6580aab9c5a9bc40442c421e337d9b6cf046861c80de and 602d82470b1e01153dd0890bd652a4eae8971b98aeab5e621684150ce8cafc52.
- `rsos221603f04.jpg`: Fig. 4 of Eliason et al. 2023, R. Soc. Open Sci. 10: 221603 (CC BY 4.0, © the authors). Used only by the earlier digitised inputs; the current results do not depend on it, but `unify_window.py` imports the digitising module.
- Dimensions: Table 2 means are written, rounded to whole nanometres and whole layers, as `T2` in `code/table2_model.py`.

## Selected individuals
FMNH 67693 (*H. branickii*), FMNH 511084 (hybrid), FMNH 286879 (*H. gularis*): individuals with spectra of all five patches. Column names in the CSV are `FMNH_<number>_<patch>_<taxon>`; patches used are gorget, crown, tail.

## Commands (run inside `code/`, e.g. `uv run --no-project --with numpy --with pillow python ...`)
| result | command | expected |
|---|---|---|
| §3.2–3.3 uncorrected and minimum ratios | `EMP_SOURCE=dryad_ref TAIL_EDGE=skip python baseline_skip.py` (and `EMP_SOURCE=dryad_mean`) | crown–tail 1.099 / 0.866 (hybrid / gularis), crown only 1.051 / 0.961 / 0.820 |
| Table 1, one row | `EMP_SOURCE=dryad_ref METRIC=geo_strict python unify_joint.py 100 0 0.05` | last line "2羽以上 11件" (11 of 100 draws) |
| Table 1, all rows | `bash run_tables.sh` | 18 counts, written to `../out_<date>/`; about one hour |
| §3.4 two-taxon comparison | `EMP_SOURCE=dryad_ref python control_only_pair.py 100 0.05` | both taxa ≤ 1.024 in 10 (crown–tail), 71 (crown only) and 71 (crown only on the crown–tail admissible set) of 100 draws; all nine runs in `outputs/control_only_pair_20261130.txt` |
| §3.4 threshold curve | `EMP_SOURCE=dryad_ref python threshold_curve.py 100 0.05` | at 1.024 the same 10 / 71 as above; table in `outputs/threshold_curve_20261130.txt` |
| §5 window and second maxima | `EMP_SOURCE=dryad_ref python window_check.py` | as in `outputs/window_check_20261130.txt` |
| §5 peak correspondence | `EMP_SOURCE=dryad_ref python peak_match.py 0.8` (and `0.5`, and `EMP_SOURCE=dryad_mean`) | as in `outputs/peak_match_{ref,mean}_20261130.txt` |
| §3.5 oblique sectioning | `python oblique_dryad.py` | as in `outputs/oblique_dryad_20261130.txt` |
| Figures | `python fig_spectra.py`, `python fig_fractions.py` | `../figs/fig1_spectra.svg`, `fig2_fractions.svg` |

Environment variables: `EMP_SOURCE` = `dryad_ref` (selected individuals), `dryad_mean` (species mean with standard-error noise), `dryad_boot` (resampling individuals); `METRIC` = `geo_strict` (crown–tail control, edge-limited tails undecided) or `crown` (crown only). In the printed lines, "線以下の羽数 0/1/2/3" is the distribution of the number of taxa at or below 1.024 and "2羽以上 N件" is the count used in Table 1.

## Stored outputs
`unify_joint_dryad_{ref,mean,boot}_{strict,crown}_sd{0.02,0.05,0.07}_20261124.txt` are the runs behind Table 1. Random seed 23 is fixed inside `unify_joint.py` (29 in `control_only_pair.py`).

## Other files
`code/` also contains the exploratory scripts of the project (earlier digitised inputs, RCWA, TEM measurements). They are not needed for the results above, and some of them need files that are not included.
