This repository contains materials for comparing beam emittance calculations between MATLAB and pyemittance at SLAC's LCLS injector (OTR screen OTRS:IN20:571).
emittance_matlab_pyemittance_matv7_3.ipynb— Jupyter notebook that loads MATLAB emittance scan files, re-runs the analysis with pyemittance, and compares results (emittance, Twiss parameters, Bmag).matlab_scans/— MATLAB.matfiles from emittance scans taken in 2020–2021.LCLS_OTR2/— Beamline optics/configuration for the OTR2 screen.pv_data.json— Machine PV snapshot data associated with individual scans. This is only needed for the optional exercise involving the LCLS injector surrogate model.requirements.txt— Python dependencies.
Create and activate an isolated environment, then install dependencies.
Using venv:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtUsing conda:
conda create -n emittance python=3.11
conda activate emittance
pip install -r requirements.txtOpen emittance_matlab_pyemittance_matv7_3.ipynb in an IDE such as VS Code or PyCharm and select the environment created above as the kernel. Running the notebook inside an IDE is required for AI coding agents (e.g. GitHub Copilot) to be able to read cell outputs and assist with the exercises.