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

Skeleton for cluster lens simulations #148

Merged
merged 49 commits into from
May 15, 2024

Conversation

furcelay
Copy link
Collaborator

@furcelay furcelay commented Apr 1, 2024

This is the first pull following #134 and provides a skeleton of the classes described in that issue. The classes are empty except for ClusterLens(LensBase) which is partially implemented.

ClusterLens takes the parameters that describe a halo (by the time only EPL) and a table with the parameters of each subhalo and generates the Lenstronomy keywords to simulate the lens. This is exemplified in a new notebook cluster_lens.ipynb.

furcelay and others added 13 commits January 19, 2024 15:45
This reverts commit 8be0219.

I've modified setup.py and the requirements for easyer installation
on a non-LSST environment (local), but now I revert this as is not
related with the purpose of this fork.
This reverts commit e1bffbd.

I've modified setup.py and the requirements for easyer installation
on a non-LSST environment (local), but now I revert this as is not
related with the purpose of this fork.
…dir/site-packages/data as wanted by LensPop)"

This reverts commit 887a653.

Revert requirements
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.65%. Comparing base (4a9e9fd) to head (537690b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
+ Coverage   95.51%   95.65%   +0.13%     
==========================================
  Files          38       39       +1     
  Lines        1896     1955      +59     
==========================================
+ Hits         1811     1870      +59     
  Misses         85       85              
Files Coverage Δ
slsim/Deflectors/DeflectorTypes/nfw_cluster.py 100.00% <100.00%> (ø)
slsim/Deflectors/velocity_dispersion.py 100.00% <100.00%> (ø)

@furcelay furcelay requested a review from nkhadka21 April 10, 2024 16:10
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.

Hi @furcelay , thank you very much for your PR. I have some major comments. GalaxyClusterLenses and ClusterLensPop are mostly duplicates of Lens and LensPop classes. I think you should start from the small steps. I encourage you to start from generating cluster deflector and sources for cluster lenses. and then, you can think about ClusterLens and ClusterLensPop (might be able to use existing classes with addition of some extra parameters). Please let me know if you have any questions!

@@ -0,0 +1,3 @@
class ClusterPipeline:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We do not need this class. It would be great if you could delete this class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this class as it is not needed yet.

import warnings


class ClusterLens(LensedSystemBase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class has a lot of overlap with existing Lens() class. I think we can think about using existing Lens class or creating a Clusterlens() class only with functions which are not in Lens class. You can do this later (save this somewhere else and once you start working on this class, you can bring it back.). For now focus on creating a class to generate or manage cluster deflectors. Simon has implemented class to manage NFW and Hernquist mass model. Please look at them and see if they are useful for you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed the ClusterLens class and implemented NFWCluster which is a new Deflector subclass to manage clusters. It can work with the existing Lens class by modifying the deflector_mass_model_lenstronomy. Another way might be to handle the mass model in the Deflector class and just call it from the Lens class (see #156).

from slsim.lensed_population_base import LensedPopulationBase


class ClusterLensPop(LensedPopulationBase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class is exactly the same as LensPop() class. So, you can delete it and use LensPop() class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this class

from slsim.Pipelines.cluster_pipeline import ClusterPipeline


class TestClusterPipeline(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We do not need ClusterPipeline class. So, remove it.

Copy link
Collaborator Author

@furcelay furcelay May 13, 2024

Choose a reason for hiding this comment

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

Removed



class TestClusterLens(object):
# pytest.fixture(scope='class')
Copy link
Collaborator

Choose a reason for hiding this comment

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

As ClusterLens class is a duplication of Lens class, these testing are also duplication of existing test functions. The best way is to start from the basic steps. I encourage you to start from cluster deflector class which will manage cluster deflector population.

Copy link
Collaborator Author

@furcelay furcelay May 13, 2024

Choose a reason for hiding this comment

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

Removed



@pytest.fixture
def gg_lens_pop_instance():
Copy link
Collaborator

Choose a reason for hiding this comment

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

You do not need these test functions if you remove ClusterLensPop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

@furcelay
Copy link
Collaborator Author

I've removed the redundant or unneeded classes and implemented a new Deflector to handle clusters. This deflector is a NFW halo without a luminous component and subhalos that can be any other deflector (EPL+Sérsic or NFW+Hernquist). I've also implemented a new function to compute its line-of-sight velocity dispersion of the halo following Lokas & Mamon 2001 as it cannot be weighted by the light as in the NFW + Hernquist model.

@furcelay furcelay requested a review from nkhadka21 May 14, 2024 02:13
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.

Hi @furcelay looks very good and I am glad you could use most of the other classes for your cluster class. I have just a minor inquiry about the velocity dispersion. You calculate them for the NFW halo alone, just want to make sure that this is what you want


m_halo, c_halo = self.halo_properties
rs_arcsec, _ = lens_cosmo.nfw_physical2angle(m_halo, c_halo)
vel_disp = vel_disp_nfw_aperture(
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the dispersion in the dark matter particles, or some light tracer particles? For a NFW+Hernquist model, we have a velocity dispersion routine (currently averaged to the half-light radius) in this routine:

def vel_disp_composite_model(r, m_star, rs_star, m_halo, c_halo, cosmo, z_lens):
(heavily using the lenstronomy.Galkin routines for solving the Jeans equation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @sibirrer, indeed the velocity dispersion is the one of the dark matter particles without any light tracer. This is because the velocity dispersion of the dark matter halo of groups or clusters cannot be measured in the same way as galaxies. It is usually measured by the spread in the redshift of the subhalos within a radius and assuming the radial profile for the velocity dispersion from Łokas & Mamon 2001. So it should be consistent with the measured velocity dispersion with some considerations on the aperture radius.

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 @furcelay! I leave it to @nkhadka21 for the final review and merge.

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.

Hi @furcelay , thank you very miuch for this update! Looks very good. I have a minor comment. Please address it.

- 'z': redshift of deflector
"""

def __init__(self, deflector_dict, subhalos_list):
Copy link
Collaborator

@nkhadka21 nkhadka21 May 14, 2024

Choose a reason for hiding this comment

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

Please add doc string for deflector_dict and subhalos_list. Clarify what subhalos_list should contain. Might be useful to explain how halo_EPl.fits and subhaloes_table.fits that you have added in TestData can be used in this class or you need to add full list of halos or subhalos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @nkhadka21, I've added the docstring for that method. Also included the fits files in test_nfw_cluster to exemplify their use, both have an astropy table with the quantities to init the halo and subhalos respectively.

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 the update! I approved it and excited to see your progress on other aspects of the cluster lens code!

@nkhadka21 nkhadka21 merged commit 9fb1f8f into LSST-strong-lensing:main May 15, 2024
5 checks passed
@furcelay
Copy link
Collaborator Author

Thank you! I hope to have more progress soon.

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