Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
dd3fd10
built a folder examples/triaxiality, added a readme file inside
shenmingfu Jul 18, 2023
656b37b
added mock catalog info into readme file
shenmingfu Jul 18, 2023
740bae1
added mock catalogs, added a notebook for visualization
shenmingfu Jul 18, 2023
5d279b6
test notebook plotting delta sigma vs radius
akumgill Jul 19, 2023
0a70528
Model predictions for Quadrupole lensing
rkrishnan2912 Jul 19, 2023
b38d2c6
updating notebook with gamma sign and cos term sign
akumgill Jul 19, 2023
f1d118f
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
akumgill Jul 19, 2023
2b31613
code cleanup / removing dupe loops
akumgill Jul 19, 2023
a8c2e32
put functions for data analysis into script file
rancesol Jul 20, 2023
167f3c3
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 20, 2023
7e5999d
Comparison of two implementations
rkrishnan2912 Jul 21, 2023
ae56e5f
adding fitting files
rancesol Jul 22, 2023
5461145
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 22, 2023
0a020c5
update fitting notebook
rancesol Jul 22, 2023
e742f2a
fixed emcee fitting error due to inconcistent parameter values
rancesol Jul 29, 2023
e517e13
cleaning up repeated data files
rancesol Jul 29, 2023
0ee57e9
update fitting nnotebook to account for corrected monopole term
rancesol Aug 16, 2023
f2da93b
MCMC fitting for elliptical lens model
rkrishnan2912 Aug 25, 2023
5fdf268
Fixed the fitting modules
rkrishnan2912 Jul 15, 2024
54f0299
Added triaxiality theory functions in func_layer.py
Jul 16, 2024
6647498
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
Jul 16, 2024
da083fc
some changes to initialize triaxiality functions
Jul 16, 2024
3b0b7c3
Merge branch 'main' into issue/591/triaxiality
Jul 16, 2024
7fc4d2d
added triaxial functions to class modules
rancesol Jul 16, 2024
8e7865f
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 16, 2024
c8f1d61
added quadrupole calculation plus major axis calculation
tae-h-shin Jul 16, 2024
04951c8
fixed conflicts
tae-h-shin Jul 16, 2024
a453bf7
documentation updated
Jul 16, 2024
a40ff56
add triaxial functions
rancesol Jul 16, 2024
c47ea78
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 16, 2024
9134c90
typo correction
rancesol Jul 17, 2024
3dd3d64
Minor comments and cosmetic changres
Jul 17, 2024
2f39979
Data operation-functions for triaxiality added to dataops
Jul 17, 2024
46067b8
edited galaxycluster.py to incorporate quadrupole lensing
tae-h-shin Jul 17, 2024
8cef454
edited galaxycluster.py to incorporate quadrupole lensing
tae-h-shin Jul 17, 2024
2223c3b
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 17, 2024
8525ba7
changed dataops/__init__.py for quadrupole
tae-h-shin Jul 17, 2024
40358a7
changed galaxycluser.py for quadrupole
tae-h-shin Jul 17, 2024
ad70d4e
Edited a minor typo in code in dataops/__init__.py
Jul 18, 2024
9ba290a
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
Jul 18, 2024
28b7016
argument and backend validation
rancesol Jul 18, 2024
2a196f7
Edited a small typo in dataops/__init__.py
Jul 18, 2024
3e90071
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 18, 2024
92586b3
initial edit to clusterensemble.py for quadrupole
tae-h-shin Jul 18, 2024
e4130d3
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 18, 2024
ce51076
finished adding quadrupole operations to clusterensemble.py
tae-h-shin Jul 18, 2024
243bf0f
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 18, 2024
a0e060a
cleaned up triaxiality functions
rancesol Jul 18, 2024
3b12ff1
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 18, 2024
b722e79
Minor addition to doc string in func_layer.py
Jul 18, 2024
50ce90b
Reformatting func_layer.py
Jul 18, 2024
e6cbf2f
delted three redundant functions from dataopts
tae-h-shin Jul 18, 2024
af3d466
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 18, 2024
8088606
fixed formating
rancesol Jul 18, 2024
6d18127
add triaxial tests
rancesol Jul 18, 2024
87d7547
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 18, 2024
1d4f39f
cosmetic changes to make pylint happy and added one test
tae-h-shin Jul 18, 2024
175e7e6
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 18, 2024
17806f6
fix 'test_triaxial' arguments
rancesol Jul 18, 2024
8a90ad3
correct arments for simpson integration function
rancesol Jul 18, 2024
0e97a3b
Pylint corrections to func_layer.py and __init__.py
Jul 18, 2024
b63aa75
triaxial test added for object-oriented and functional form comparison
rancesol Jul 18, 2024
b619780
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 18, 2024
7090659
pylint is finally happy
tae-h-shin Jul 18, 2024
c23cd98
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
tae-h-shin Jul 18, 2024
51fd52c
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 19, 2024
ea8cdd5
Updates to the interpolation and sampling in func_layer.py theory fun…
Jul 19, 2024
f0eea39
Merge branch 'issue/591/triaxiality' of https://github.com/LSSTDESC/C…
rancesol Jul 19, 2024
2d5aa5b
issue/627/testskypixelcoords: New notebook to test coordinate system …
ts485 Jul 19, 2024
3082315
minor edits to triaxial functs to bring into agreement with naming sc…
rancesol Jul 23, 2024
425a3e8
edits to triaxial functs to bring into agreement with func_layer.py
rancesol Jul 23, 2024
5d0f007
added tests for triaxial functions
rancesol Jul 23, 2024
b346a88
ran black on files
rancesol Jul 23, 2024
c4f4290
removed unused function
rancesol Jul 23, 2024
23bd956
remove obsolete function from test
rancesol Jul 23, 2024
424ced9
finished test_dataops.py
tae-h-shin Jul 24, 2024
530496f
finished test_galaxycluster.py
tae-h-shin Jul 26, 2024
4d873f8
finished test_clusterensemble.py
tae-h-shin Jul 26, 2024
704faae
add triaxial functions from func_layer
rancesol Jul 29, 2024
a638d6d
Merge branch 'main' into issue/591/triaxiality
rancesol Jul 30, 2024
8cfea7c
raise value error if term is incorrect for triaxial calculations
rancesol Jul 30, 2024
f0212ec
minor edit
rancesol Jul 30, 2024
30e824d
fixed local variables in triaxial calculations
rancesol Jul 30, 2024
c11e6fe
fixed number of local variables in triaxial calculations
rancesol Jul 30, 2024
e55877f
pylint ignore number of instances (8/7)
rancesol Jul 30, 2024
94b751e
minor formating edit
rancesol Jul 30, 2024
d0f45dc
corrected description on include_quadrupole parameter
rancesol Jan 16, 2025
1ca899e
mirrored triaxial functions in func_layer with their counterparts in …
rancesol Jan 17, 2025
0507b58
updated triaxial function imports in __init__
rancesol Jan 17, 2025
6c1aefa
updated names of triaxial functions
rancesol Jan 20, 2025
5592770
NB showing issue in quad measurement
combet Jan 24, 2025
67c4ae4
fixed the coordinate system issue (see the slack message)
tae-h-shin Feb 5, 2025
70b4fcb
Notebook showcasing CLMM func_layer implementation
rkrishnan2912 Feb 10, 2025
9986270
Edited Outputs
rkrishnan2912 Feb 10, 2025
7e43688
fix merge conflicts
m-aguena Feb 17, 2025
71762d2
Horizontally-rescaled mock catalogs
rkrishnan2912 Mar 25, 2025
03306f7
Update test_theory.py
rkrishnan2912 Apr 9, 2025
db061fe
CLMM triaxiality example notebook
rkrishnan2912 Apr 10, 2025
a54d483
Update __init__.py
rkrishnan2912 Apr 18, 2025
c8b0e7b
Update test_dataops.py
rkrishnan2912 Apr 23, 2025
6716d8c
Update test_galaxycluster.py
rkrishnan2912 Apr 23, 2025
74a09cb
Update test_galaxycluster.py
rkrishnan2912 Apr 23, 2025
b9ff8a0
Update conftest.py
rkrishnan2912 Apr 30, 2025
4aeb8af
Update conftest.py
rkrishnan2912 Apr 30, 2025
8b535bb
Update test_galaxycluster.py
tae-h-shin May 7, 2025
3758bdd
Update __init__.py
tae-h-shin May 7, 2025
d976247
Update test_dataops.py
tae-h-shin May 7, 2025
dffb095
Update func_layer.py
rkrishnan2912 May 9, 2025
e56c30d
Update func_layer.py
rkrishnan2912 May 9, 2025
8849360
Update __init__.py
rkrishnan2912 May 9, 2025
25a7aa7
Update __init__.py
rkrishnan2912 May 9, 2025
358bb1d
Update func_layer.py
rkrishnan2912 May 9, 2025
61c046f
Update __init__.py
rkrishnan2912 May 9, 2025
e40cbb0
Update __init__.py
rkrishnan2912 May 10, 2025
29c9562
Update galaxycluster.py
rkrishnan2912 May 10, 2025
1078dea
Update galaxycluster.py
rkrishnan2912 May 11, 2025
35e9f27
Update galaxycluster.py
rkrishnan2912 May 11, 2025
9577362
Update galaxycluster.py
rkrishnan2912 May 12, 2025
f27ca2f
Merge branch 'main' of https://github.com/LSSTDESC/CLMM into issue/59…
May 15, 2025
99462dc
simplify quadrupole use in ClusterEnsemble.make_stacked_radial_profile
m-aguena May 16, 2025
5b1a4f6
simplify quadrupole use in ClusterEnsemble.make_stacked_radial_profile
m-aguena May 16, 2025
f0e3e9c
simplify quadrupole use in ClusterEnsemble.compute_sample_covariance
m-aguena May 16, 2025
06c85a3
add ValueError tests for triaxial functions
rancesol May 16, 2025
17ca768
Add ValueError test when neight phi_major or member distributions are…
rancesol May 16, 2025
974d848
fixed typo in ValueError test for quadrupole function
rancesol May 16, 2025
2e9c6b4
corrected aguments for compute_tangential_and_cross_compenents ValueE…
rancesol May 16, 2025
ebd0691
Update test_dataops.py
rkrishnan2912 May 17, 2025
b2a3e79
Update __init__.py
rkrishnan2912 May 17, 2025
f7a3108
Delete examples/triaxiality/data_functions.py
rkrishnan2912 Jul 3, 2025
7ab4d29
file no longer needed
rancesol Jul 3, 2025
16b95b0
Delete examples/triaxiality/readme
rkrishnan2912 Jul 3, 2025
ffd6679
Delete examples/triaxiality/model_functions.py
rkrishnan2912 Jul 3, 2025
d8d0467
Delete examples/triaxiality/fitting_elliptical_halo.ipynb
rkrishnan2912 Jul 3, 2025
bbe28d7
Delete examples/triaxiality/delta_sigma_test.ipynb
rkrishnan2912 Jul 3, 2025
ec1a035
Delete examples/triaxiality/catalogs.zip
rkrishnan2912 Jul 3, 2025
d777404
Delete examples/triaxiality/Elliptical_lenses_model.ipynb
rkrishnan2912 Jul 3, 2025
55d8037
Delete examples/triaxiality/Elliptical_lenses_MCMC.ipynb
rkrishnan2912 Jul 3, 2025
1a13334
Delete examples/triaxiality/DESY1_Elliptical_lenses_MCMC.ipynb
rkrishnan2912 Jul 3, 2025
8c28819
imported compute_excess_surface_density_triaxial from theory layer in…
rancesol Jul 3, 2025
3ecaf0e
moved triaxiality computations for mono, quad_4theta, and quad_const …
rancesol Jul 3, 2025
412b5d7
Added more description on the 'term' option
rancesol Jul 3, 2025
02554d9
Update clusterensemble.py (g4theta, e4theta, gconst, econst ==> g_qu…
tae-h-shin Jul 10, 2025
d146282
Update galaxycluster.py (e4theta, econst, g4theta, gconst ==> e_quad_…
tae-h-shin Jul 10, 2025
3979d1d
Update test_clusterensemble.py (changed e.g. g4theta ==> g_quad_4thet…
tae-h-shin Jul 10, 2025
f4bbfc5
Update test_galaxycluster.py (changed e.g. e4theta ==> e_quad_4theta …
tae-h-shin Jul 10, 2025
d4ed9f0
Update test_clusterensemble.py (chagned gconst ==> g_quad_const)
tae-h-shin Jul 10, 2025
a903443
cleaned with black and made _calculate_major_axis a public funciton
rancesol Jul 25, 2025
ce43094
unused parameter estimates were removed
rancesol Jul 25, 2025
4067116
adjust length of docstring
rancesol Jul 25, 2025
4934dfe
adjusted clmm/theory/func_layer.py for indentation
shenmingfu Sep 23, 2025
336fecc
simplify clmm/clusterensemble.py
m-aguena Oct 3, 2025
efd538f
Update clusterensemble.py
rkrishnan2912 Oct 17, 2025
01d3c45
fix merge conflicts
m-aguena Oct 30, 2025
db50999
fix imports
m-aguena Oct 30, 2025
308abcb
Update clusterensemble.py
rkrishnan2912 Nov 27, 2025
e263857
Update clusterensemble.py
rkrishnan2912 Nov 27, 2025
8736341
Update __init__.py
rkrishnan2912 Nov 27, 2025
9f57043
Update parent_class.py
rkrishnan2912 Nov 27, 2025
c0bd244
Update __init__.py
rkrishnan2912 Nov 27, 2025
ff33918
Update galaxycluster.py
rkrishnan2912 Nov 27, 2025
af53deb
Update clusterensemble.py
rkrishnan2912 Nov 27, 2025
46b4c75
Update clusterensemble.py
rkrishnan2912 Nov 27, 2025
25b64e6
Update __init__.py
rkrishnan2912 Nov 27, 2025
cdd689f
Update __init__.py
rkrishnan2912 Nov 28, 2025
7c81123
Merge branch 'main' into issue/591/triaxiality
m-aguena Dec 3, 2025
2fac124
Merge branch 'main' into issue/591/triaxiality
m-aguena Dec 3, 2025
3c1478b
fix merge conflicts
m-aguena Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
compute_convergence,
compute_excess_surface_density,
compute_excess_surface_density_2h,
compute_excess_surface_density_triaxial,
compute_magnification,
compute_magnification_bias,
compute_magnification_bias_from_magnification,
Expand Down
199 changes: 172 additions & 27 deletions clmm/clusterensemble.py

Large diffs are not rendered by default.

132 changes: 126 additions & 6 deletions clmm/dataops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
_integ_pzfuncs,
_validate_coordinate_system,
_validate_dec,
_validate_include_quadrupole_phi_major,
_validate_is_deltasigma_sigma_c,
_validate_ra,
arguments_consistency,
Expand All @@ -32,6 +33,9 @@ def compute_tangential_and_cross_components(
geometry="curve",
is_deltasigma=False,
sigma_c=None,
include_quadrupole=False,
phi_major=None,
info_mem=None,
validate_input=True,
):
r"""Computes tangential- and cross- components for shear or ellipticity
Expand Down Expand Up @@ -71,6 +75,14 @@ def compute_tangential_and_cross_components(
g_t =& -\left( g_1\cos\left(2\phi\right)+g_2\sin\left(2\phi\right)\right)\\
g_x =& g_1 \sin\left(2\phi\right)-g_2\cos\left(2\phi\right)

The quadrupole ellipticity/shear components, :math:`g_4theta` and :math:`g_const`,
are also calculated using the two ellipticity/shear components :math:`g_1` and :math:`g_2`
of the source galaxies, following Eq.31 and Eq.34 in Shin et al. (2018), arXiv:1705.11167.

.. math::
Copy link
Member

Choose a reason for hiding this comment

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

Check it this is compiled correctly in the documentation

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, this looks good!

g_4theta =& \left( g_1\cos\left(4\phi\right)+g_2\sin\left(4\phi\right)\right)\\
g_const =& g_1

Finally, if the critical surface density (:math:`\Sigma_\text{crit}`) is provided, an estimate
of the excess surface density :math:`\widehat{\Delta\Sigma}` is obtained from

Expand All @@ -96,9 +108,9 @@ def compute_tangential_and_cross_components(
shear2: array
The measured shear (or reduced shear or ellipticity) of the source galaxies
coordinate_system: str, optional
Coordinate system of the ellipticity components. Must be either 'celestial' or
euclidean'. See https://doi.org/10.48550/arXiv.1407.7676 section 5.1 for more details.
If not set, defaults to 'euclidean'.
Coordinate system of the ellipticity components. Must be either `celestial` or
`euclidean`. See https://doi.org/10.48550/arXiv.1407.7676 section 5.1 for more details.
Default is `euclidean`.
geometry: str, optional
Sky geometry to compute angular separation.
Options are curve (uses astropy) or flat.
Expand All @@ -108,6 +120,21 @@ def compute_tangential_and_cross_components(
sigma_c : None, array_like
Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`.
Used only when is_deltasigma=True.
include_quadrupole: bool
If `True`, the quadrupole shear components (g_4theta, g_const; Shin+2018) are calculated
phi_major : float, optional
the direction of the major axis of the input cluster in the unit of radian.
only needed when `include_quadrupole` is `True`.
This quantity is always in Euclidean coordinates, for celestial coordinates only set
the coordinate_system=`celestial`.
Users could choose to provide ra_mem, dec_mem and weight_mem instead of this quantity.
info_mem : list of array, optional
RAs, DECs and weights of the member galaxies of the input cluster,
to calcualte the direction of the major axis of the cluster.
Only needed when `include_quadrupole` is `True` and `phi_major` is not provided.
The shape must be in `[ra_mem,dec_mem,weight_mem]`, where each element is an array.
The weights could be `1` (no weights) or
`membership probability (p_mem)` or any user choice.
validate_input: bool
Validade each input argument

Expand All @@ -119,8 +146,13 @@ def compute_tangential_and_cross_components(
Tangential shear (or assimilated quantity) for each source galaxy
cross_component: array_like
Cross shear (or assimilated quantity) for each source galaxy
IF include_quadrupole:
4theta_component: array_like
4theta shear component (or assimilated quantity) for each source galaxy
const_component: array_like
constant shear component (or assimilated quantity) for each source galaxy
"""
# pylint: disable-msg=too-many-locals
# pylint: disable-msg=too-many-locals,too-many-branches
# Note: we make these quantities to be np.array so that a name is not passed from astropy
# columns
if coordinate_system is None:
Expand All @@ -135,6 +167,8 @@ def compute_tangential_and_cross_components(
validate_argument(locals(), "shear1", "float_array")
validate_argument(locals(), "shear2", "float_array")
validate_argument(locals(), "geometry", str)
validate_argument(locals(), "is_deltasigma", bool)
validate_argument(locals(), "include_quadrupole", bool)
validate_argument(locals(), "sigma_c", "float_array", none_ok=True)
_validate_coordinate_system(locals(), "coordinate_system")
ra_source_, dec_source_, shear1_, shear2_ = arguments_consistency(
Expand All @@ -143,6 +177,9 @@ def compute_tangential_and_cross_components(
prefix="Tangential- and Cross- shape components sources",
)
_validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c)
_validate_include_quadrupole_phi_major(include_quadrupole, phi_major, info_mem)
validate_argument(locals(), "phi_major", float, none_ok=True)
validate_argument(locals(), "info_mem", list, none_ok=True)
elif np.iterable(ra_source):
ra_source_, dec_source_, shear1_, shear2_ = (
np.array(col) for col in [ra_source, dec_source, shear1, shear2]
Expand All @@ -168,12 +205,31 @@ def compute_tangential_and_cross_components(
# Compute the tangential and cross shears
tangential_comp = _compute_tangential_shear(shear1_, shear2_, phi)
cross_comp = _compute_cross_shear(shear1_, shear2_, phi)

# If the is_deltasigma flag is True, multiply the results by Sigma_crit.
if sigma_c is not None:
_sigma_c_arr = np.array(sigma_c)
tangential_comp *= _sigma_c_arr
cross_comp *= _sigma_c_arr

if include_quadrupole:
if (phi_major is None) and (info_mem is None):
raise ValueError("Either phi_major or (ra_mem, dec_mem, weight_mem) should be provided")
if phi_major is None:
# info_mem=[ra_mem,dec_mem,weight_mem]
phi_major = calculate_major_axis(
ra_lens, dec_lens, info_mem[0], info_mem[1], info_mem[2]
)
if coordinate_system == "celestial":
phi_major = np.pi - phi_major
rotated_shear1, rotated_shear2 = _rotate_shear(shear1_, shear2_, phi_major)
# Compute the quadrupole shear components
four_theta_comp = _compute_4theta_shear(rotated_shear1, rotated_shear2, phi - phi_major)
const_comp = rotated_shear1
# If the is_deltasigma flag is True, multiply the results by Sigma_crit.
if sigma_c is not None:
four_theta_comp *= _sigma_c_arr
const_comp *= _sigma_c_arr
return angsep, tangential_comp, cross_comp, four_theta_comp, const_comp
return angsep, tangential_comp, cross_comp


Expand Down Expand Up @@ -446,6 +502,51 @@ def _compute_lensing_angles_astropy(
return angsep, phi


def calculate_major_axis(ra_lens_, dec_lens_, ra_mem_, dec_mem_, weight_mem_):
r"""Compute the major axis of a given cluster from the distribution of
its member galaxies using the position second moments.

The computation is done according to Eq. 5-10 of Shin et al. 2018, arXiv:1705.11167

Current implementation assumes the +RA direction is aligned with +x direction.

For extended descriptions of parameters, see `compute_shear()` documentation.
"""
ind_bcg = (np.array(ra_mem_) == ra_lens_) * (np.array(dec_mem_) == dec_lens_)
sk_lens = SkyCoord(ra_lens_ * u.deg, dec_lens_ * u.deg, frame="icrs")
sk_mem = SkyCoord(
np.array(ra_mem_)[~ind_bcg] * u.deg, np.array(dec_mem_)[~ind_bcg] * u.deg, frame="icrs"
)
position_angle_mem = np.array(sk_lens.position_angle(sk_mem).radian + np.pi / 2.0)
separation_mem = np.array(sk_lens.separation(sk_mem).degree)
x_mem = separation_mem * np.cos(position_angle_mem)
y_mem = separation_mem * np.sin(position_angle_mem)
distance_weight_mem = 1.0 / (separation_mem**2)
weight_total_mem = np.array(weight_mem_) * distance_weight_mem
sum_weight_total_mem = np.sum(weight_total_mem)
# Calcualte second moments of the member galaxies
ixx = np.sum(x_mem**2 * weight_total_mem) / sum_weight_total_mem
iyy = np.sum(y_mem**2 * weight_total_mem) / sum_weight_total_mem
ixy = np.sum(x_mem * y_mem * weight_total_mem) / sum_weight_total_mem
# Transformation of the second moments to the direction of the major axis
phi_major = np.arctan2(2.0 * ixy, ixx - iyy) / 2.0
return phi_major


def _rotate_shear(shear1, shear2, phi_major):
r"""Rotate shear components into the coordinate where +x axis is aligned with
the cluster major axis.

.. math::
g_rotated = g * \exp\left(-2i\phi\right)

For extended descriptions of parameters, see `compute_shear()` documentation.
"""
shear_vec = shear1 + shear2 * 1.0j
rotated_shear_vec = shear_vec * np.exp(-2.0j * phi_major)
return np.real(rotated_shear_vec), np.imag(rotated_shear_vec)


def _compute_tangential_shear(shear1, shear2, phi):
r"""Compute the tangential shear given the two shears and azimuthal positions for
a single source or list of sources.
Expand Down Expand Up @@ -475,6 +576,25 @@ def _compute_cross_shear(shear1, shear2, phi):
return shear1 * np.sin(2.0 * phi) - shear2 * np.cos(2.0 * phi)


def _compute_4theta_shear(shear1, shear2, phi):
r"""Compute the 4theta component of the quadrupole shear given the two shear components and
azimuthal positions for a single source or list of sources.

We compute the tangential shear following Eq. 31 of Shin et al. 2018, arXiv:1705.11167

.. math::
g_4theta = g_1\cos\left(4\phi\right)+g_2\sin\left(4\phi\right)

Note that here `\phi` is the position angle of the source galaxies
with respect to the major axis of the cluster.
Also, `shear1` and `shear2` are measured in the coordinate where
the +x axis is aligned with the major axis of the cluster.

For extended descriptions of parameters, see `compute_shear()' documentation.
"""
return shear1 * np.cos(4.0 * phi) + shear2 * np.sin(4.0 * phi)


def make_radial_profile(
components,
angsep,
Expand Down Expand Up @@ -656,7 +776,7 @@ def make_stacked_radial_profile(angsep, weights, components):
Parameters
----------
angsep: 2d array
Transvesal distances corresponding to each object with shape `n_obj, n_rad_bins`.
Transversal distances corresponding to each object with shape `n_obj, n_rad_bins`.
weights: 2d array
Weights corresponding to each objects with shape `n_obj, n_rad_bins`.
components: list of 2d arrays
Expand Down
Loading
Loading