RayCrafter 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {raycrafter-0.0.1 → raycrafter-0.0.2}/.github/workflows/test_and_deploy.yml +13 -1
- {raycrafter-0.0.1 → raycrafter-0.0.2}/CLAUDE.md +42 -10
- raycrafter-0.0.2/Changelog.md +19 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/PKG-INFO +14 -6
- raycrafter-0.0.2/README.md +41 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/PKG-INFO +14 -6
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/SOURCES.txt +11 -2
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/requires.txt +1 -1
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/scm_file_list.json +16 -2
- raycrafter-0.0.2/RayCrafter.egg-info/scm_version.json +8 -0
- raycrafter-0.0.2/log.md +203 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/pyproject.toml +7 -9
- raycrafter-0.0.2/raycrafter/core/analysis.py +589 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/core/model.py +213 -26
- raycrafter-0.0.2/raycrafter/core/optic_builder.py +188 -0
- raycrafter-0.0.2/raycrafter/core/plot_geometry.py +110 -0
- raycrafter-0.0.2/raycrafter/core/ray_launch.py +121 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/core/state.py +77 -14
- raycrafter-0.0.2/raycrafter/core/zmx_import.py +384 -0
- raycrafter-0.0.2/raycrafter/gui/about_dialog.py +47 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/gui/analysis_panels.py +71 -52
- raycrafter-0.0.2/raycrafter/gui/app.py +45 -0
- raycrafter-0.0.2/raycrafter/gui/compile_notice.py +38 -0
- raycrafter-0.0.2/raycrafter/gui/field_editor.py +337 -0
- raycrafter-0.0.2/raycrafter/gui/lens_picker.py +377 -0
- raycrafter-0.0.2/raycrafter/gui/main_window.py +663 -0
- raycrafter-0.0.2/raycrafter/gui/range_slider.py +130 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/gui/side_view.py +327 -43
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/gui/style.py +18 -0
- raycrafter-0.0.2/raycrafter/lenscatalog/catalog.py +94 -0
- raycrafter-0.0.2/raycrafter/lenscatalog/data/thorlabs.json.gz +0 -0
- raycrafter-0.0.2/raycrafter/lenscatalog/selection.py +132 -0
- raycrafter-0.0.2/raycrafter/lenscatalog/thorlabs.py +117 -0
- raycrafter-0.0.2/raycrafter/palette.py +66 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/explanations.py +3 -3
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/figures.py +50 -28
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/html_report.py +36 -19
- raycrafter-0.0.2/scripts/make_thorlabs_catalog.py +70 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/uv.lock +17 -450
- raycrafter-0.0.1/README.md +0 -32
- raycrafter-0.0.1/RayCrafter.egg-info/scm_version.json +0 -8
- raycrafter-0.0.1/log.md +0 -88
- raycrafter-0.0.1/raycrafter/core/analysis.py +0 -420
- raycrafter-0.0.1/raycrafter/core/optic_builder.py +0 -110
- raycrafter-0.0.1/raycrafter/core/plot_geometry.py +0 -93
- raycrafter-0.0.1/raycrafter/gui/app.py +0 -24
- raycrafter-0.0.1/raycrafter/gui/main_window.py +0 -483
- raycrafter-0.0.1/raycrafter/lenscatalog/catalog.py +0 -103
- raycrafter-0.0.1/raycrafter/lenscatalog/data/thorlabs_achromats.json +0 -544
- raycrafter-0.0.1/raycrafter/lenscatalog/thorlabs.py +0 -85
- raycrafter-0.0.1/raycrafter/palette.py +0 -22
- raycrafter-0.0.1/scripts/make_thorlabs_subset.py +0 -59
- {raycrafter-0.0.1 → raycrafter-0.0.2}/.gitignore +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/LICENSE +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/MANIFEST.in +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/dependency_links.txt +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/entry_points.txt +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/RayCrafter.egg-info/top_level.txt +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/__init__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/__main__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/core/__init__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/core/prescription.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/gui/__init__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/lenscatalog/__init__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/__init__.py +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/assets/report.css +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/raycrafter/report/assets/report.js +0 -0
- {raycrafter-0.0.1 → raycrafter-0.0.2}/setup.cfg +0 -0
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
name: tests
|
|
2
2
|
|
|
3
|
+
# Run on pushes to main (including merges into it), on every pull request (before it is
|
|
4
|
+
# merged), on tags (which also publish to PyPI), and by hand from the Actions tab. Pushes to
|
|
5
|
+
# other branches, such as dev, are not tested here; run the tests locally or open a PR.
|
|
3
6
|
on:
|
|
4
7
|
push:
|
|
5
8
|
branches:
|
|
6
|
-
-
|
|
9
|
+
- main
|
|
7
10
|
tags:
|
|
8
11
|
- '*'
|
|
9
12
|
pull_request:
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
# A newer push to the same branch or PR cancels the run still going for the older one.
|
|
16
|
+
# Release (tag) runs are never cancelled.
|
|
17
|
+
concurrency:
|
|
18
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: ${{ github.ref_type != 'tag' }}
|
|
10
20
|
|
|
11
21
|
jobs:
|
|
12
22
|
linting:
|
|
@@ -44,6 +54,8 @@ jobs:
|
|
|
44
54
|
- uses: neuroinformatics-unit/actions/test@v2
|
|
45
55
|
with:
|
|
46
56
|
python-version: ${{ matrix.python-version }}
|
|
57
|
+
# Needed to upload the coverage report to codecov.io (see the README badge).
|
|
58
|
+
secret-codecov-token: ${{ secrets.CODECOV_TOKEN }}
|
|
47
59
|
|
|
48
60
|
build_sdist_wheels:
|
|
49
61
|
name: Build source distribution
|
|
@@ -14,6 +14,12 @@ little or no AI. If something would confuse a careful human reader, it is wrong.
|
|
|
14
14
|
calls on it. It holds no optical state of its own beyond what it needs to draw.
|
|
15
15
|
- **Object-oriented, modular.** One clear responsibility per module. Subpackages must be usable
|
|
16
16
|
on their own, e.g. `from raycrafter.lenscatalog import thorlabs` must not pull in Qt or the GUI.
|
|
17
|
+
- **Responsiveness first.** The GUI must respond immediately, on slow machines too (Optiland
|
|
18
|
+
is noticeably slower on some). Be very careful about what is calculated on every change
|
|
19
|
+
(each drag event or slider tick): only what the user is watching while they drag. Anything
|
|
20
|
+
else goes on the slow path (after changes settle) or runs only once nothing is being
|
|
21
|
+
dragged, as the f-number does (`MainWindow.is_dragging`). Measure what you add to the fast
|
|
22
|
+
path; the side view shows the trace and draw times.
|
|
17
23
|
- **File size.** Aim for files under about 1000 lines. This is a soft limit: if a file has to be
|
|
18
24
|
bigger, say why in `log.md`.
|
|
19
25
|
- **Optiland.** It is pinned to a tested minor version in `pyproject.toml`. Any workaround for an
|
|
@@ -59,24 +65,50 @@ raycrafter/
|
|
|
59
65
|
|
|
60
66
|
# Workflow
|
|
61
67
|
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
- **Branches.** Small, self-contained changes go straight onto `main`. A longer job that
|
|
69
|
+
will take a series of commits is done on the long-lived `dev` branch; once it is complete
|
|
70
|
+
and the local tests pass, `dev` is merged into `main`. Before starting on `dev`, merge
|
|
71
|
+
`main` into it so it has any small fixes made there. A feature branch is used only for
|
|
72
|
+
risky or experimental work: it branches from `dev`, merges back into `dev`, and is then
|
|
73
|
+
deleted. Pull requests (from forks or feature branches) target `dev`, never `main`.
|
|
74
|
+
- **CI** runs on pushes to `main`, on every pull request, on tags, and by hand from the
|
|
75
|
+
Actions tab. Pushes to `dev` or feature branches are not tested by CI, so the local checks
|
|
76
|
+
below are what stand between them and `main`.
|
|
65
77
|
- Use GitHub issues for substantial bugs, features and design questions, so there is a public
|
|
66
78
|
record of what was done and why. Reference the issue in commits and PRs.
|
|
79
|
+
- **Known problems.** For now, while the project is young, a feature is done when it does
|
|
80
|
+
what its issue asks, even if not all of its ramifications are resolved. Each significant
|
|
81
|
+
ramification left unsolved (e.g. something a file format cannot store, or an analysis that
|
|
82
|
+
ignores a new setting) gets its own issue with the `known problem` label. The feature's
|
|
83
|
+
issue is then closed with a comment linking to those known problems. This lets us move
|
|
84
|
+
forward quickly. We will review this choice as the project develops: later we may be
|
|
85
|
+
stricter and keep a feature's issue open until all its ramifications are resolved.
|
|
67
86
|
- Before committing, run `uv run pre-commit run --all-files` and `uv run pytest`.
|
|
68
|
-
- Agents may create or comment on issues, and
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
approval from Rob.
|
|
73
|
-
- Versions come from git tags via setuptools-scm, using semantic versioning. Pushing a
|
|
74
|
-
`vX.Y.Z` tag publishes to PyPI.
|
|
87
|
+
- Agents may create or comment on issues, push `dev` and feature branches, and open pull
|
|
88
|
+
requests into `dev`.
|
|
89
|
+
- Small changes on `main` may be committed and pushed without asking. Merging `dev` into
|
|
90
|
+
`main`, tagging and releasing need explicit approval from Rob.
|
|
75
91
|
- Stop and ask at natural check-points rather than finishing large pieces of work in one go.
|
|
76
92
|
- Expect that people may have changed files you recently worked on or are working on now.
|
|
77
93
|
Re-read a file before modifying it; otherwise you risk reverting a human developer's saved
|
|
78
94
|
changes.
|
|
79
95
|
|
|
96
|
+
## Releases
|
|
97
|
+
|
|
98
|
+
- When it is time for a new release, you will first conduct an adversarial code review of
|
|
99
|
+
work down between now and the last release. The main task of the review will be to find
|
|
100
|
+
bugs that may have been introduced. However, you should also verify that the changes made
|
|
101
|
+
are in keeping with the design plan of the software. Once any fixes have been applied
|
|
102
|
+
after the review ends, it is OK to increment the version and deploy the new release.
|
|
103
|
+
- Versions come from git tags via setuptools-scm, using semantic versioning. Pushing a
|
|
104
|
+
`vX.Y.Z` tag publishes to PyPI. Always verify your proposed new version number with the
|
|
105
|
+
human managing the project.
|
|
106
|
+
- You will write a release message that succinctly summarises the changes in the release.
|
|
107
|
+
This will be placed in the release message on GitHub. You will also maintain a Changelog.md
|
|
108
|
+
that is designed to be read by a human who wishes to see the evolution of the project.
|
|
109
|
+
The changelog must be very succinct and orderly. You have a tendency to be over-complete.
|
|
110
|
+
Do not do this. Place links to issues and links to release messages for people who may
|
|
111
|
+
wish more information.
|
|
80
112
|
|
|
81
113
|
# Environment
|
|
82
114
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Each release also has a release message on
|
|
4
|
+
[GitHub](https://github.com/raycrafter-optical-design/raycrafter/releases).
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## [0.0.2](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.2) (2026-11-24)
|
|
8
|
+
|
|
9
|
+
- Lens picker dialog and the full Thorlabs catalogue ([#1](https://github.com/raycrafter-optical-design/raycrafter/issues/1)).
|
|
10
|
+
- Rays outside a lens's clear aperture are blocked; slow analyses wait until a drag ends ([#3](https://github.com/raycrafter-optical-design/raycrafter/issues/3)).
|
|
11
|
+
- Paraxial (ideal thin) lenses ([#6](https://github.com/raycrafter-optical-design/raycrafter/issues/6)).
|
|
12
|
+
- Several fields (beams), edited live in a field window ([#7](https://github.com/raycrafter-optical-design/raycrafter/issues/7)).
|
|
13
|
+
- File menu: new, save and load Zemax `.zmx` files ([#8](https://github.com/raycrafter-optical-design/raycrafter/issues/8)).
|
|
14
|
+
- Requires Python 3.12+ and PyQt6 6.8+.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.0.1 (2026-11-23)
|
|
18
|
+
|
|
19
|
+
First preview release.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RayCrafter
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Raytracing GUI for simple optical systems using off-the-shelf lenses and Optiland
|
|
5
5
|
Author-email: Rob Campbell <git@raacampbell.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -9,19 +9,18 @@ Project-URL: Bug Tracker, https://github.com/raycrafter-optical-design/raycrafte
|
|
|
9
9
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
10
|
Classifier: Programming Language :: Python
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.12.0
|
|
18
17
|
Description-Content-Type: text/markdown
|
|
19
18
|
License-File: LICENSE
|
|
20
19
|
Requires-Dist: optiland<0.7,>=0.6.3
|
|
21
20
|
Requires-Dist: numpy
|
|
22
21
|
Requires-Dist: scipy
|
|
23
22
|
Requires-Dist: matplotlib
|
|
24
|
-
Requires-Dist: PyQt6
|
|
23
|
+
Requires-Dist: PyQt6>=6.8
|
|
25
24
|
Requires-Dist: pyqtgraph>=0.14
|
|
26
25
|
Provides-Extra: dev
|
|
27
26
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -36,13 +35,22 @@ Dynamic: license-file
|
|
|
36
35
|
|
|
37
36
|
# RayCrafter
|
|
38
37
|
|
|
38
|
+
[](https://pypi.org/project/raycrafter)
|
|
39
|
+
[](https://pypi.org/project/raycrafter)
|
|
40
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
|
|
41
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
|
|
42
|
+
[](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
|
|
43
|
+
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
45
|
+
|
|
39
46
|
RayCrafter is an early proof of principle for a lens-level optical design tool. You place
|
|
40
47
|
off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
|
|
41
48
|
through-focus curve, MTF, ray fan and field curvature update as you go. The ray tracing is
|
|
42
49
|
done by [Optiland](https://github.com/HarrisonKramer/optiland).
|
|
43
50
|
|
|
44
|
-
At present it offers
|
|
45
|
-
|
|
51
|
+
At present it offers the Thorlabs spherical lenses and ideal (paraxial) lenses, and any number
|
|
52
|
+
of beams, each with its own width, angle, vergence, offset and wavelength. It can export the
|
|
53
|
+
system as a Zemax `.zmx` file and write an HTML report.
|
|
46
54
|
|
|
47
55
|
**Status:** pre-alpha. Expect anything to change, including the API.
|
|
48
56
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# RayCrafter
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/raycrafter)
|
|
4
|
+
[](https://pypi.org/project/raycrafter)
|
|
5
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
|
|
7
|
+
[](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
10
|
+
|
|
11
|
+
RayCrafter is an early proof of principle for a lens-level optical design tool. You place
|
|
12
|
+
off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
|
|
13
|
+
through-focus curve, MTF, ray fan and field curvature update as you go. The ray tracing is
|
|
14
|
+
done by [Optiland](https://github.com/HarrisonKramer/optiland).
|
|
15
|
+
|
|
16
|
+
At present it offers the Thorlabs spherical lenses and ideal (paraxial) lenses, and any number
|
|
17
|
+
of beams, each with its own width, angle, vergence, offset and wavelength. It can export the
|
|
18
|
+
system as a Zemax `.zmx` file and write an HTML report.
|
|
19
|
+
|
|
20
|
+
**Status:** pre-alpha. Expect anything to change, including the API.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Install and run
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
pip install raycrafter
|
|
27
|
+
raycrafter
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## An agent-generated project
|
|
34
|
+
|
|
35
|
+
The code in this repository is written by AI coding agents, working with the project's
|
|
36
|
+
developers. Due to time constraints, the project is only possible because of agentic
|
|
37
|
+
coding.
|
|
38
|
+
|
|
39
|
+
We nonetheless aim for well-designed, readable code that people who use little or no AI can
|
|
40
|
+
understand and contribute to. The rules the agents follow are in [CLAUDE.md](CLAUDE.md), and
|
|
41
|
+
significant decisions, with their reasons, are recorded in [log.md](log.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RayCrafter
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Raytracing GUI for simple optical systems using off-the-shelf lenses and Optiland
|
|
5
5
|
Author-email: Rob Campbell <git@raacampbell.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -9,19 +9,18 @@ Project-URL: Bug Tracker, https://github.com/raycrafter-optical-design/raycrafte
|
|
|
9
9
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
10
|
Classifier: Programming Language :: Python
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.12.0
|
|
18
17
|
Description-Content-Type: text/markdown
|
|
19
18
|
License-File: LICENSE
|
|
20
19
|
Requires-Dist: optiland<0.7,>=0.6.3
|
|
21
20
|
Requires-Dist: numpy
|
|
22
21
|
Requires-Dist: scipy
|
|
23
22
|
Requires-Dist: matplotlib
|
|
24
|
-
Requires-Dist: PyQt6
|
|
23
|
+
Requires-Dist: PyQt6>=6.8
|
|
25
24
|
Requires-Dist: pyqtgraph>=0.14
|
|
26
25
|
Provides-Extra: dev
|
|
27
26
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -36,13 +35,22 @@ Dynamic: license-file
|
|
|
36
35
|
|
|
37
36
|
# RayCrafter
|
|
38
37
|
|
|
38
|
+
[](https://pypi.org/project/raycrafter)
|
|
39
|
+
[](https://pypi.org/project/raycrafter)
|
|
40
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
|
|
41
|
+
[](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
|
|
42
|
+
[](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
|
|
43
|
+
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
45
|
+
|
|
39
46
|
RayCrafter is an early proof of principle for a lens-level optical design tool. You place
|
|
40
47
|
off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
|
|
41
48
|
through-focus curve, MTF, ray fan and field curvature update as you go. The ray tracing is
|
|
42
49
|
done by [Optiland](https://github.com/HarrisonKramer/optiland).
|
|
43
50
|
|
|
44
|
-
At present it offers
|
|
45
|
-
|
|
51
|
+
At present it offers the Thorlabs spherical lenses and ideal (paraxial) lenses, and any number
|
|
52
|
+
of beams, each with its own width, angle, vergence, offset and wavelength. It can export the
|
|
53
|
+
system as a Zemax `.zmx` file and write an HTML report.
|
|
46
54
|
|
|
47
55
|
**Status:** pre-alpha. Expect anything to change, including the API.
|
|
48
56
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
.gitignore
|
|
2
2
|
CLAUDE.md
|
|
3
|
+
Changelog.md
|
|
3
4
|
LICENSE
|
|
4
5
|
MANIFEST.in
|
|
5
6
|
README.md
|
|
@@ -24,21 +25,29 @@ raycrafter/core/model.py
|
|
|
24
25
|
raycrafter/core/optic_builder.py
|
|
25
26
|
raycrafter/core/plot_geometry.py
|
|
26
27
|
raycrafter/core/prescription.py
|
|
28
|
+
raycrafter/core/ray_launch.py
|
|
27
29
|
raycrafter/core/state.py
|
|
30
|
+
raycrafter/core/zmx_import.py
|
|
28
31
|
raycrafter/gui/__init__.py
|
|
32
|
+
raycrafter/gui/about_dialog.py
|
|
29
33
|
raycrafter/gui/analysis_panels.py
|
|
30
34
|
raycrafter/gui/app.py
|
|
35
|
+
raycrafter/gui/compile_notice.py
|
|
36
|
+
raycrafter/gui/field_editor.py
|
|
37
|
+
raycrafter/gui/lens_picker.py
|
|
31
38
|
raycrafter/gui/main_window.py
|
|
39
|
+
raycrafter/gui/range_slider.py
|
|
32
40
|
raycrafter/gui/side_view.py
|
|
33
41
|
raycrafter/gui/style.py
|
|
34
42
|
raycrafter/lenscatalog/__init__.py
|
|
35
43
|
raycrafter/lenscatalog/catalog.py
|
|
44
|
+
raycrafter/lenscatalog/selection.py
|
|
36
45
|
raycrafter/lenscatalog/thorlabs.py
|
|
37
|
-
raycrafter/lenscatalog/data/
|
|
46
|
+
raycrafter/lenscatalog/data/thorlabs.json.gz
|
|
38
47
|
raycrafter/report/__init__.py
|
|
39
48
|
raycrafter/report/explanations.py
|
|
40
49
|
raycrafter/report/figures.py
|
|
41
50
|
raycrafter/report/html_report.py
|
|
42
51
|
raycrafter/report/assets/report.css
|
|
43
52
|
raycrafter/report/assets/report.js
|
|
44
|
-
scripts/
|
|
53
|
+
scripts/make_thorlabs_catalog.py
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
".gitignore",
|
|
5
5
|
".pre-commit-config.yaml",
|
|
6
6
|
"CLAUDE.md",
|
|
7
|
+
"Changelog.md",
|
|
7
8
|
"LICENSE",
|
|
8
9
|
"MANIFEST.in",
|
|
9
10
|
"README.md",
|
|
@@ -17,16 +18,24 @@
|
|
|
17
18
|
"raycrafter/core/optic_builder.py",
|
|
18
19
|
"raycrafter/core/plot_geometry.py",
|
|
19
20
|
"raycrafter/core/prescription.py",
|
|
21
|
+
"raycrafter/core/ray_launch.py",
|
|
20
22
|
"raycrafter/core/state.py",
|
|
23
|
+
"raycrafter/core/zmx_import.py",
|
|
21
24
|
"raycrafter/gui/__init__.py",
|
|
25
|
+
"raycrafter/gui/about_dialog.py",
|
|
22
26
|
"raycrafter/gui/analysis_panels.py",
|
|
23
27
|
"raycrafter/gui/app.py",
|
|
28
|
+
"raycrafter/gui/compile_notice.py",
|
|
29
|
+
"raycrafter/gui/field_editor.py",
|
|
30
|
+
"raycrafter/gui/lens_picker.py",
|
|
24
31
|
"raycrafter/gui/main_window.py",
|
|
32
|
+
"raycrafter/gui/range_slider.py",
|
|
25
33
|
"raycrafter/gui/side_view.py",
|
|
26
34
|
"raycrafter/gui/style.py",
|
|
27
35
|
"raycrafter/lenscatalog/__init__.py",
|
|
28
36
|
"raycrafter/lenscatalog/catalog.py",
|
|
29
|
-
"raycrafter/lenscatalog/data/
|
|
37
|
+
"raycrafter/lenscatalog/data/thorlabs.json.gz",
|
|
38
|
+
"raycrafter/lenscatalog/selection.py",
|
|
30
39
|
"raycrafter/lenscatalog/thorlabs.py",
|
|
31
40
|
"raycrafter/palette.py",
|
|
32
41
|
"raycrafter/report/__init__.py",
|
|
@@ -35,7 +44,7 @@
|
|
|
35
44
|
"raycrafter/report/explanations.py",
|
|
36
45
|
"raycrafter/report/figures.py",
|
|
37
46
|
"raycrafter/report/html_report.py",
|
|
38
|
-
"scripts/
|
|
47
|
+
"scripts/make_thorlabs_catalog.py",
|
|
39
48
|
"tests/__init__.py",
|
|
40
49
|
"tests/conftest.py",
|
|
41
50
|
"tests/test_integration/__init__.py",
|
|
@@ -43,9 +52,14 @@
|
|
|
43
52
|
"tests/test_integration/test_report.py",
|
|
44
53
|
"tests/test_unit/__init__.py",
|
|
45
54
|
"tests/test_unit/test_bench_editing.py",
|
|
55
|
+
"tests/test_unit/test_compile_notice.py",
|
|
56
|
+
"tests/test_unit/test_fields.py",
|
|
57
|
+
"tests/test_unit/test_lens_selection.py",
|
|
46
58
|
"tests/test_unit/test_lenscatalog.py",
|
|
59
|
+
"tests/test_unit/test_paraxial_lens.py",
|
|
47
60
|
"tests/test_unit/test_physics.py",
|
|
48
61
|
"tests/test_unit/test_prescription.py",
|
|
62
|
+
"tests/test_unit/test_zmx_import.py",
|
|
49
63
|
"uv.lock"
|
|
50
64
|
]
|
|
51
65
|
}
|
raycrafter-0.0.2/log.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Decision log
|
|
2
|
+
|
|
3
|
+
Significant decisions and the reasons for them, oldest first. Append only; see CLAUDE.md for
|
|
4
|
+
the rules. Entries marked "Pilot" summarise work done before this repo existed (in
|
|
5
|
+
`pilot/evaluation` and `pilot/minimal_GUI` of the planning folder).
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 2026-11-23: Pilot: Optiland as the optics engine
|
|
9
|
+
**Decision:** Use Optiland for ray tracing and analysis rather than writing our own engine.
|
|
10
|
+
**Why:** On the SMOD4.5 system it matches Zemax to 4 digits for ray-based quantities, and it
|
|
11
|
+
imports the Thorlabs ZMF catalogue. Wavefront quantities (RMS WFE, Strehl, PSF, MTF) are wrong
|
|
12
|
+
off axis because of an ideal-lens OPD bug; this is reported upstream and does not affect the
|
|
13
|
+
real-lens systems in this release.
|
|
14
|
+
|
|
15
|
+
## 2026-11-23: Pilot: pyqtgraph rather than matplotlib for the GUI
|
|
16
|
+
**Decision:** The interactive GUI is PyQt6 + pyqtgraph. matplotlib is used only for the
|
|
17
|
+
static HTML report.
|
|
18
|
+
**Why:** In the pilot, pyqtgraph took about 1 ms to draw where matplotlib took about 6 ms (a full
|
|
19
|
+
update took about 26 ms against about 65 ms). Its items can also be dragged directly.
|
|
20
|
+
|
|
21
|
+
## 2026-11-23: Pilot: rebuild the Optiland system on every change
|
|
22
|
+
**Decision:** The model keeps its own simple state (lenses, positions, flips, beam, image plane)
|
|
23
|
+
and builds a fresh Optiland `Optic` from it for each update, instead of editing a long-lived
|
|
24
|
+
one.
|
|
25
|
+
**Why:** It is simpler and avoids stale surfaces after adding, deleting or flipping lenses. At
|
|
26
|
+
about 8 ms per build it is fast enough. The surface-based Optiland model sits under a lens-level
|
|
27
|
+
layer of our own.
|
|
28
|
+
|
|
29
|
+
## 2026-11-23: Pilot: fast and slow update paths
|
|
30
|
+
**Decision:** The side view, spot, through-focus and status bar update on every change (about
|
|
31
|
+
17 ms). MTF, ray fan and field curvature are recomputed 120 ms after the last change, and only
|
|
32
|
+
for the visible tab.
|
|
33
|
+
**Why:** It keeps dragging smooth while still showing the costlier analyses.
|
|
34
|
+
|
|
35
|
+
## 2026-11-23: Pilot: modelling choices in the analyses
|
|
36
|
+
**Decision:** Through-focus and autofocus propagate the traced image-plane rays in straight
|
|
37
|
+
lines rather than re-tracing. Field curvature is a least-squares focus of ray fans, not
|
|
38
|
+
Optiland's `FieldCurvature` class. Beam vergence is an object at -1000/V mm. The Airy radius
|
|
39
|
+
uses the NA taken from the traced rays.
|
|
40
|
+
**Why:** Each is fast (well under 1 ms where vectorised) and correct for any vergence or tilt.
|
|
41
|
+
|
|
42
|
+
## 2026-11-23: Tooling for the first package
|
|
43
|
+
**Decision:** Start from the NIU python-cookiecutter. Keep pre-commit with ruff (format at 100
|
|
44
|
+
chars, lint limit 120), lenient mypy and codespell. Drop check-manifest. CI tests Linux with
|
|
45
|
+
Python 3.12 only, under XVFB for Qt. `uv.lock` is committed.
|
|
46
|
+
**Why:** The tools cost nothing when Claude runs them and keep diffs clean for future human
|
|
47
|
+
contributors. check-manifest adds nothing because setuptools-scm already includes all tracked
|
|
48
|
+
files; a test checks the catalogue is in the wheel. The CI matrix stays small until there are
|
|
49
|
+
users.
|
|
50
|
+
|
|
51
|
+
## 2026-11-23: Versioning and release
|
|
52
|
+
**Decision:** Semantic versioning from git tags (setuptools-scm). The first release is v0.0.1,
|
|
53
|
+
published to PyPI automatically by CI when the tag is pushed (Trusted Publishing).
|
|
54
|
+
**Why:** v0.0.1 is a proof of principle; the number should not suggest anything more.
|
|
55
|
+
|
|
56
|
+
## 2026-11-23: GUI included in the plain install; Qt Designer later
|
|
57
|
+
**Decision:** `pip install raycrafter` installs PyQt6 and pyqtgraph, and `raycrafter` launches
|
|
58
|
+
the app. The GUI layout stays in code for now.
|
|
59
|
+
**Why:** It is the simplest install for colleagues. Because the core never imports Qt, a
|
|
60
|
+
`[gui]` extra can be split out later. `.ui` files will come when someone wants to edit the
|
|
61
|
+
layout by hand.
|
|
62
|
+
|
|
63
|
+
## 2026-11-23: Ship only the lenses the GUI offers
|
|
64
|
+
**Decision:** The packaged Thorlabs catalogue holds only the 2" A-coated achromats and the
|
|
65
|
+
A-coated negative achromats shown in the drop-down, built from the full decoded catalogue by
|
|
66
|
+
`scripts/make_thorlabs_subset.py`.
|
|
67
|
+
**Why:** It keeps the package small (the full JSON is 4 MB and 2109 lenses). Open question: the
|
|
68
|
+
catalogues may later move to a separate, separately installed repository.
|
|
69
|
+
|
|
70
|
+
## 2026-11-23: Package layout for the first release
|
|
71
|
+
**Decision:** The pilot's three files became four subpackages: `core` (state, Optiland system
|
|
72
|
+
building, analyses, `OpticalModel`; no Qt), `lenscatalog`, `report` and `gui` (style, side
|
|
73
|
+
view, analysis panels, main window). Drawing geometry used by both the GUI and the report
|
|
74
|
+
(lens outlines, incoming rays, plot ranges) lives once, in `core/plot_geometry.py`.
|
|
75
|
+
**Why:** Each subpackage can be used alone (e.g. the catalogue or the report without Qt), no
|
|
76
|
+
file exceeds about 500 lines, and the GUI and report can no longer draw things differently.
|
|
77
|
+
|
|
78
|
+
## 2026-11-23: Work on main for now
|
|
79
|
+
**Decision:** Commit directly to `main`; use branches only when there is a real need.
|
|
80
|
+
**Why:** There are no users yet, so feature branches and PRs add overhead with no benefit. To
|
|
81
|
+
be revisited when the project has users or more contributors.
|
|
82
|
+
|
|
83
|
+
## 2026-11-23: Qt in CI without XVFB
|
|
84
|
+
**Decision:** CI runs the GUI tests with Qt's off-screen platform and installs Qt's system
|
|
85
|
+
libraries (libEGL etc.) with apt, instead of running under XVFB.
|
|
86
|
+
**Supersedes:** the XVFB part of "Tooling for the first package".
|
|
87
|
+
**Why:** The first CI run failed because the runner lacks libEGL. The tests never needed a
|
|
88
|
+
display, so XVFB only added a dependency (and a deprecated action).
|
|
89
|
+
|
|
90
|
+
## 2026-11-23: dev branch and fewer CI runs
|
|
91
|
+
**Decision:** Small changes go straight onto `main`; longer jobs are done on a long-lived `dev`
|
|
92
|
+
branch and merged into `main` when complete. Feature branches (risky work only) and all pull
|
|
93
|
+
requests go into `dev`. CI runs only on pushes to `main`, on pull requests, on tags and by
|
|
94
|
+
hand; a newer push cancels an older run on the same branch.
|
|
95
|
+
**Supersedes:** "Work on main for now".
|
|
96
|
+
**Why:** Testing every push to every branch was excessive. Pre-commit and local pytest check
|
|
97
|
+
each commit; CI checks on a clean machine before anything is merged or released.
|
|
98
|
+
|
|
99
|
+
## 2026-11-23: Require Python 3.12 or newer
|
|
100
|
+
**Decision:** `requires-python` is `>=3.12`; Python 3.11 is dropped from the classifiers and tox.
|
|
101
|
+
**Why:** On 3.11 numba emits `NumbaIRAssumptionWarning` while compiling Optiland's conic code,
|
|
102
|
+
which our warnings-as-errors tests turn into a failure. CI only ever ran 3.12, so 3.11 support
|
|
103
|
+
was never real. Rob chose to drop it rather than filter the warning or report it upstream.
|
|
104
|
+
|
|
105
|
+
## 2026-11-24: Ship the whole Thorlabs catalogue, gzipped
|
|
106
|
+
**Decision:** The package ships every Thorlabs lens except the cylindrical ones (1564) as
|
|
107
|
+
`thorlabs.json.gz` (about 110 KB), made by `scripts/make_thorlabs_catalog.py`. All parts are
|
|
108
|
+
listed in the new lens picker (#1); near-duplicate focal lengths are no longer dropped.
|
|
109
|
+
Aspheres are in the file but not offered until `LensSurface` can represent them (#2).
|
|
110
|
+
**Why:** The picker's categories and filters need the full range. Coating variants share
|
|
111
|
+
prescriptions, so the 3 MB of JSON compresses about 27-fold.
|
|
112
|
+
**Supersedes:** 2026-11-23 "Ship only the lenses the GUI offers".
|
|
113
|
+
|
|
114
|
+
## 2026-11-24: Lens picker design (#1)
|
|
115
|
+
**Decision:** "Add lens" opens a dialog: category -> diameter -> lens tree, part-number search,
|
|
116
|
+
and filters for coating (default: all coatings), |f| range and sign. The |f| slider is
|
|
117
|
+
logarithmic and uses the magnitude; the sign is chosen with "hide positive/negative". After
|
|
118
|
+
Insert, a ghost follows the pointer and snaps to the nearest gap the lens fits in.
|
|
119
|
+
**Why:** An "Uncoated" default hid every achromat (Thorlabs sells none uncoated). A log scale
|
|
120
|
+
suits focal lengths from 4 mm to 2.5 m. Snapping means a placed lens never overlaps another.
|
|
121
|
+
|
|
122
|
+
## 2026-11-24: Lens surfaces have their clear aperture (#3)
|
|
123
|
+
**Decision:** Every lens surface blocks rays outside the lens's clear semi-aperture. Analyses
|
|
124
|
+
use only the rays that get through; with none, they report "no light". The MTF uses the part
|
|
125
|
+
of the beam that gets through on axis. Blocked rays are drawn up to the plane of the rim.
|
|
126
|
+
**Why:** Without apertures, a beam wider than a lens was traced through surfaces that do not
|
|
127
|
+
exist, giving wrong results or NaN (and a crash). Thorlabs' ZMX files give every surface the
|
|
128
|
+
same fixed aperture, so this matches the vendor model; Zemax agreement to be checked (#4).
|
|
129
|
+
|
|
130
|
+
## 2026-11-24: f-number from the transmitted beam
|
|
131
|
+
**Decision:** The f-number is |EFL| / the diameter of the on-axis beam that gets through every
|
|
132
|
+
lens, and is shown as e.g. "f/1.9 (beam clipped to 10.8 mm)" when a lens rim cuts the beam.
|
|
133
|
+
**Why:** When the beam overfills a lens, the rim sets the cone of light, so the nominal beam
|
|
134
|
+
overstates the speed. This probably differs from Zemax's paraxial F/#, which uses the system
|
|
135
|
+
aperture (#5); matching Zemax is not the aim, since a Zemax user would set the stop to the
|
|
136
|
+
lens. RayCrafter has no field stops yet. The probe costs about 3.5 ms per fast update.
|
|
137
|
+
|
|
138
|
+
## 2026-11-24: One wavelength (555 nm) for every lens, including IR designs
|
|
139
|
+
**Decision:** All tracing is at 555 nm, whatever a lens's design wavelength. The picker lists
|
|
140
|
+
the catalogue focal length.
|
|
141
|
+
**Why:** Recorded while adding the full catalogue: our prescriptions reproduce Optiland's own
|
|
142
|
+
ZMX import exactly, but IR-designed lenses (C, E, 1064 coatings etc.) come out a few percent
|
|
143
|
+
off their catalogue focal length at 555 nm because of dispersion. Wavelength choice is future
|
|
144
|
+
work.
|
|
145
|
+
|
|
146
|
+
## 2026-11-24: "Test in Zemax" issues
|
|
147
|
+
**Decision:** Checks that need a Zemax licence become GitHub issues with the "Test in Zemax"
|
|
148
|
+
label, each saying what to compare and how (e.g. #4, #5). Results can become reference tests.
|
|
149
|
+
**Why:** Not every developer has Zemax, and these checks are what support our claims of
|
|
150
|
+
agreement with it, so they need a visible queue rather than notes in a conversation.
|
|
151
|
+
|
|
152
|
+
## 2026-11-24: Responsiveness first: only essential work on every frame
|
|
153
|
+
**Decision:** The GUI must stay responsive, so anything computed on every change (each drag
|
|
154
|
+
event or slider tick) must be something the user is watching. Other work runs after changes
|
|
155
|
+
settle (the slow plots) or only once nothing is being dragged. The f-number is the first
|
|
156
|
+
case: it is computed only then, and is left out of the status bar during a drag.
|
|
157
|
+
**Supersedes:** the "about 3.5 ms per fast update" in "f-number from the transmitted beam".
|
|
158
|
+
**Why:** Optiland is noticeably slower on some machines (Rob's Windows PC), and nobody reads
|
|
159
|
+
the f-number while dragging.
|
|
160
|
+
|
|
161
|
+
## 2026-11-24: Slow plots fade during a drag and update on release
|
|
162
|
+
**Decision:** While a lens, the image plane or a slider handle is dragged, the MTF, ray fan
|
|
163
|
+
and field curvature are faded (40% opacity) and not recomputed; they are recomputed when
|
|
164
|
+
the mouse is released. The f-number keeps showing its last value until then.
|
|
165
|
+
**Supersedes:** the slow plots' "after changes settle" in "Pilot: fast and slow update
|
|
166
|
+
paths", for drags only (other changes still wait SLOW_PLOT_DELAY_MS), and hiding the f-number
|
|
167
|
+
during a drag in "Responsiveness first".
|
|
168
|
+
**Why:** A pause mid-drag used to trigger the slow plots, which stutters on slower machines.
|
|
169
|
+
Fading shows they are out of date; keeping the last f-number is less jarring than hiding it.
|
|
170
|
+
|
|
171
|
+
## 2026-11-24: Fields replace the beam sliders (#7)
|
|
172
|
+
**Decision:** The bench has a list of fields (beams), each with its own diameter, angle,
|
|
173
|
+
vergence, offset, wavelength and colour, edited live in a small non-modal field window. The
|
|
174
|
+
beam diameter, angle and vergence sliders and "Reset beam" are removed. The spot diagram and
|
|
175
|
+
side view show every field; through-focus, MTF, ray fan, field curvature, f-number and
|
|
176
|
+
autofocus use the selected field.
|
|
177
|
+
**Why:** The sliders were a single-beam prototype. Rob chose to remove them rather than keep
|
|
178
|
+
two ways of setting the same beam.
|
|
179
|
+
|
|
180
|
+
## 2026-11-24: Each field is traced at its own wavelength
|
|
181
|
+
**Decision:** Every field is traced at its own wavelength (default 555 nm), so glass
|
|
182
|
+
dispersion shows, e.g. as a chromatic focal shift between a blue and a red field.
|
|
183
|
+
**Supersedes:** "One wavelength (555 nm) for every lens, including IR designs".
|
|
184
|
+
**Why:** Rob's choice when fields gained a wavelength; using it only for the beam colour
|
|
185
|
+
would have been misleading.
|
|
186
|
+
|
|
187
|
+
## 2026-11-24: Each field's rays are launched by RayCrafter, not Optiland (#7)
|
|
188
|
+
**Decision:** The Optiland system is built once per update and each field's rays are made
|
|
189
|
+
in numpy (`core/ray_launch.py`) and traced with `optic.surfaces.trace`. A beam is defined
|
|
190
|
+
where it crosses the first lens's front vertex plane. The MTF still uses Optiland's own
|
|
191
|
+
object and pupil (it needs them), so it ignores a field's offset (#10).
|
|
192
|
+
**Supersedes:** "Beam vergence is an object at -1000/V mm" in "Pilot: modelling choices in
|
|
193
|
+
the analyses", except for the MTF and the ZMX export.
|
|
194
|
+
**Why:** Optiland's aperture, object and field angles are system-wide, but each field has its
|
|
195
|
+
own width, vergence, offset and wavelength. One build per field would cost ~8 ms each.
|
|
196
|
+
|
|
197
|
+
## 2026-11-24: Loading ZMX files matches lenses against the catalogue (#8)
|
|
198
|
+
**Decision:** Load ZMX turns each run of glass surfaces into a lens and looks it up in the
|
|
199
|
+
catalogue (curvatures, thicknesses and glasses, both ways round), so part numbers and flips
|
|
200
|
+
come back; unmatched lenses keep their prescription as "Imported lens N". Paraxial surfaces
|
|
201
|
+
become paraxial lenses. Aspheres, conics, mirrors and tilts are refused. Fields are rebuilt
|
|
202
|
+
from the EPD, object distance, angles and wavelengths, with any simplification reported.
|
|
203
|
+
**Why:** Matching keeps designs editable as catalogue parts. Lossy parts are parked (#11, #12).
|