Repository navigation
Keep the sign of the phase of relief rulings, and measure it from the side the light arrives on - #302
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #302 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 142 142
Lines 14007 14059 +52
=========================================
+ Hits 14007 14059 +52
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…side the light arrives on `AbstractRulings._gamma` took the magnitude of `n1 cos(alpha) - n2 cos(beta)`, and measured `alpha` from the normal whichever side the light arrived on. - The magnitude threw away which way an asymmetric profile blazes. A facet that reflects light one way refracts the light entering a denser medium the other way, but `SawtoothRulings` and `BlazedRulings` blazed the same orders for both. - Light arriving along the normal, from the back of the surface, made `cos(alpha)` negative while `cos(beta)` stayed positive, so a mirror's phase cancelled and every relief profile sent all of the light into order 0. Now `_gamma` measures both angles from the side the light arrives on, which is the side `incident_effective` counts the orders from, and keeps the sign. The symmetric profiles do not depend on it, and `TriangularRulings`, whose form assumed it was not negative, takes its magnitude. The notes of `SawtoothRulings` and `BlazedRulings` say which orders they blaze in reflection and in transmission. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB
roytsmart
force-pushed
the
fix/rulings-gamma-sign
branch
from
December 1, 2026 22:41
3b553c1 to
4b0afb1
Compare
- The notes of the symmetric profiles, and a comment in `BlazedRulings.efficiency`, still wrote gamma with an absolute value. They now write it with its sign, and say that a symmetric profile depends only on its magnitude. - Gamma has the sign of the depth for a mirror, not always positive, and the opposite sign for transmission only where n2 cos(beta) > n1 cos(alpha), which steep orders entering a denser medium do not satisfy. - Annotate the new tests with `-> None`, and build their orders with `na.arange`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two bugs in
AbstractRulings._gamma, the phase amplitude γ = π h₁ (n₁ cos α − n₂ cos β) / 2λ that every relief profile (sinusoidal, square, sawtooth, triangular, blazed, rectangular) is built on. Both were found in the review of #301.Bugs
_gammatooknp.abs(n1 cos α − n2 cos β). For a symmetric profile the sign doesn't matter, but for an asymmetric one it decides which orders are blazed: a facet that reflects light one way refracts light entering a denser medium the other way.SawtoothRulingsandBlazedRulingsblazed the same orders in both cases. For example, at 3°, 20 µm, 500 nm, normal incidence into n = 1.5, the peak was at order −1 when the facet refracts the light into +1.cos α = −(a · n)is negative when the ray travels along the normal, butcos βwas always a positive square root. For a mirror, n₁(cos α + cos β) then cancels to about 0, so every relief profile returned η₀ = 1 and nothing in any other order.incident_effectivealready counts the orders from the side the light arrives on, usingsign(a · n), but the efficiency didn't.Fix
cos α = |a · n|: both angles are measured from the normal on the side the light arrives on, which is the sideincident_effectivecounts the orders from.TriangularRulingstakes |γ|, because its closed form assumes γ ≥ 0. The other symmetric profiles are even in γ.AbstractRulings.efficiency,_gamma,SawtoothRulingsandBlazedRulingsnow give γ with its sign, and say which orders each profile blazes in reflection and in transmission.Tests
test_efficiency_facet: for a sawtooth and for a 3°/12°BlazedRulings, for mirror and transmission, from the front and from the back, at 0° and 10° incidence, the blazed order is the one closest to where the blaze facet reflects or refracts the light (geometric optics), with efficiency > 0.8 (sawtooth) or > 0.5 (blazed).test_efficiency_back: for every relief profile, mirror and transmission, light from the back has the efficiency of light from the front, reflected through the surface, in the opposite order of the profile turned upside down.test_efficiency_reciprocal, now withBlazedRulings, moved to a module variable,_rulings_relief, so the new test can share it.All 255 rulings tests and all 151 surface tests pass locally;
test_to_dxfonly passes serially, the known xdist race. Black and ruff are clean.Rebased on #301
Rebased onto main after #301 (
BlazedRulings) merged: its notes give γ with its sign, it is in_rulings_relief, and it is in the facet and back-side tests. The test helpers both PRs defined are no longer duplicated.🤖 Generated with Claude Code
https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB