feat(fileio): import and export Zemax rectangular and elliptical apertures by jaruiz6363 · Pull Request #954 · optiland/optiland · GitHub
Skip to content

feat(fileio): import and export Zemax rectangular and elliptical apertures - #954

Merged
HarrisonKramer merged 1 commit into
optiland:masterfrom
jaruiz6363:feat/zemax-rect-ellip-apertures
Oct 24, 2026
Merged

HarrisonKramer merged 1 commit into
optiland:masterfrom
jaruiz6363:feat/zemax-rect-ellip-apertures

Conversation

@jaruiz6363

Copy link
Copy Markdown
Contributor

Refs #931. Depends on #953: this branch sits on top of the OBSC commit (461da65), which will drop out of the diff once #953 merges. Only the last commit (48f9e8d) is new here.

Summary

The Zemax reader skipped rectangular and elliptical surface apertures; it only stopped them from leaving a fixed ("U") semi-diameter clip behind. The writer exported a RectangularAperture as a circular CLAP of radius x_max.

OpticStudio writes the four types as:

Type Record
Rectangular aperture SQAP x_half y_half pickup
Rectangular obscuration SQOB x_half y_half pickup
Elliptical aperture ELAP x_half y_half pickup
Elliptical obscuration ELOB x_half y_half pickup

An OBDC record decentres any of them. The last field names a pickup surface (0 for none); the file still carries the picked-up half-widths, so the reader uses the values on the line.

Reader

  • SQAP → RectangularAperture(ox - xh, ox + xh, oy - yh, oy + yh)
  • ELAP → EllipticalAperture(xh, yh, ox, oy)
  • SQOB / ELOB → DifferenceAperture(RadialAperture(0, inf), shape): rays inside the shape are blocked, everything else passes with no outer limit, like OBSC.
  • OBDC applies in either order relative to the shape record, as for CLAP and OBSC.

Writer

Emits the matching SQAP / SQOB / ELAP / ELOB record plus OBDC for a non-zero centre, so these apertures round-trip. An asymmetric RectangularAperture is written as its half-widths and centre.

Tests

  • New tests/test_fileio/test_zemax_rect_ellip_apertures.py: aperture types built, which rays pass or are blocked for each type with a decentred 6 × 3 shape, replacement of the fixed semi-diameter clip, OBDC order, the pickup field, and round trips (records written and to_dict equality).
  • test_zemax_semi_diameter.py: SQAP and ELAP removed from the unsupported-aperture list (SPID and USAP remain).

Aperture tests pass on numpy and torch.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@HarrisonKramer

Copy link
Copy Markdown
Collaborator

Hi @jaruiz6363,

Thanks for splitting this out. #953 is merged, so could you rebase this onto master? The OBSC commit should drop out of the diff and leave only the rectangular/elliptical change. Happy to review it as soon as it is updated.

Best,
Kramer

Read SQAP and ELAP as RectangularAperture and EllipticalAperture, and
their obscuration counterparts SQOB and ELOB as an unbounded aperture
minus the shape, so rays inside it are blocked and everything else
passes. OBDC decentres all four, in either order. The writer emits the
same records, plus OBDC, instead of approximating a rectangle as a
circular CLAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jaruiz6363
jaruiz6363 force-pushed the feat/zemax-rect-ellip-apertures branch from 48f9e8d to 4361c13 Compare October 20, 2026 16:29
@jaruiz6363

Copy link
Copy Markdown
Contributor Author

@HarrisonKramer
HarrisonKramer merged commit 302f8f4 into optiland:master Oct 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants