dsigma 1.2.0__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dsigma-1.2.0 → dsigma-1.2.2}/PKG-INFO +9 -3
- {dsigma-1.2.0 → dsigma-1.2.2}/README.md +8 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/__init__.py +2 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/helpers.py +2 -3
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/jackknife.py +10 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/physics.py +23 -18
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/precompute.py +5 -6
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/precompute_engine.pyx +1 -1
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/scripts/process_decade.py +1 -1
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/scripts/process_des_y3.py +2 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/scripts/process_hsc_y3.py +2 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/scripts/process_kids_legacy.py +2 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/PKG-INFO +9 -3
- {dsigma-1.2.0 → dsigma-1.2.2}/tests/test_jackknife.py +5 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/tests/test_physics.py +11 -7
- {dsigma-1.2.0 → dsigma-1.2.2}/tests/test_precompute.py +34 -2
- {dsigma-1.2.0 → dsigma-1.2.2}/LICENSE +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma/stacking.py +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/SOURCES.txt +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/dependency_links.txt +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/entry_points.txt +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/requires.txt +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/dsigma.egg-info/top_level.txt +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/pyproject.toml +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/setup.cfg +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/tests/test_full.py +0 -0
- {dsigma-1.2.0 → dsigma-1.2.2}/tests/test_stacking.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dsigma
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: A Galaxy-Galaxy Lensing Python Package
|
|
5
5
|
Author-email: "Johannes U. Lange" <jlange@american.edu>, Song Huang <shuang@tsinghua.edu.cn>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -33,6 +33,8 @@ Provides-Extra: process
|
|
|
33
33
|
Requires-Dist: h5py>=3.0.0; extra == "process"
|
|
34
34
|
Dynamic: license-file
|
|
35
35
|
|
|
36
|
+
<div align="center">
|
|
37
|
+
|
|
36
38
|

|
|
37
39
|
|
|
38
40
|
[](https://github.com/johannesulf/dsigma/actions)
|
|
@@ -42,6 +44,10 @@ Dynamic: license-file
|
|
|
42
44
|

|
|
43
45
|

|
|
44
46
|
[](https://raw.githubusercontent.com/johannesulf/dsigma/main/LICENSE)
|
|
47
|
+
[](https://doi.org/10.5281/zenodo.20378642)
|
|
49
|
+
|
|
50
|
+
</div>
|
|
45
51
|
|
|
46
52
|
``dsigma`` is an easy-to-use Python package for measuring gravitational galaxy-galaxy lensing. Using a lensing catalog, it estimates excess surface density around a population of lenses, such as galaxies in the Sloan Digital Sky Survey or the Baryon Oscillation Spectroscopic Survey. It has a flexible API and can utilize data from, DECADE, the Dark Energy Survey (DES), the Kilo-Degree Survey (KiDS), and the Hyper Suprime-Cam (HSC) lensing surveys, among others. With core computations written in C, ``dsigma`` is very fast. Additionally, ``dsigma`` provides out-of-the-box support for estimating covariances with jackknife resampling and calculating various summary statistics.
|
|
47
53
|
|
|
@@ -54,7 +60,7 @@ Dynamic: license-file
|
|
|
54
60
|
|
|
55
61
|
## Installation
|
|
56
62
|
|
|
57
|
-
The easiest way to install ``dsigma`` is to use ``pip``
|
|
63
|
+
The easiest way to install ``dsigma`` is to use ``pip`` for the latest stable version from the Python Package Index (PyPI).
|
|
58
64
|
|
|
59
65
|
pip install dsigma
|
|
60
66
|
|
|
@@ -76,4 +82,4 @@ Documentation for ``dsigma`` with concept introductions, examples, and API docum
|
|
|
76
82
|
|
|
77
83
|
## Generative AI
|
|
78
84
|
|
|
79
|
-
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites.
|
|
85
|
+
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites. The core developers did not use AI to write any part of the ``dsigma`` code itself. Code contributions from other developers may use AI, as described in the respective pull requests, and are carefully vetted by the core developers.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|

|
|
2
4
|
|
|
3
5
|
[](https://github.com/johannesulf/dsigma/actions)
|
|
@@ -7,6 +9,10 @@
|
|
|
7
9
|

|
|
8
10
|

|
|
9
11
|
[](https://raw.githubusercontent.com/johannesulf/dsigma/main/LICENSE)
|
|
12
|
+
[](https://doi.org/10.5281/zenodo.20378642)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
10
16
|
|
|
11
17
|
``dsigma`` is an easy-to-use Python package for measuring gravitational galaxy-galaxy lensing. Using a lensing catalog, it estimates excess surface density around a population of lenses, such as galaxies in the Sloan Digital Sky Survey or the Baryon Oscillation Spectroscopic Survey. It has a flexible API and can utilize data from, DECADE, the Dark Energy Survey (DES), the Kilo-Degree Survey (KiDS), and the Hyper Suprime-Cam (HSC) lensing surveys, among others. With core computations written in C, ``dsigma`` is very fast. Additionally, ``dsigma`` provides out-of-the-box support for estimating covariances with jackknife resampling and calculating various summary statistics.
|
|
12
18
|
|
|
@@ -19,7 +25,7 @@
|
|
|
19
25
|
|
|
20
26
|
## Installation
|
|
21
27
|
|
|
22
|
-
The easiest way to install ``dsigma`` is to use ``pip``
|
|
28
|
+
The easiest way to install ``dsigma`` is to use ``pip`` for the latest stable version from the Python Package Index (PyPI).
|
|
23
29
|
|
|
24
30
|
pip install dsigma
|
|
25
31
|
|
|
@@ -41,4 +47,4 @@ Documentation for ``dsigma`` with concept introductions, examples, and API docum
|
|
|
41
47
|
|
|
42
48
|
## Generative AI
|
|
43
49
|
|
|
44
|
-
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites.
|
|
50
|
+
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites. The core developers did not use AI to write any part of the ``dsigma`` code itself. Code contributions from other developers may use AI, as described in the respective pull requests, and are carefully vetted by the core developers.
|
|
@@ -4,8 +4,8 @@ from astropy.cosmology import Planck15
|
|
|
4
4
|
|
|
5
5
|
default_cosmology = Planck15
|
|
6
6
|
|
|
7
|
-
from . import helpers, jackknife, physics, precompute, stacking
|
|
7
|
+
from . import helpers, jackknife, physics, precompute, stacking
|
|
8
8
|
|
|
9
9
|
__all__ = ['default_cosmology', 'helpers', 'jackknife', 'physics',
|
|
10
10
|
'precompute', 'stacking']
|
|
11
|
-
__version__ = '1.2.
|
|
11
|
+
__version__ = '1.2.2'
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"""Convenience functions for the dsigma pipeline."""
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
|
-
from scipy.interpolate import make_interp_spline
|
|
5
|
-
|
|
6
4
|
from astropy import units as u
|
|
5
|
+
from scipy.interpolate import make_interp_spline
|
|
7
6
|
|
|
8
|
-
__all__ = ['
|
|
7
|
+
__all__ = ['in_degrees', 'interpolate_over_redshift', 'spherical_to_cartesian']
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def interpolate_over_redshift(f, z, *args, **kwargs):
|
|
@@ -204,7 +204,8 @@ def smooth_covariance_matrix(cov, sigma):
|
|
|
204
204
|
|
|
205
205
|
|
|
206
206
|
def jackknife_resampling(f, table_l, table_r=None, table_l_2=None,
|
|
207
|
-
table_r_2=None, compress=True,
|
|
207
|
+
table_r_2=None, compress=True, return_samples=False,
|
|
208
|
+
**kwargs):
|
|
208
209
|
"""Compute the covariance of a function from jackknife re-sampling.
|
|
209
210
|
|
|
210
211
|
Parameters
|
|
@@ -233,6 +234,9 @@ def jackknife_resampling(f, table_l, table_r=None, table_l_2=None,
|
|
|
233
234
|
``dsigma.jackknife.compress_jackknife_fields`` before performing the
|
|
234
235
|
jackknife calculation. This can substantially improve performance.
|
|
235
236
|
Default is ``True``.
|
|
237
|
+
return_samples : bool, optional
|
|
238
|
+
If ``True``, return the list of samples used to compute the covariance
|
|
239
|
+
as a second return value.
|
|
236
240
|
**kwargs
|
|
237
241
|
Additional keyword arguments to be passed to the function.
|
|
238
242
|
|
|
@@ -240,7 +244,9 @@ def jackknife_resampling(f, table_l, table_r=None, table_l_2=None,
|
|
|
240
244
|
-------
|
|
241
245
|
cov : numpy.ndarray or astropy.units.quantity.Quantity
|
|
242
246
|
Covariance matrix of the result derived from jackknife re-sampling.
|
|
243
|
-
|
|
247
|
+
samples : list[array]
|
|
248
|
+
Only returned if return_samples=True. The samples used to compute the
|
|
249
|
+
covariance.
|
|
244
250
|
"""
|
|
245
251
|
samples = []
|
|
246
252
|
|
|
@@ -267,5 +273,7 @@ def jackknife_resampling(f, table_l, table_r=None, table_l_2=None,
|
|
|
267
273
|
if isinstance(samples[0], u.Quantity):
|
|
268
274
|
cov = cov * samples[0].unit**2
|
|
269
275
|
|
|
276
|
+
if return_samples:
|
|
277
|
+
return cov, samples
|
|
270
278
|
|
|
271
279
|
return cov
|
|
@@ -140,7 +140,7 @@ def effective_critical_surface_density(
|
|
|
140
140
|
return 1.0 / sigma_crit_eff_inv
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
def _to_camb(cosmology, sigma_8, n_s, z):
|
|
143
|
+
def _to_camb(cosmology, sigma_8, n_s, z, k_max=1e3):
|
|
144
144
|
r"""Convert an astropy cosmology object into a CAMB result object.
|
|
145
145
|
|
|
146
146
|
Parameters
|
|
@@ -150,9 +150,12 @@ def _to_camb(cosmology, sigma_8, n_s, z):
|
|
|
150
150
|
sigma_8 : float
|
|
151
151
|
Scale of fluctuations at :math:`8 h^{-1} \, \mathrm{Mpc}`.
|
|
152
152
|
n_s : float
|
|
153
|
-
Primordial power spectrum index.
|
|
153
|
+
Primordial power spectrum index.
|
|
154
154
|
z : numpy.ndarray
|
|
155
155
|
Redshifts for which to compute the power spectrum.
|
|
156
|
+
k_max : float, optional
|
|
157
|
+
The maximum wavenumber (in :math:`\mathrm{Mpc}^{-1}`) beyond which the
|
|
158
|
+
power spectrum is assumed to be 0. Default is 1000.
|
|
156
159
|
|
|
157
160
|
Returns
|
|
158
161
|
-------
|
|
@@ -162,7 +165,7 @@ def _to_camb(cosmology, sigma_8, n_s, z):
|
|
|
162
165
|
|
|
163
166
|
Raises
|
|
164
167
|
------
|
|
165
|
-
|
|
168
|
+
TypeError
|
|
166
169
|
If cosmology is not an instance of ``astropy.cosmology.FlatLambdaCDM``.
|
|
167
170
|
ImportError
|
|
168
171
|
If ``camb`` is not installed.
|
|
@@ -170,7 +173,7 @@ def _to_camb(cosmology, sigma_8, n_s, z):
|
|
|
170
173
|
"""
|
|
171
174
|
if not isinstance(cosmology, FlatLambdaCDM):
|
|
172
175
|
msg = "Cosmology must be instance of astropy.cosmology.FlatLambdaCDM."
|
|
173
|
-
raise
|
|
176
|
+
raise TypeError(msg)
|
|
174
177
|
|
|
175
178
|
try:
|
|
176
179
|
import camb
|
|
@@ -184,26 +187,28 @@ def _to_camb(cosmology, sigma_8, n_s, z):
|
|
|
184
187
|
cosmology.m_nu.to(u.eV).value)
|
|
185
188
|
|
|
186
189
|
# Note that astropy considers all neutrinos for Onu but CAMB only takes
|
|
187
|
-
# into account massive neutrinos for "nu".
|
|
188
|
-
# Onu h^2 = sum m_nu / 93.14 eV formula.
|
|
190
|
+
# into account massive neutrinos for "nu".
|
|
189
191
|
pars = camb.set_params(
|
|
190
192
|
H0=100 * h, omch2=(cosmology.Om0 - cosmology.Ob0) * h**2,
|
|
191
|
-
ombh2=cosmology.Ob0 * h**2,
|
|
193
|
+
ombh2=cosmology.Ob0 * h**2,
|
|
194
|
+
omnuh2=(
|
|
195
|
+
cosmology.Onu0 - 0.227107318 * cosmology.Ogamma0 * cosmology.Neff *
|
|
196
|
+
np.mean(m_nu == 0)) * h**2,
|
|
192
197
|
TCMB=cosmology.Tcmb0.to(u.K).value,
|
|
193
|
-
num_nu_massless=cosmology.Neff
|
|
198
|
+
num_nu_massless=cosmology.Neff * np.mean(m_nu == 0),
|
|
194
199
|
num_nu_massive=np.sum(m_nu > 0),
|
|
195
200
|
nu_mass_eigenstates=len(np.unique(m_nu[m_nu > 0])),
|
|
196
201
|
nu_mass_numbers=np.unique(m_nu[m_nu > 0], return_counts=True)[1],
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
nu_mass_fractions=[np.average(m_nu == m_nu_i, weights=m_nu) for
|
|
203
|
+
m_nu_i in np.unique(m_nu[m_nu > 0])],
|
|
204
|
+
nu_mass_degeneracies=cosmology.Neff / len(m_nu) * np.unique(
|
|
205
|
+
m_nu[m_nu > 0], return_counts=True)[1],
|
|
206
|
+
ns=n_s, As=a_s, NonLinear='NonLinear_pk', kmax=k_max, redshifts=z)
|
|
199
207
|
|
|
200
208
|
results = camb.get_results(pars)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
a_s *= (sigma_8 / results.get_sigma8_0())**2
|
|
205
|
-
pars.InitPower.set_params(ns=n_s, As=a_s)
|
|
206
|
-
results = camb.get_results(pars)
|
|
209
|
+
a_s *= (sigma_8 / results.get_sigma8_0())**2
|
|
210
|
+
pars.InitPower.set_params(ns=n_s, As=a_s)
|
|
211
|
+
results = camb.get_results(pars)
|
|
207
212
|
|
|
208
213
|
return results
|
|
209
214
|
|
|
@@ -291,7 +296,7 @@ def lens_magnification_shear_bias(
|
|
|
291
296
|
should never fall below `bessel_function_zeros`. Default is 100.
|
|
292
297
|
k_max : float, optional
|
|
293
298
|
The maximum wavenumber (in :math:`\mathrm{Mpc}^{-1}`) beyond which the
|
|
294
|
-
power spectrum is assumed to be 0. Default is
|
|
299
|
+
power spectrum is assumed to be 0. Default is 1000.
|
|
295
300
|
|
|
296
301
|
Returns
|
|
297
302
|
-------
|
|
@@ -319,7 +324,7 @@ def lens_magnification_shear_bias(
|
|
|
319
324
|
cosmology.angular_diameter_distance_z1z2(z_u, z_s)[idx] /
|
|
320
325
|
cosmology.angular_diameter_distance(z_s) *
|
|
321
326
|
np.where(k > k_max, 0, np.array(
|
|
322
|
-
[p(z_i, k_i) for z_i, k_i in zip(z, k)])))
|
|
327
|
+
[np.squeeze(p(z_i, k_i)) for z_i, k_i in zip(z, k)])))
|
|
323
328
|
|
|
324
329
|
ell_max = np.amax(jn_zeros(2, bessel_function_zeros)) / theta
|
|
325
330
|
|
|
@@ -11,9 +11,8 @@ from astropy.units import UnitConversionError
|
|
|
11
11
|
from astropy_healpix import HEALPix
|
|
12
12
|
|
|
13
13
|
from . import default_cosmology
|
|
14
|
-
from .helpers import
|
|
15
|
-
from .physics import critical_surface_density
|
|
16
|
-
from .physics import effective_critical_surface_density
|
|
14
|
+
from .helpers import in_degrees, interpolate_over_redshift
|
|
15
|
+
from .physics import critical_surface_density, effective_critical_surface_density
|
|
17
16
|
from .precompute_engine import precompute_engine
|
|
18
17
|
|
|
19
18
|
__all__ = ['mean_photo_z_offset', 'photo_z_dilution_factor', 'precompute']
|
|
@@ -407,15 +406,15 @@ def precompute(
|
|
|
407
406
|
for i in range(n_jobs):
|
|
408
407
|
process = mp.Process(
|
|
409
408
|
target=precompute_engine, args=args,
|
|
410
|
-
kwargs=
|
|
409
|
+
kwargs={'progress_bar': progress_bar if i == 0 else False})
|
|
411
410
|
process.start()
|
|
412
411
|
processes.append(process)
|
|
413
412
|
for i in range(n_jobs):
|
|
414
413
|
processes[i].join()
|
|
415
414
|
|
|
416
415
|
if n_jobs > 1:
|
|
417
|
-
for key in table_engine_r:
|
|
418
|
-
table_engine_r[key] = np.array(
|
|
416
|
+
for key, value in table_engine_r.items():
|
|
417
|
+
table_engine_r[key] = np.array(value)
|
|
419
418
|
|
|
420
419
|
inv_argsort_pix_l = np.argsort(argsort_pix_l)
|
|
421
420
|
for key in table_engine_r:
|
|
@@ -215,7 +215,7 @@ def precompute_engine(
|
|
|
215
215
|
dy = y_pix_l[i_pix_l] - y_pix_s[i_pix_s]
|
|
216
216
|
dz = z_pix_l[i_pix_l] - z_pix_s[i_pix_s]
|
|
217
217
|
chord_sq_pix_min = dx * dx + dy * dy + dz * dz
|
|
218
|
-
chord_sq_pix_min = pow(sqrt(chord_sq_pix_min) - 2 * max_pixrad, 2)
|
|
218
|
+
chord_sq_pix_min = pow(fmax(sqrt(chord_sq_pix_min) - 2 * max_pixrad, 0.0), 2)
|
|
219
219
|
|
|
220
220
|
# Loop over all lenses in the pixel.
|
|
221
221
|
for i_l in range(i_l_min, i_l_max):
|
|
@@ -101,7 +101,7 @@ def process_decade():
|
|
|
101
101
|
# Adjust redshift bin definition.
|
|
102
102
|
table_s['MCAL_SEL_NOSHEAR'] -= 1
|
|
103
103
|
|
|
104
|
-
keys = dict(ra='RA', dec='DEC', z_bin='MCAL_SEL_NOSHEAR',
|
|
104
|
+
keys = dict(ra='RA', dec='DEC', z_bin='MCAL_SEL_NOSHEAR', # noqa: C408
|
|
105
105
|
e_1='MCAL_G_1_NOSHEAR', e_2='MCAL_G_2_NOSHEAR',
|
|
106
106
|
w='MCAL_W_NOSHEAR', m='m')
|
|
107
107
|
for new_key, old_key in keys.items():
|
|
@@ -76,7 +76,7 @@ def process_des_y3():
|
|
|
76
76
|
m = np.array([-0.63, -1.98, -2.41, -3.69]) * 1e-2
|
|
77
77
|
table_s['m'] = m[table_s['z_bin']]
|
|
78
78
|
|
|
79
|
-
keys = dict(w='weight', R_11='R11', R_22='R22', R_12='R12', R_21='R21')
|
|
79
|
+
keys = dict(w='weight', R_11='R11', R_22='R22', R_12='R12', R_21='R21') # noqa: C408
|
|
80
80
|
for new_key, old_key in keys.items():
|
|
81
81
|
table_s.rename_column(old_key, new_key)
|
|
82
82
|
|
|
@@ -86,7 +86,7 @@ def process_des_y3():
|
|
|
86
86
|
table_n = Table.read(
|
|
87
87
|
'2pt_NG_final_2ptunblind_02_26_21_wnz_maglim_covupdate.fits', hdu=6)
|
|
88
88
|
table_n.rename_column('Z_MID', 'z')
|
|
89
|
-
table_n['n'] = np.column_stack([table_n[f'BIN{i+1}'] for i in range(4)])
|
|
89
|
+
table_n['n'] = np.column_stack([table_n[f'BIN{i + 1}'] for i in range(4)])
|
|
90
90
|
table_n.keep_columns(['z', 'n'])
|
|
91
91
|
table_n.write('des_y3.hdf5', path='calibration', overwrite=True,
|
|
92
92
|
append=True)
|
|
@@ -29,7 +29,7 @@ def process_hsc_y3():
|
|
|
29
29
|
# Remove regions with large B-modes.
|
|
30
30
|
table_s = table_s[table_s['b_mode_mask'] == 1]
|
|
31
31
|
|
|
32
|
-
keys = dict(
|
|
32
|
+
keys = dict( # noqa: C408
|
|
33
33
|
ra='i_ra', dec='i_dec', z_bin='hsc_y3_zbin',
|
|
34
34
|
e_1='i_hsmshaperegauss_e1', e_2='i_hsmshaperegauss_e2',
|
|
35
35
|
w='i_hsmshaperegauss_derived_weight',
|
|
@@ -63,7 +63,7 @@ def process_hsc_y3():
|
|
|
63
63
|
table_n = Table.read('nz.fits')
|
|
64
64
|
# Create the columns expected by dsigma.
|
|
65
65
|
table_n.rename_column('Z_MID', 'z')
|
|
66
|
-
table_n['n'] = np.column_stack([table_n[f'BIN{i+1}'] for i in range(4)])
|
|
66
|
+
table_n['n'] = np.column_stack([table_n[f'BIN{i + 1}'] for i in range(4)])
|
|
67
67
|
table_n.keep_columns(['z', 'n'])
|
|
68
68
|
table_n.write('hsc_y3.hdf5', path='calibration', overwrite=True,
|
|
69
69
|
append=True)
|
|
@@ -21,8 +21,8 @@ def process_kids_legacy():
|
|
|
21
21
|
|
|
22
22
|
table_s = Table.read('KiDS_Legacy_NS_unblind_final.fits.gz')
|
|
23
23
|
|
|
24
|
-
keys = dict(ra='RAJ2000', dec='DECJ2000', z_bin='TOMOBIN',
|
|
25
|
-
e_2='e2', w='weight')
|
|
24
|
+
keys = dict(ra='RAJ2000', dec='DECJ2000', z_bin='TOMOBIN', # noqa: C408
|
|
25
|
+
e_1='e1', e_2='e2', w='weight')
|
|
26
26
|
for new_key, old_key in keys.items():
|
|
27
27
|
table_s.rename_column(old_key, new_key)
|
|
28
28
|
table_s.keep_columns(keys.keys())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dsigma
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: A Galaxy-Galaxy Lensing Python Package
|
|
5
5
|
Author-email: "Johannes U. Lange" <jlange@american.edu>, Song Huang <shuang@tsinghua.edu.cn>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -33,6 +33,8 @@ Provides-Extra: process
|
|
|
33
33
|
Requires-Dist: h5py>=3.0.0; extra == "process"
|
|
34
34
|
Dynamic: license-file
|
|
35
35
|
|
|
36
|
+
<div align="center">
|
|
37
|
+
|
|
36
38
|

|
|
37
39
|
|
|
38
40
|
[](https://github.com/johannesulf/dsigma/actions)
|
|
@@ -42,6 +44,10 @@ Dynamic: license-file
|
|
|
42
44
|

|
|
43
45
|

|
|
44
46
|
[](https://raw.githubusercontent.com/johannesulf/dsigma/main/LICENSE)
|
|
47
|
+
[](https://doi.org/10.5281/zenodo.20378642)
|
|
49
|
+
|
|
50
|
+
</div>
|
|
45
51
|
|
|
46
52
|
``dsigma`` is an easy-to-use Python package for measuring gravitational galaxy-galaxy lensing. Using a lensing catalog, it estimates excess surface density around a population of lenses, such as galaxies in the Sloan Digital Sky Survey or the Baryon Oscillation Spectroscopic Survey. It has a flexible API and can utilize data from, DECADE, the Dark Energy Survey (DES), the Kilo-Degree Survey (KiDS), and the Hyper Suprime-Cam (HSC) lensing surveys, among others. With core computations written in C, ``dsigma`` is very fast. Additionally, ``dsigma`` provides out-of-the-box support for estimating covariances with jackknife resampling and calculating various summary statistics.
|
|
47
53
|
|
|
@@ -54,7 +60,7 @@ Dynamic: license-file
|
|
|
54
60
|
|
|
55
61
|
## Installation
|
|
56
62
|
|
|
57
|
-
The easiest way to install ``dsigma`` is to use ``pip``
|
|
63
|
+
The easiest way to install ``dsigma`` is to use ``pip`` for the latest stable version from the Python Package Index (PyPI).
|
|
58
64
|
|
|
59
65
|
pip install dsigma
|
|
60
66
|
|
|
@@ -76,4 +82,4 @@ Documentation for ``dsigma`` with concept introductions, examples, and API docum
|
|
|
76
82
|
|
|
77
83
|
## Generative AI
|
|
78
84
|
|
|
79
|
-
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites.
|
|
85
|
+
Generative AI was used to search for potential bugs in the code and to improve the documentation by finding typos and suggesting minor rewrites. The core developers did not use AI to write any part of the ``dsigma`` code itself. Code contributions from other developers may use AI, as described in the respective pull requests, and are carefully vetted by the core developers.
|
|
@@ -36,6 +36,11 @@ def test_jackknife(test_catalogs, n_jk):
|
|
|
36
36
|
stacking.tangential_shear, table_l, compress=True),
|
|
37
37
|
rtol=0, atol=1e-12))
|
|
38
38
|
|
|
39
|
+
# Check the return_samples keyword
|
|
40
|
+
cov, samples = jackknife.jackknife_resampling(
|
|
41
|
+
stacking.tangential_shear, table_l, return_samples=True)
|
|
42
|
+
assert len(samples) == n_jk
|
|
43
|
+
|
|
39
44
|
# Test the smoothing.
|
|
40
45
|
cov = jackknife.jackknife_resampling(stacking.tangential_shear, table_l)
|
|
41
46
|
for sigma in [1.0, 2.0, 5.0]:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
+
import pytest
|
|
2
3
|
from astropy import units as u
|
|
3
4
|
from astropy.cosmology import FlatLambdaCDM
|
|
4
5
|
from astropy.cosmology import units as cu
|
|
@@ -32,35 +33,38 @@ def test_critical_surface_density():
|
|
|
32
33
|
assert sigma_crit == np.inf
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
@pytest.mark.parametrize('m_nu', [[0, 0, 0], [0, 0, 0.001], [0, 0, 0.6],
|
|
37
|
+
[0, 0.6, 1.2]])
|
|
38
|
+
def test_to_camb(m_nu):
|
|
36
39
|
# Test that we can convert to CAMB correctly.
|
|
37
40
|
|
|
38
41
|
sigma_8 = 0.7
|
|
39
|
-
cosmology_astropy = default_cosmology
|
|
42
|
+
cosmology_astropy = default_cosmology.clone(m_nu=m_nu, Tcmb0=3.0)
|
|
40
43
|
cosmology_camb = physics._to_camb(cosmology_astropy, sigma_8, 0.96,
|
|
41
44
|
[1, 0.5, 0])
|
|
42
45
|
|
|
43
|
-
assert np.isclose(cosmology_camb.get_sigma8_0(), sigma_8
|
|
46
|
+
assert np.isclose(cosmology_camb.get_sigma8_0(), sigma_8, rtol=1e-6,
|
|
47
|
+
atol=0)
|
|
44
48
|
|
|
45
49
|
z = np.linspace(0, 5, 20)
|
|
46
50
|
|
|
47
51
|
assert np.allclose(
|
|
48
52
|
cosmology_astropy.angular_diameter_distance(z).to(u.Mpc).value,
|
|
49
|
-
cosmology_camb.angular_diameter_distance(z), rtol=
|
|
53
|
+
cosmology_camb.angular_diameter_distance(z), rtol=1e-6, atol=0)
|
|
50
54
|
|
|
51
55
|
assert np.allclose(
|
|
52
56
|
cosmology_camb.get_Omega('photon', z),
|
|
53
|
-
cosmology_astropy.Ogamma(z), rtol=
|
|
57
|
+
cosmology_astropy.Ogamma(z), rtol=1e-5, atol=0)
|
|
54
58
|
|
|
55
59
|
assert np.allclose(
|
|
56
60
|
cosmology_camb.get_Omega('baryon', z) +
|
|
57
61
|
cosmology_camb.get_Omega('cdm', z),
|
|
58
|
-
cosmology_astropy.Om(z), rtol=
|
|
62
|
+
cosmology_astropy.Om(z), rtol=1e-5, atol=0)
|
|
59
63
|
|
|
60
64
|
assert np.allclose(
|
|
61
65
|
cosmology_camb.get_Omega('neutrino', z) +
|
|
62
66
|
cosmology_camb.get_Omega('nu', z),
|
|
63
|
-
cosmology_astropy.Onu(z), rtol=
|
|
67
|
+
cosmology_astropy.Onu(z), rtol=2e-3, atol=0)
|
|
64
68
|
|
|
65
69
|
|
|
66
70
|
def test_gaussian_quadrature_2d():
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import pytest
|
|
3
|
-
from astropy
|
|
3
|
+
from astropy import units as u
|
|
4
|
+
from astropy.coordinates import SkyCoord
|
|
5
|
+
from astropy.cosmology import LambdaCDM, FlatLambdaCDM
|
|
4
6
|
from astropy.table import Table
|
|
5
|
-
|
|
6
7
|
from dsigma.precompute import precompute
|
|
7
8
|
from fixtures import test_catalogs
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
def test_pairs_below_pixel_size():
|
|
12
|
+
# Each lens gets one source 30" away, far below the nside=256 pixel
|
|
13
|
+
# (~13.7'). The sub-pixel search radius must not cause the pixel
|
|
14
|
+
# pre-filter to drop same-pixel pairs, so #pairs == #lenses.
|
|
15
|
+
ra, dec = np.meshgrid(np.linspace(10.0, 18.0, 25),
|
|
16
|
+
np.linspace(-8.0, 8.0, 20))
|
|
17
|
+
ra, dec = ra.ravel(), dec.ravel()
|
|
18
|
+
n = ra.size
|
|
19
|
+
|
|
20
|
+
table_l = Table()
|
|
21
|
+
table_l['ra'] = ra * u.deg
|
|
22
|
+
table_l['dec'] = dec * u.deg
|
|
23
|
+
table_l['z'] = np.full(n, 0.2)
|
|
24
|
+
table_l['w_sys'] = np.ones(n)
|
|
25
|
+
|
|
26
|
+
c_s = SkyCoord(table_l['ra'], table_l['dec']).directional_offset_by(
|
|
27
|
+
0 * u.deg, 30 * u.arcsec)
|
|
28
|
+
table_s = Table()
|
|
29
|
+
table_s['ra'] = c_s.ra
|
|
30
|
+
table_s['dec'] = c_s.dec
|
|
31
|
+
table_s['z'] = np.full(n, 0.8)
|
|
32
|
+
table_s['w'] = np.ones(n)
|
|
33
|
+
table_s['e_1'] = np.zeros(n)
|
|
34
|
+
table_s['e_2'] = np.zeros(n)
|
|
35
|
+
|
|
36
|
+
rp_bins = [15, 60] * u.arcsec
|
|
37
|
+
table_l = precompute(table_l, table_s, rp_bins,
|
|
38
|
+
cosmology=FlatLambdaCDM(70, 0.2, 0.7))
|
|
39
|
+
assert table_l['sum 1'].sum() == n
|
|
40
|
+
|
|
41
|
+
|
|
10
42
|
def test_warnings_errors(test_catalogs):
|
|
11
43
|
# Check that dsigma throws expected value errors.
|
|
12
44
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|