Skip to content

Commit

Permalink
fixed bug in calculation of f_bias
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesulf committed Jan 18, 2023
1 parent 9685ec7 commit c49ecfe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.1] - 2023-01-18

### Changed

- `dsigma.jackknife.compress_jackknife_fields` now supresses `numpy` warnings if columns contain NaNs

### Fixed

- bug in the calcaluation of the photo-z dilution correction factor, led to percent-level biases in the total galaxy-galaxy lensing amplitude, did not affect DES and KiDS calculations since those are based on n(z)'s, bug was introduced in version 0.6

## [0.7.0] - 2023-01-06

### Changed
Expand Down
9 changes: 7 additions & 2 deletions dsigma/jackknife.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module containing jackknife resampling functions."""

import warnings
import numpy as np
import astropy.units as u
from astropy.coordinates import SkyCoord
Expand Down Expand Up @@ -135,8 +136,12 @@ def compress_jackknife_fields(table):
elif key in ['w_sys', 'sum 1']:
table_jk[i][key] = np.sum(table[key][mask], axis=0)
else:
table_jk[i][key] = np.average(
table[key][mask], weights=table['w_sys'][mask], axis=0)
with warnings.catch_warnings():
if np.any(np.isnan(table[key][mask])):
warnings.simplefilter(
'ignore', category=RuntimeWarning)
table_jk[i][key] = np.average(
table[key][mask], weights=table['w_sys'][mask], axis=0)

return table_jk

Expand Down
4 changes: 2 additions & 2 deletions dsigma/precompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def photo_z_dilution_factor(z_l, table_c, cosmology, weighting=-2,
sigma_crit_true = critical_surface_density(z_l, z_s_true, d_l=d_l,
d_s=d_s_true)

mask = (z_l_max < z_l) & (z_l > z_s)
mask = (z_l_max < z_l) | (z_l > z_s)

if np.any(np.all(mask, axis=-1)):
warnings.warn('Could not find valid calibration sources for some ' +
Expand Down Expand Up @@ -148,7 +148,7 @@ def mean_photo_z_offset(z_l, table_c, cosmology, weighting=-2,
sigma_crit = critical_surface_density(z_l, z_s, d_l=d_l, d_s=d_s)
w = w * sigma_crit**weighting

mask = (z_l_max < z_l) & (z_l > z_s)
mask = (z_l_max < z_l) | (z_l > z_s)

return np.sum((z_s - z_s_true) * w * (~mask), axis=-1) / np.sum(
w * (~mask), axis=-1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dsigma"
version = "0.7.0"
version = "0.7.1"
requires-python = ">=3.8"
authors = [{name = "Johannes U. Lange", email = "julange.astro@pm.me"},
{name = "Song Huang"}]
Expand Down

0 comments on commit c49ecfe

Please sign in to comment.