Skip to content
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

Deflector mass method #171

Merged
merged 13 commits into from
May 23, 2024

Conversation

furcelay
Copy link
Collaborator

This pull request adds a new method mass_model_lenstronomy to the DeflectorBase, EPLSersic, NFWHernquist, NFWCluster, and Deflector classes. This method takes a Lenstronomy LensCosmo instance and returns the mass profile parameters for the deflector in Lenstronomy conventions.

Although this method depends on a source redshift through the LensCosmo instance, it is not tied to a specific source. The results are not stored within the deflector, ensuring that it adheres to the class definition: "Class of a single deflector with quantities only related to the deflector (independent of the source)."

The primary advantage of this addition is the simplification and generalization of the deflector_mass_model_lenstronomy method in the Lens class. This change removes the need for specific handling of each deflector type, especially the NFWCluster, which would otherwise require constructing models for the halo and each subhalo within the function (issue #156). By incorporating this new method, these operations are now managed within the NFWCluster and its subhalos, streamlining the process of implementing #134 and other new deflectors.

Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 97.72727% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.62%. Comparing base (0fabab2) to head (c606b82).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
- Coverage   95.66%   95.62%   -0.05%     
==========================================
  Files          39       39              
  Lines        1985     2010      +25     
==========================================
+ Hits         1899     1922      +23     
- Misses         86       88       +2     
Files Coverage Δ
slsim/Deflectors/DeflectorTypes/epl_sersic.py 100.00% <100.00%> (ø)
slsim/Deflectors/DeflectorTypes/nfw_cluster.py 100.00% <100.00%> (ø)
slsim/Deflectors/DeflectorTypes/nfw_hernquist.py 97.05% <100.00%> (+1.22%) ⬆️
slsim/Deflectors/deflector.py 95.00% <100.00%> (-5.00%) ⬇️
slsim/lens.py 95.95% <100.00%> (+0.11%) ⬆️
slsim/Deflectors/DeflectorTypes/deflector_base.py 91.11% <66.66%> (-1.75%) ⬇️

@furcelay furcelay requested a review from sibirrer May 22, 2024 19:30
Copy link
Contributor

@sibirrer sibirrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @furcelay! I like this change. It though requires the consistent treatment of the source redshift but I think this is a better way of doing it in the respective classes.
For multiple source redshift, the lenstronomy LensModel() class has a z_source_convention argument and this is the one for which the single-plane equivalent source redshifts are defined in the mass models (so that's what you then need to do, i.e. LensCosmo(z_source=z_source_convention). And then you can have multiple sources with different redshifts appended to it

"""Returns lens model instance and parameters in lenstronomy conventions.

:param lens_cosmo: lens cosmology model
:type lens_cosmo: LensCosmo class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write this as ~lenstronomy.Cosmo.LensCosmo instance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected in the last commit

@sibirrer sibirrer requested a review from nkhadka21 May 23, 2024 01:36
@furcelay
Copy link
Collaborator Author

Thank you @sibirrer! I'll make sure to handle consistent treatment of the source redshift using z_source_convention in LensCosmo for multiple source cases.

Copy link
Collaborator

@nkhadka21 nkhadka21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@furcelay , thank you very much for This PR! I like these changes. I approve this PR. Looking forward to seeing your progress in multiple source with different redshift case.

@nkhadka21 nkhadka21 merged commit b624c90 into LSST-strong-lensing:main May 23, 2024
4 of 5 checks passed
@furcelay furcelay deleted the deflector_mass_method branch May 24, 2024 16:35
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.

3 participants