Skip to content

Commit fbd50aa

Browse files
added option in get_wl1_sphere to divide by noise std to have SNR on x-axis
1 parent e5eb413 commit fbd50aa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pycs/astro/wl/hos_peaks_l1.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,13 @@ def get_wtl1_sphere(
589589
Mask=None,
590590
min_snr=None,
591591
max_snr=None,
592+
noise_std=None,
592593
):
593594
"""
594595
Computes L1 norms of normalized wavelet transform coefficients at different scales for a HEALPix map.
595596
The wavelet transform is performed using CMRStarlet. The normalization ensures || Psi_j ||^2 = 1.
596-
The values binned are C.coef[j] / C.TabNorm[j].
597+
If `noise_std` is provided, the binned values are SNR = (C.coef[j] / C.TabNorm[j]) / noise_std.
598+
Otherwise, the binned values are the normalized coefficients C.coef[j] / C.TabNorm[j].
597599
598600
Parameters
599601
----------
@@ -611,12 +613,15 @@ def get_wtl1_sphere(
611613
max_snr : float, optional
612614
Maximum value for binning the normalized coefficients (C.coef[j] / C.TabNorm[j]).
613615
If None, uses the maximum value in the coefficients for the current scale.
616+
noise_std : float, optional
617+
Noise standard deviation. If provided, coefficients are divided by this value
618+
to compute an SNR before binning. Default is None.
614619
615620
Returns
616621
-------
617622
tuple of numpy arrays
618623
(bins, l1norm) where:
619-
- bins[i] are the bin centers for scale i
624+
- bins[i] are the bin centers for scale i (representing SNR if noise_std is used)
620625
- l1norm[i] are the L1 norms for each bin at scale i
621626
"""
622627

@@ -643,6 +648,10 @@ def get_wtl1_sphere(
643648
else:
644649
ScaleCoeffs = C.coef[i] / C.TabNorm[i]
645650

651+
# If noise_std is provided, convert to SNR
652+
if noise_std is not None:
653+
ScaleCoeffs = ScaleCoeffs / noise_std
654+
646655
# Apply the mask if provided
647656
if Mask is not None:
648657
if Mask.shape[0] != ScaleCoeffs.shape[0]:

0 commit comments

Comments
 (0)