-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-plane lensing #37
Conversation
This class stores a list of mass model objects. Given the eta values defining the geometry of the system it can ray trace observed positions onto each mass plane defined.
This class stores a list of light models and given a ray-traced positions for each light plane will calculated the surface brightness of each light plane and return them as a stack.
This class is ued to forward model a multi-plane lens system. This class adds new features of the current single-plane case: - Only use mask boundaries for pixel grid extents (for speed) - Only ray trace the observed positions once (and feed the results into the extent method if needed) - add source_grid_scale to scale the resulting extents of a pixel grid by a constant factor - add conjugate_points as a convenience function to quickly trace a know list of points to each source plane. To do: - add doc strings - make sure all features work as expected
Pull Request Test Coverage Report for Build 10490896144Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
pixels_x_coord, | ||
pixels_y_coord, | ||
k=k_light, | ||
) * self._source_arc_masks_flat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CKrawczyk I think the multiplication by the arc masks should be performed after convolution, to avoid introducing artifacts in the model at the edge of the masks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did it this way because the convolution happens once on the final image rather than each slice independently. To get around the artifact a "soft mask" can be used (gaussian blur the mask so it is a smooth gradient down to zero at the edge).
For completion, I added a "direct" calculation method for the distortion matrix that uses the |
Thanks for the push @CKrawczyk ! These features will be very handy. |
I think documentation is the only thing missing at the moment. I will try to take some time today to get that mostly sorted. I noticed that you use several different doc string formats throughout the code base, what one should I aim to use? |
@CKrawczyk The one that you just pushed is the right one, it's longer but much easier to read than other formats 👍 |
This is ready for review and testing. Every public-facing class method should have a doc string. |
For testing above I was using this model setup: mass_model = MPMassModel([
['SIS'],
['SIS']
])
light_model=MPLightModel([
[],
[],
['GAUSSIAN']
], [{}, {}, {}])
kwargs_numerics = {'supersampling_factor': 5}
lens_image = MPLensImage(
pixel_grid, psf, noise,
mass_model, light_model,
kwargs_numerics=kwargs_numerics
)
kwargs_mass = [
[{'theta_E': 1.0, 'center_x': 0.0, 'center_y': 0.0}],
[{'theta_E': 0.9, 'center_x': 0.9, 'center_y': 0.0}]
]
kwargs_light = [
[],
[],
[{'amp': 2, 'sigma': 0.05, 'center_x': 0.9, 'center_y': 0.05}]
]
eta_flat=jnp.array([1.05])
image = lens_image.model(
eta_flat=eta_flat,
kwargs_mass=kwargs_mass,
kwargs_light=kwargs_light,
) |
The number of planes axis will always be -2 coming out of vectorize.
I have done a local test with an example notebook (the one used to make the plot above). Just found one small bug that I fixed with how the |
For clarification, the where Where As the The MP lensing equation is given by: By expanding this out and padding with some zeros we can see these values can be calculated by iterating over the rows of the The rows of The row of zeros at the bottom of the matrix is skipped in the calculation (as it doesn't change anything), it is only kept around to make the matrix square. The first column of zeros is a statement that the observed image stays unchanged by lensing, it is kept around to make the iteration loop easier to write. |
Thank you very much @CKrawczyk for the clarification and equation 👌 As soon as I have some time I'll make sure to merge this PR and then work on the integration with the other existing single-plane classes. |
A draft PR with the start of the MP-lensing code. I still need to add some doc-strings and check that each class works as expected.