This repository turns a 4f microscope lab into a reproducible Python analysis project. Starting from raw CSV measurements, it reproduces the report numbers, propagates uncertainties analytically, exports machine-readable results, and generates figures that GitHub can render directly.
This project is a compact example of reproducible model comparison. It evaluates three measurement routes, carries uncertainty through each chain, exports structured outputs, and makes the figures inspectable without opening the report.
- Data workflow: raw measurement tables are converted into processed CSV/JSON outputs, figures, and a report-facing notebook.
- Methods signal: constrained regression, method comparison, analytic uncertainty propagation, and systematic-vs-random error discussion.
- Reproducibility signal: the analysis can be rerun from a single script or Makefile target and produces GitHub-renderable artifacts.
The project keeps alternative measurement definitions visible rather than collapsing everything into one final reported value. Beyond the optics result, it is structured as a compact empirical replication package: raw measurements, uncertainty assumptions, intermediate outputs, figures, and final reported numbers are linked through rerunnable code.
The most important methodological result is that the slit-cutoff route has the smallest reported random uncertainty but is dominated by systematic uncertainty. In this dataset, the camera-calibration route is the most defensible estimate once that distinction is made explicit.
- Data analysis in
numpy,pandas, andmatplotlib - Constrained regression for the screen-angle method
- Analytic uncertainty propagation across multiple measurement chains
- Comparison of independent experimental methods, not just a single final number
- Reproducible outputs in notebook, CSV, JSON, and PDF form
How consistent are three independent estimates of the grating period in a Fourier optics lab, and which method is most defensible once random and systematic uncertainty are separated?
| Measurement route | Result for grating period d (um) | Main idea | Interpretation |
|---|---|---|---|
| Screen-angle geometry | 9.87 +/- 0.26 | Through-origin regression of diffraction spacing vs screen distance | Good consistency, but largest random uncertainty |
| Camera calibration | 9.92 +/- 0.11 | Calibrated object-plane pixel scale and period counting | Best overall method in this dataset |
| Fourier-plane slit cutoff | 10.83 +/- 0.05 | Spatial-frequency cutoff inferred from slit width | Reported sigma is random-only; systematics dominate |
Additional quantitative result:
- Abbe-limit estimate:
dx_min ~= 3.96 um, consistent with resolving the6 umfeature more clearly than the4 umfeature.
Screen-angle regression
Method comparison with propagated uncertainties
The Python workflow does more than fit a line. It carries uncertainty through each calculation chain.
For the screen-angle method:
y = mL
theta = arctan(m)
d = lambda / sin(theta)
sigma_theta = sigma_m / (1 + m^2)
sigma_d = |dd/dtheta| sigma_theta
For the camera method, the script propagates uncertainty from calibration pixels to object-plane scale and then into the final period estimate. For the slit-cutoff method, it reports the random component directly and also computes a simple systematic cross-check against the camera-based estimate.
python -m venv .venv
pip install -r analysis/requirements.txt
python analysis/analyze.pyIf make is available, the same analysis can be regenerated with:
make allSmoke test:
python -m unittest discover -s testsMain outputs:
analysis/FourierOptics_Analysis.ipynb: executed notebook rendered by GitHubdata/processed/results.json: structured summary for all experimentsdata/processed/grating_results.csv: compact comparison tableanalysis/output/*.png: regression, residual, and uncertainty figuresreport/main.pdf: polished lab report with derivations and discussion
analysis/ Python scripts, notebook, and generated figures
data/raw/ Raw measurements with assigned uncertainties
data/processed/ Machine-readable outputs generated by the analysis
report/ LaTeX source and compiled PDF report
docs/ Supporting notes
Report author: Hongyu Wang, with Maya Kang-Chou and Sidharth Kannan.
Code and reproducible analysis pipeline maintained by Hongyu Wang.

