(app:e)=
# Guide to the Example Computational Code
Each chapter has a corresponding Python file at `code/chapter_XX.py`. These scripts generate the PDF figures used in the text and provide starting points for reproducing the relevant orders of magnitude. Formula definitions follow their first appearance in the main text; the code turns those formulas into inspectable curves, scalings, simulated data, and error budgets.

(appsec:e-run)=
## Directory Layout and Run Order
1.  Read `code/README.md` first to check the Python version, dependencies, and output directories.

2.  Inspect `code/plot_style.py` and `code/plot_recipes.py` for the shared font, color, line-width, and save-function conventions.

3.  Run a single-chapter script, for example `python code/chapter_20.py`. A chapter script should generate only the figures for that chapter.

4.  Check that the PDF files are written to `figures/generated/chapter_XX/`.

5.  Compile `main_en.tex` and confirm that figure numbers, captions, text references, and PDF layout agree.

(appsec:e-map)=
## Mapping Between Scripts and Text
| Chapters | Typical figures or calculations | Checks |
|:-------------|:---------------------|:-----------------------------|
| 1--2 | Event tables, Poisson counts, ordinary light curves, and information loss | Event-table fields in the figure match the symbols in the text. |
| 3--4 | Optical states, occupation number, $g^{(1)}$, $g^{(2)}$, and multimode dilution | Ideal single-mode results are not drawn as if they were real instrumental observables. |
| 5 | Visibility, uniform disks, binaries, SII signal-to-noise ratio, and phase loss | Axes carry units; baselines use $B_\perp$, not the physical array distance. |
| 6 | Detector response, jitter, dead time, background dilution, and data rate | Response kernels are normalized; time units are explicit. |
| 7 | Pair counts, time-shift backgrounds, covariance, and Fisher scaling | Accidental coincidences and physical correlations are plotted separately. |
| 8 | Rayleigh curse, SPADE mode probabilities, QFI, and SII Fisher information | Log axes are not used to create a false improvement in the small-separation limit. |
| 9--13 | Radiation mechanisms, stars, compact objects, black holes, and transient toy models | Typical parameters come from the text; figures are not arbitrary normalized curves only. |
| 14--17 | Propagation, polarization, new physics, CMB, and quantum-network resources | Ordinary astrophysical terms and new-physics terms are separated in the figure. |
| 18--22 | Error budgets, science cases, teaching experiments, pitfalls, and roadmap | Captions state the feasibility, failure mode, or decision boundary. |

(appsec:e-figure-requirements)=
## Minimum Requirements for Each Figure
| Check | Requirement |
|:-----------------|:----------------------------------------------|
| Physical quantity | Axes state the quantity name and unit; dimensionless quantities should be marked as dimensionless or have no unit. |
| Scale | At least one curve, point, or annotation should correspond to a real scale used in the main text. If a signal is magnified for teaching, the caption must say so. |
| Symbols | Figure symbols should match the text, for example $B_\perp$, $\lambda$, $\theta$, $R_\gamma$, $\Delta t$, and $\tau_c$. |
| Output | All figures used in the main text should be PDF, not screenshots or low-resolution bitmap files. |
| Style | Use the shared style; avoid dense grids, too many colors, and decoration without physical meaning. |
| Reproducibility | The script header or function comment should state input parameters, defaults, and output files. |

(appsec:e-debug)=
## Debugging Checklist
If a figure appears inconsistent with the text, check these issues first.

(appsec:e-project-package)=
## Minimum Package for a Course Project
A course project based on Chapter {ref}`chap:20` should include at least five objects: an event-table description, a Python script, the generated PDF figures, a short report, and null-test output. Each figure in the report should state input parameters, units, physical meaning, and failure mode. A figure by itself is not enough.
