Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR adds support for calculating and plotting polychromatic Modulation Transfer Function (MTF) in the GeometricMTF class.

Key changes:

  • GeometricMTF now accepts wavelength="all" or a list of wavelengths.
  • When multiple wavelengths are provided, it calculates the weighted average of the monochromatic MTFs and the diffraction-limited MTF.
  • The max_freq is now automatically determined by the shortest wavelength (highest cutoff) when calculating for multiple wavelengths.
  • Refactored _generate_mtf_data to use be.where and out-of-place operations, resolving a RuntimeError with the PyTorch backend concerning in-place operations on leaf variables.
  • Updated optiland.utils.resolve_wavelengths to robustly handle single scalar inputs, ensuring backward compatibility.

Testing:

  • Added test_polychromatic_mtf_calculation to verify structure, value ranges, and frequency limits.
  • Added test_single_wavelength_normalization to ensure single-wavelength calculations remain correctly normalized (peak at 1.0) and are not incorrectly scaled by the total system weight.
  • Verified all existing tests pass.

PR created automatically by Jules for task 6427663426429089712 started by @HarrisonKramer

- Updated `GeometricMTF` to support `wavelength="all"` and list of wavelengths.
- Implemented weighted average logic for polychromatic MTF calculation.
- Fixed backend compatibility issue (Torch in-place operations) in MTF generation.
- Updated `resolve_wavelengths` in `optiland/utils.py` to handle scalar inputs.
- Verified with regression tests for both polychromatic and single-wavelength cases.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

- Resolved `zip()` strict mode issue in `optiland/mtf/geometric.py` (B905).
- Applied Ruff formatting to `optiland/mtf/geometric.py` and `optiland/utils.py`.
- Verified all tests pass.
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.

1 participant