Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

export DIRENV_WARN_TIMEOUT=20s

eval "$(devenv direnvrc)"

use devenv

if [[ -d .devenv/state/venv/bin ]]; then
PATH_add .devenv/state/venv/bin
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,5 @@ fabric.properties
env-*/
venv/
raytracing/_version.py
.devenv/
.direnv/
65 changes: 65 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1774957469,
"narHash": "sha256-YkzJi44ntRLRNTmkQoABnQU0oxQjKaOHRm0bp0uxUuI=",
"owner": "cachix",
"repo": "devenv",
"rev": "7ea7c651664ea1526387a68d66a9f4e7f17dc146",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1774287239,
"narHash": "sha256-W3krsWcDwYuA3gPWsFA24YAXxOFUL6iIlT6IknAoNSE=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "fa7125ea7f1ae5430010a6e071f68375a39bd24c",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1773840656,
"narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
57 changes: 57 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ pkgs, lib, ... }:

let
python = pkgs.python312;
pythonPackages = python.pkgs;
in
{
packages = [
python
pythonPackages.tkinter
pkgs.tk
pkgs.tcl
pkgs.stdenv.cc.cc.lib
pkgs.zlib
pkgs.libGL
pkgs.xorg.libX11
pkgs.xorg.libXext
pkgs.xorg.libXrender
pkgs.xorg.libSM
pkgs.xorg.libICE
];

env = {
VENV_DIR = ".devenv/state/venv";
PIP_DISABLE_PIP_VERSION_CHECK = "1";
PYTHONNOUSERSITE = "1";
TCL_LIBRARY = "${pkgs.tcl}/lib/tcl${pkgs.tcl.version}";
TK_LIBRARY = "${pkgs.tk}/lib/tk${pkgs.tk.version}";
LD_LIBRARY_PATH = lib.makeLibraryPath [
pkgs.stdenv.cc.cc.lib
pkgs.zlib
pkgs.libGL
pkgs.xorg.libX11
pkgs.xorg.libXext
pkgs.xorg.libXrender
pkgs.xorg.libSM
pkgs.xorg.libICE
];
};

enterShell = ''
echo "RayTracing devenv"
echo "Python $(${python}/bin/python --version | cut -d' ' -f2)"

if [ ! -x "$VENV_DIR/bin/python" ]; then
${python}/bin/python -m venv --system-site-packages "$VENV_DIR"
fi

. "$VENV_DIR/bin/activate"

python -m ensurepip --upgrade >/dev/null 2>&1 || true
python -m pip install --upgrade pip setuptools wheel build >/dev/null
python -m pip install --upgrade -e ".[gui]" pillow basedpyright ruff >/dev/null

export PATH="$PWD/$VENV_DIR/bin:$PATH"
'';
}
1 change: 1 addition & 0 deletions raytracing/common-optical-layouts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Common optical layout starter files for the RayTracing UI."""
19 changes: 19 additions & 0 deletions raytracing/common-optical-layouts/_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from raytracing import *

TITLE = "New Layout"
OBJECT_THICKNESS = "Finite" # or "Infinity"
IMAGE_THICKNESS = 100 # or "Infinity"


def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE

# Example sequence:
# path.append(Space(d=50))
# path.append(Lens(f=100, diameter=25.4))
# path.append(Space(d=100))
# path.append(Aperture(diameter=10))
# path.append(Space(d=100))

path.display(comments=comments)
19 changes: 19 additions & 0 deletions raytracing/common-optical-layouts/cooke_triplet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from raytracing import *

TITLE = "Cooke Triplet"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 38.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=7.5))
path.append(ThickLens(n=1.69, R1=38.0, R2=150.0, thickness=6.0, diameter=34))
path.append(Space(d=4.0))
path.append(ThickLens(n=1.67, R1=-28.0, R2=24.0, thickness=2.5, diameter=20))
path.append(Space(d=10.0))
path.append(Aperture(diameter=11))
path.append(Space(d=32.0))
path.append(ThickLens(n=1.72, R1=65.0, R2=-32.0, thickness=6.5, diameter=30))
path.append(Space(d=38.0))
path.display(comments=comments)
21 changes: 21 additions & 0 deletions raytracing/common-optical-layouts/double_gauss_lens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from raytracing import *

TITLE = "Double Gauss Lens"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 48.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=8.0))
path.append(ThickLens(n=1.67, R1=55.0, R2=180.0, thickness=7.0, diameter=40))
path.append(Space(d=4.0))
path.append(ThickLens(n=1.62, R1=-42.0, R2=28.0, thickness=3.0, diameter=28))
path.append(Space(d=10.0))
path.append(Aperture(diameter=18))
path.append(Space(d=4.0))
path.append(ThickLens(n=1.62, R1=28.0, R2=-42.0, thickness=3.0, diameter=28))
path.append(Space(d=28.0))
path.append(ThickLens(n=1.67, R1=180.0, R2=-55.0, thickness=7.0, diameter=40))
path.append(Space(d=48.0))
path.display(comments=comments)
17 changes: 17 additions & 0 deletions raytracing/common-optical-layouts/double_sided_telecentric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from raytracing import *

TITLE = "Double-Sided Telecentric"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 80.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=20))
path.append(Lens(f=80, diameter=32))
path.append(Space(d=80))
path.append(Aperture(diameter=10))
path.append(Space(d=80))
path.append(Lens(f=80, diameter=32))
path.append(Space(d=80))
path.display(comments=comments)
16 changes: 16 additions & 0 deletions raytracing/common-optical-layouts/finite_conjugate_objective.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from raytracing import *

TITLE = "Finite Conjugate Objective"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 140.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Aperture(diameter=12))
path.append(Space(d=18.0))
path.append(ThickLens(n=1.72, R1=32.0, R2=-45.0, thickness=5.0, diameter=24))
path.append(Space(d=6.0))
path.append(ThickLens(n=1.67, R1=48.0, R2=-120.0, thickness=4.0, diameter=22))
path.append(Space(d=140.0))
path.display(comments=comments)
15 changes: 15 additions & 0 deletions raytracing/common-optical-layouts/galilean_beam_expander.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from raytracing import *

TITLE = "Galilean Beam Expander"
OBJECT_THICKNESS = "Infinity"
IMAGE_THICKNESS = "Infinity"

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Aperture(diameter=8))
path.append(Space(d=25))
path.append(Lens(f=-25, diameter=14))
path.append(Space(d=75))
path.append(Lens(f=100, diameter=40))
path.display(comments=comments)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from raytracing import *

TITLE = "20x Infinity Objective + 200 mm Tube Lens"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 200.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=10.0))
path.append(Lens(f=10, diameter=8))
path.append(Aperture(diameter=6))
path.append(Space(d=60.0))
path.append(Lens(f=200, diameter=30))
path.append(Space(d=200.0))
path.display(comments=comments)
17 changes: 17 additions & 0 deletions raytracing/common-optical-layouts/keplerian_beam_expander.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from raytracing import *

TITLE = "Keplerian Beam Expander"
OBJECT_THICKNESS = "Infinity"
IMAGE_THICKNESS = "Infinity"

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Aperture(diameter=12))
path.append(Space(d=40))
path.append(Lens(f=40, diameter=20))
path.append(Space(d=40))
path.append(Aperture(diameter=10))
path.append(Space(d=120))
path.append(Lens(f=120, diameter=42))
path.display(comments=comments)
14 changes: 14 additions & 0 deletions raytracing/common-optical-layouts/layout_2f.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from raytracing import *

TITLE = "2f"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 200

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Aperture(diameter=25.4))
path.append(Space(d=200))
path.append(Lens(f=100, diameter=25.4))
path.append(Space(d=200))
path.display(comments=comments)
17 changes: 17 additions & 0 deletions raytracing/common-optical-layouts/layout_4f.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from raytracing import *

TITLE = "4f"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 100

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=100))
path.append(Lens(f=100, diameter=30))
path.append(Space(d=100))
path.append(Aperture(diameter=18))
path.append(Space(d=100))
path.append(Lens(f=100, diameter=30))
path.append(Space(d=100))
path.display(comments=comments)
17 changes: 17 additions & 0 deletions raytracing/common-optical-layouts/object_space_telecentric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from raytracing import *

TITLE = "Object-Space Telecentric"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 120.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=20))
path.append(Lens(f=80, diameter=32))
path.append(Space(d=80))
path.append(Aperture(diameter=12))
path.append(Space(d=70))
path.append(Lens(f=120, diameter=34))
path.append(Space(d=120))
path.display(comments=comments)
19 changes: 19 additions & 0 deletions raytracing/common-optical-layouts/retrofocus_lenses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from raytracing import *

TITLE = "Retrofocus Lenses"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 36.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=12.0))
path.append(ThickLens(n=1.61, R1=-65.0, R2=34.0, thickness=7.0, diameter=44))
path.append(Space(d=20.0))
path.append(Aperture(diameter=18))
path.append(Space(d=8.0))
path.append(ThickLens(n=1.70, R1=42.0, R2=-120.0, thickness=8.0, diameter=34))
path.append(Space(d=26.0))
path.append(ThickLens(n=1.72, R1=58.0, R2=-44.0, thickness=6.5, diameter=30))
path.append(Space(d=36.0))
path.display(comments=comments)
12 changes: 12 additions & 0 deletions raytracing/common-optical-layouts/single_lens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from raytracing import *

TITLE = "Single Lens"
OBJECT_THICKNESS = "Finite"
IMAGE_THICKNESS = 200

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Lens(f=100, diameter=25.4))
path.append(Space(d=200))
path.display(comments=comments)
17 changes: 17 additions & 0 deletions raytracing/common-optical-layouts/telephoto_infinity_focus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from raytracing import *

TITLE = "Telephoto (Infinity Focus)"
OBJECT_THICKNESS = "Infinity"
IMAGE_THICKNESS = 12.0

def exampleCode(comments=None):
path = ImagingPath()
path.label = TITLE
path.append(Space(d=20.0))
path.append(ThickLens(n=1.69, R1=140.0, R2=-80.0, thickness=8.0, diameter=42))
path.append(Space(d=8.0))
path.append(Aperture(diameter=20))
path.append(Space(d=55.0))
path.append(ThickLens(n=1.72, R1=-35.0, R2=140.0, thickness=4.0, diameter=26))
path.append(Space(d=12.0))
path.display(comments=comments)
Loading