dispcraft
Physics-first, then hybrid physics+ML modeling of the Euclid/NISP grism spectral dispersion — from a geometrical-optics instrument model, through per-dataset and joint multi-dataset calibration against ground-test data, to an ML residual corrector and a field-dependent extension, benchmarked against a published reference result (arXiv:2506.08378).
Project status: exploratory research prototype, ongoing — not production-ready. This is a proof-of-concept pipeline, not a finished deliverable. The best model produced so far (hybrid physical + ML residual) is 1.7x worse on
yand 8.4x worse onzthan the reference paper's own held-out accuracy (see Results below anddocs/Status_Report.md§1) — it does not currently reach the accuracy this instrument needs. Development is ongoing; open gaps and next steps are tracked indocs/Status_Report.md§9-10.
If you just want to use the calibrated models (predict where a spectrum lands, given field position and wavelength), see the User Guide — but read the status note above first: these are the best models this exploratory project has produced to date, not models validated as meeting an accuracy requirement. This README covers the project itself.
What's here
dispcraft/— the library: instrument optics (optics/), the ground-test forward model and joint-fit machinery (calibration.py), the field-dependent correction tier (field_calibration.py), the 0th-order dispersion model (zeroth_dispersion.py), the Chebyshev polynomial residual alternative (chebyshev_residual.py), data loading (measurement.py), the residual-MLP building block (ml.py), GitLab model-registry helpers (model_registry.py), and the unified 1st-/0th-order prediction entry point (prediction.py).scripts/—register_models.pytrains and publishes the recommended residual/NN models to GitLab's model registry (see the User Guide);freeze_stage5_fits.py,freeze_chebyshev_fits.py, andfreeze_best_models.pyreplay already-validated fits to produce the correspondingmodels/*.tomlfiles.models/*.toml— frozen, versioned calibration results (one file per fit). Every tunable physical parameter used in a real result is recorded here, not hardcoded in code or notebooks.notebooks/— one notebook per project stage/phase, prototyping and producing every result before (validated bits) get promoted todispcraft/.data/— ground-test PSF datasets (docs/internship/2-Intro_data/index.htmlis the authoritative description of what's in here and how it was built; see alsodata/README.md).docs/—User_Guide.md(how to use the calibrated models),Status_Report.md(full write-up of methodology and results), reference material (Euclid-NISP-Specs.md, the benchmark paper summary),internship/(the slide decks, see below), and the source for the published documentation site (mkdocs.ymlat the repo root).docs/internship/0-Intro_generale/…4-Projet/— the slide decks that define this project's scope and order (see Roadmap below).webapp/— a self-contained, static JS visualization of the physical grism model (no build step, no data dependency) — an interactive, outreach-friendly complement to the notebooks.tests/— one test module perdispcraft/module.
Roadmap
This project follows a fixed sequence of stages, each driven by a slide
deck, plus three further stages added by explicit request once the deck's
own scope closed. Status and detailed findings for every stage are tracked
in CLAUDE.md; the short version:
| Stage | Topic | Status |
|---|---|---|
| 0 | General introduction | done |
| 1 | Subject/problem, instrument model | done |
| 2 | Data introduction | done |
| 3 | ML introduction, per-dataset physical calibration | done |
| 4 | Project integration: ML residual, joint fitting, literature comparison | done (deck's own scope, one phase skipped by decision) |
| 5 | Extension: field-dependent parameters, 0th-order dispersion, BGS model | done |
| 6 | Status report | done — see docs/Status_Report.md |
| 7 | Model distribution: GitLab model registry, unified prediction entry point | done |
| 8 | Chebyshev polynomial residual model (interpretable alternative to the MLP) | done |
Getting started
This project uses pixi for environment management —
don't use a bare venv/pip install.
pixi install # create/sync the environment from pixi.toml/pixi.lock
pixi run test # run the test suite (pytest tests)
pixi run mlflow-ui # browse logged experiment runs (sqlite:///mlflow.db)
To work in a notebook or script interactively:
pixi shell
jupyter lab notebooks/
Data files (data/*.csv) are already provided; data/README.md documents
how they were extracted from the ground-test database, if you need to
regenerate them.
Results at a glance
Final held-out accuracy (mean over the 6 RGS ground-test configs), compared
to the reference paper's own held-out (Argon) figure — full detail in
docs/Status_Report.md:
| Model | RMSE y (mm) | RMSE z (mm) |
|---|---|---|
| Physical model only (joint 3-tier fit) | 0.194 | 0.300 |
| Hybrid: physical + ML residual (recommended default) | 0.019 | 0.075 |
| Reference paper, held-out | 0.009 | 0.009 |
This does not yet reach the reference's accuracy (1.7x worse on y,
8.4x worse on z) — closing that gap is ongoing work, not a solved
problem. See docs/Status_Report.md §9-10 for the open items.
See the User Guide for how to reproduce and use this (and the BGS / 0th-order counterparts) yourself — as a snapshot of current, unfinished work, not a validated production model.
License
GNU General Public License v3.0 — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dispcraft-0.1.0.tar.gz.
File metadata
- Download URL: dispcraft-0.1.0.tar.gz
- Upload date:
- Size: 41.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
213189aa4a3455d803d9be92eaab940f70c609d761f6c8a0b8d65ed2f7b9f3d8
|
|
| MD5 |
d1a158d52ece89ed8645c578a56eb9bb
|
|
| BLAKE2b-256 |
212b77054161c0c569e737816e3723b76a5179d7060385772c42fbb430c2ede0
|
File details
Details for the file dispcraft-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dispcraft-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5621d792e19456508a9b36baf2650123d8e2e04ddfa144c04ea4e2a6a0f2ce52
|
|
| MD5 |
27d743dfc1000e158daffd64a7c5e1f7
|
|
| BLAKE2b-256 |
17c63fb92ea102ab57f6a2d5f3e9185bb30f20816bfb2c3a7341fb498c9280f9
|