Skip to content

Line-of-Sight Structure-Enhanced Ray-Tracing Halos Rendering for External Convergence and Shear - #64

Merged
nkhadka21 merged 179 commits into
LSST-strong-lensing:mainfrom
trivialTZ:main
Jun 10, 2024
Merged

nkhadka21 merged 179 commits into
LSST-strong-lensing:mainfrom
trivialTZ:main

Conversation

@trivialTZ

Copy link
Copy Markdown
Collaborator

Line-of-Sight Structure-Enhanced Ray-Tracing Halos Rendering for External Convergence and Shear

Description:

This pull request introduces an enhancement to the ray-tracing halos rendering mechanism. It incorporates both large-scale structures using GLASS and small-scale structures via the halo mass function.

Key Features:
  1. Line-of-Sight Structure Rendering: This implementation utilizes the SkyPy halo module for the line-of-sight structure. It's worth noting that the currently used SkyPy halo module has not been merged into the main SkyPy branch, hence we're temporarily making use of Skypy_halos_duplicate.
  2. Ray-Tracing Computations: For a given sky area, this feature generates halos within the corresponding light cone. It then employs ray-tracing techniques to compute the distribution of convergence ( $\kappa_{ext}$ ) and shear ( $\gamma_{tot}$ ).
  3. Negative Mass Sheet Option: Users have the flexibility to generate a negative mass sheet which can be used for kappa correction.
  4. Demonstrative Notebook: A notebook has been added to provide a hands-on demonstration of this feature.

Next Steps:

  1. Testing and Documentation:

    • Test Functions: Enhance and finalize the test functions to ensure the feature's robustness.
    • Notebook: Refine the notebook to provide clearer demonstrations and examples.
    • Documentation: Improve the documentation to ensure comprehensive understanding and ease of use for the users.
  2. Incorporate $\kappa_{ext}$ Correction:

    • We aim to introduce a correction factor for $\kappa_{ext}$:

$$ 1 - \kappa_{ext} = \frac{(1-\kappa_d)(1-\kappa_s)}{1-\kappa_{ds}} $$

This will ensure a more accurate representation and calculation in our rendering mechanism.

Acknowledgements:

We kindly request a review of this feature, and are open to further feedback and suggestions.

trivialTZ and others added 30 commits July 19, 2023 02:33
Some bugs still need to be fixed
with documentation, jupyter sample, test function.
Create a utility function that handles default parameter and then modify the other functions to use this new utility function.
1. update Jupyter notebook with the computing gamma and kappa
2. change yml file to make it run quicker for debug(will change back)
3. add halos_len.py with Class HalosLens() in it and def concentration_from_mass() in it.
1. **halos_lens.py**:
   - Introduced `get_kappa_gamma_distib()` for computing the kappa and gamma_tot values from the list.
   - Implemented running time tracking for performance analysis.

2. **halos.py**:
   - Added running time metrics for enhanced performance tracking.

3. **Notebook Renaming**:
   - Renamed `get_halos.ipynb` to `halos_rendering.ipynb`.

4. **halos_rendering.ipynb Enhancements**:
   - Added `kappa_gamma_distribution` for visualizing the joint distribution of kappa-gamma_tot.
   - Introduced visualizations to showcase the distributions of the modified kappa and gamma values from halos using histograms.
   - Incorporated KDE functionality for generating random samples of `kappa_halos` and `gamma_halos`.

5. **Data Files**:
   - Added `kgdata.npy`: Weak-lensing maps sourced from GLASS with n=128 (z=5). (better try other way to upload)
   - Introduced `z5data.npy`: Weak-lensing maps from GLASS with n=2048 (z=5).

6. **halos_plus_glass.py**:
   - This script fuses several functions to produce the joint distribution of kappa and gamma values leveraging both halo and GLASS data.
     a. **Glass Data & Sample Generation**: Utilized `read_glass_data` to extract kappa and gamma values from the Glass data file. Implemented `skyarea_form_n` to deduce the corresponding sky area for each pixel. Employed `generate_samples_from_glass` to fit a Gaussian KDE to the joint distribution and generate a random sample.
     b. **Halo Data & Sample Generation**: Applied a Gaussian KDE to derive the joint distribution and presented a hexbin plot visualization.
     c. **Combining Halo and Glass Data**: Invoked `generate_halos_multiple_times` to repeatedly generate kappa and gamma values from halos. Subsequently, merged the halo and Glass data samples with the `halos_plus_glass` function.

7. **glass_convergencen_shear.ipynb**:
   - A dedicated notebook to import data from GLASS and facilitate its visualization.

8. **glass_plus_halos_rendering.ipynb**:
   - This notebook illustrates the process of deriving kappa and gamma values from both halo and GLASS sources. It also demonstrates the method to visualize the combined kappa and gamma values' joint distribution.
----------------------------------------------------------------------
If there are no issues with these codes and the underlying physics, I will generate weak lensing maps for add different values of z and add test function next.
1. debug: including debug about the position sample (of disk); halos mass's resolution and others.
2. improve: add/improve some methods and improve the docstring.
3. The results should be more realistic now.
1.make a duplicate of Skypy halos branch and make a read.me for credits statement
2. Optimize the project. (mulitprocess & numpy vector operator)
(still some room for improve)
For passing the test
1. add test function for Halos
2. rename file name halos ---> Halos
3. move the jupyter notebooks to the notebook folder
4. debug of halos_plus_glass.py ()
5. give proper attribution for the code copy from Skypy (as once it is in the main branch or release version of SkyPy, that this code becomes deprecated)

@sibirrer
1. add def run_halos_without_kde_by_multiprocessing() as it can help improve halos rendering when n_iterations is large.
2. debug
1.Add test for new method
2.delete unnecessary duplicate from Skypy
3.move pipeline test file
4.minor change on the markdown of a jupyter notebook
Test function and documentation are on the way.
still need further look of what went wrong.
1.deg2_to_cone_angle debug
2.add a test function
1.add test for cone_radius_angle_to_physical_area()
2. will update documentation and complete test functions in the furture.
1, Make the negative mass in the mass sheet correction uniformly distributed within the light cone according to the halo mass function, rather than keeping it at the same redshift as the generated halos.

2,Address the issue in the code when the number of generated halos is too small, causing N to be equal to zero.
@trivialTZ

Copy link
Copy Markdown
Collaborator Author

@sibirrer good for code review

Comment thread notebooks/external_convergence_shear_distributions_tutorial.ipynb
Comment thread notebooks/external_convergence_shear_distributions_tutorial.ipynb
Comment thread notebooks/external_convergence_shear_distributions_tutorial.ipynb
Comment thread notebooks/external_convergence_shear_distributions_tutorial.ipynb
Comment thread notebooks/galaxy_galaxy_lensing_tutorial.ipynb
Comment thread notebooks/line_of_sight_tutorial.ipynb Outdated
@trivialTZ

Copy link
Copy Markdown
Collaborator Author

@sibirrer the notebook is updated, good for further reviews.

@@ -2,8 +2,13 @@
"cells": [

@sibirrer sibirrer May 28, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you try not to submit this notebook as it adds to disk space


Reply via ReviewNB

@sibirrer sibirrer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great @trivialTZ! I have one request to remove one notebook from the PR and then we can merge it

@sibirrer
sibirrer requested a review from nkhadka21 June 6, 2024 14:03
@sibirrer

sibirrer commented Jun 6, 2024

Copy link
Copy Markdown
Contributor

@nkhadka21 from my side, TZ's PR is ready to be merged (modulo the minor conflict that will be resolved). Can you look through the files and see whether there are any issues or requests? Thank you!

@trivialTZ

Copy link
Copy Markdown
Collaborator Author

@nkhadka21 this pull request is good for reviewing, thanks!

@nkhadka21 nkhadka21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @trivialTZ , thank you very much for this wonderful work! Code is very well documented. I have a very minor comment that you can address. It looks good to me and I approve this PR.


path = os.path.dirname(slsim.__file__)
module_path, _ = os.path.split(path)
if skypy_config is None:

@nkhadka21 nkhadka21 Jun 10, 2024 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You have given default sky area below but It would be good to mention the default sky area here.

@nkhadka21
nkhadka21 merged commit 68adf90 into LSST-strong-lensing:main Jun 10, 2024
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.

4 participants