This is the tutorial and example workspace for PyAutoCTI, a Python library for calibrating and modelling Charge Transfer Inefficiency (CTI) in CCD imaging. These are the canonical, agent-agnostic instructions for this repo.
scripts/— Runnable Python scripts, organised by topic:overview/— the six-part introduction to CTI and CTI calibrationdataset_1d/— 1D CTI calibration datasets: simulators, modeling, correction, results, advanced (database, temporal)imaging_ci/— 2D charge injection imaging: simulators, modeling, correction, data_preparation, results, advanced (chaining pipelines)plot/— the plotting API guides (function-basedautocti.plotAPI)
notebooks/— Jupyter notebook versions, generated fromscripts/(do not edit directly)config/— PyAutoCTI configuration YAML filesdataset/— Example 1D and charge injection datasets (simulators regenerate them)output/— Model-fit results (generated at runtime, not committed)
Scripts are run from the repository root so relative paths to dataset/ and output/
resolve correctly:
python scripts/dataset_1d/modeling/start_here.pyEach topic folder has a start_here.py that is the canonical, always-current reference for that
topic. Results/database examples depend on outputs produced by their section's modeling scripts.
import autofit as af
import autocti as ac
import autocti.plot as apltimport autocti requires arcticpy (the C++ arctic clocking code). It is not a pip
dependency of autocti — install it after numpy with:
pip install arcticpy==2.6 --no-build-isolation --no-deps(It needs libgsl-dev and a C++ toolchain to build; see PyAutoCTI/AGENTS.md for the no-root
header workaround, and note a naive pip install arcticpy downgrades numpy below 2.0.)
Fast structural validation of scripts that run a non-linear search uses the test-mode knob:
PYAUTO_TEST_MODE=2 python scripts/dataset_1d/modeling/start_here.py(2 bypasses sampling entirely; 1 runs a reduced-iteration search; the variable is
PYAUTO_TEST_MODE, not PYAUTOFIT_TEST_MODE.)
Known test-mode artifact: bypass levels (2/3) evaluate the model at prior medians, so scripts
whose models assert an ordering between identically-prior'd parameters (e.g.
trap_0.release_timescale < trap_1.release_timescale) raise a FitException at the tied
medians. Real (non-bypass) runs resample such points gracefully — this is not a script bug.
In a sandboxed / restricted environment, point caches at writable directories:
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python scripts/...Notebooks in notebooks/ are generated from the .py files in scripts/. Always edit the
.py scripts, never the .ipynb notebooks directly. Notebook regeneration runs through the
PyAutoHands pipeline at release time.
CTI calibration fits many datasets (e.g. injection normalizations) simultaneously. Analysis
summing (analysis_1 + analysis_2) was removed from PyAutoFit — multi-dataset fits wrap each
analysis in an af.AnalysisFactor sharing the model and combine them in an
af.FactorGraphModel:
analysis_factor_list = [
af.AnalysisFactor(prior_model=model, analysis=analysis) for analysis in analysis_list
]
factor_graph = af.FactorGraphModel(*analysis_factor_list)
result_list = search.fit(model=factor_graph.global_prior_model, analysis=factor_graph)The PyAutoCTI stack (all on the PyAutoLabs GitHub org):
- https://github.com/PyAutoLabs/PyAutoNerves — configuration handling
- https://github.com/PyAutoLabs/PyAutoArray — arrays, layouts, regions, masks
- https://github.com/PyAutoLabs/PyAutoFit — model composition + non-linear search
- https://github.com/PyAutoLabs/PyAutoCTI — CTI clocking (arctic), datasets, fits, analyses
- https://github.com/PyAutoLabs/autocti_workspace_test — regression scripts + Euclid heritage
- https://github.com/PyAutoLabs/PyAutoHands — notebook generation + CI
For local development these are typically cloned as siblings of this repo (../PyAutoCTI, etc.).
Never rewrite pushed history on any repo with a remote — no git init over a
tracked repo, no force-push to main, no fresh-start "Initial commit", no
filter-repo / filter-branch / rebase -i on pushed branches. To get a
clean tree: git fetch origin && git reset --hard origin/main && git clean -fd.