Add jax_zero_contour-based critical curve and caustic tracing#312
Merged
Add jax_zero_contour-based critical curve and caustic tracing#312
Conversation
Replaces the dense marching-squares grid evaluation with a JAX contour tracer that evaluates the eigen-value function only along the curve itself — far fewer function calls, no input grid required. New LensCalc methods - _make_eigen_fn(kind, pixel_scales): unified JAX scalar function factory (tangential/radial differ only in sign; hessian_xy is symmetrised) - _init_guess_from_coarse_grid: 25x25 seed search via marching squares - _critical_curve_list_via_zero_contour: shared private implementation - _caustic_list_via_zero_contour: shared private implementation - tangential/radial_critical_curve_list_via_zero_contour_from - tangential/radial_caustic_list_via_zero_contour_from - einstein_radius_list/scalar_via_zero_contour_from Visualizer config (visualize/general.yaml) - New key general.critical_curves_method (default: zero_contour) - plot_utils._critical_curves_method() reads config and dispatches - Both _critical_curves_from and _caustics_from respect the setting - Gracefully returns [] when no curve found (no ValueError in plot path) Also fixes pre-existing bug in galaxy_plots.subplot_of_mass_profiles where output filenames were prefixed with "subplot_" contrary to the intended behaviour described in commit 585acb6. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add jax_zero_contour to pyproject.toml [optional] extras and wrap the import inside _critical_curve_list_via_zero_contour in a try/except so that the rest of the package imports cleanly on build servers that do not have the package installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Appending pts[0] to the end of each path ensures the plotted critical curve and its derived caustic have no gap between the last and first point. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
jax_zero_contourpackage to trace critical curves and caustics via Newton's method + Euler-Lagrange stepping, eliminating the need for a dense input grid.LensCalcmethods:tangential/radial_critical_curve_list_via_zero_contour_from,tangential/radial_caustic_list_via_zero_contour_from,einstein_radius_via_zero_contour_from.[]when no critical curve is found (e.g. sub-critical mass configurations).critical_curves_methodconfig key tovisualize/general.yaml(zero_contourdefault,marching_squaresfallback) so the visualizer/plotting layer can dispatch between methods without code changes.galaxy_plots.subplot_of_mass_profiles(was saving assubplot_convergence.png, tests expectedconvergence.png).Test plan
python -m pytest test_autogalaxy/— 833 passed, 0 failed (confirmed before commit)autolens_workspace_test/scripts/critical_curves_zero_contour.pycovers return-type checks, cross-comparison with marching squares (mean-radius rtol ≤ 5%, centroid atol ≤ 0.15 arcsec, area rtol ≤ 10%), auto-seed path, and offset-centre lenstest_autogalaxy/plot/mat_wrap/test_visuals.py::test__mass_plotter__tangential_critical_curves(geometric consistency check ≤ 5% mean-radius difference)🤖 Generated with Claude Code