Skip to content

Commit

Permalink
Cosine needlets and some fixes and doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
msyriac committed Aug 24, 2024
1 parent 3b8614f commit cd2d1a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pixell/pointsrcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def sim_objects(shape, wcs, poss, amps, profile, prof_ids=None, omap=None, vmin=
is used. amps determines the pre-dimensions
* poss: The positions of the objects. [{dec,ra},nobj] in radians.
* amps: The central amplitudes of the objects. [...,nobj]. Not the same as the flux.
* profile: The profiles to use. Either [{r,b(r)},nsamp] or a list of such.
* profile: The profiles to use. Either [{r,b(r)},nsamp] (with shape (2,nsamp)) or a
list of such, where nsamp is the size of r and b(r). If providing a list for
nobj objects, the shape of the array passed is (nobj,2,nsamp) and prof_ids
should be np.arange(nobj).
Optional arguments:
* prof_ids: Which profile to use for each source. Defaults to use
Expand Down
34 changes: 31 additions & 3 deletions pixell/wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Butterworth:
def __init__(self, step=2, shape=7, tol=1e-3, lmin=None, lmax=None):
self.step = step; self.shape = shape; self.tol = tol
self.lmin = lmin; self.lmax = lmax
if self.lmin is not None and self.lmin is not None:
if self.lmin is not None and self.lmax is not None:

Check warning on line 27 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L27

Added line #L27 was not covered by tests
self._finalize()
def with_bounds(self, lmin, lmax):
"""Return a new instance with the given multipole bounds"""
Expand Down Expand Up @@ -53,7 +53,7 @@ class ButterTrim:
def __init__(self, step=2, shape=7, trim=1e-2, lmin=None, lmax=None):
self.step = step; self.shape = shape; self.trim = trim
self.lmin = lmin; self.lmax = lmax
if self.lmin is not None and self.lmin is not None:
if self.lmin is not None and self.lmax is not None:

Check warning on line 56 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L56

Added line #L56 was not covered by tests
self._finalize()
def with_bounds(self, lmin, lmax):
"""Return a new instance with the given multipole bounds"""
Expand Down Expand Up @@ -83,7 +83,7 @@ class DigitalButterTrim:
def __init__(self, step=2, shape=7, trim=1e-2, lmin=None, lmax=None):
self.step = step; self.shape = shape; self.trim = trim
self.lmin = lmin; self.lmax = lmax
if self.lmin is not None and self.lmin is not None:
if self.lmin is not None and self.lmax is not None:

Check warning on line 86 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L86

Added line #L86 was not covered by tests
self._finalize()
def with_bounds(self, lmin, lmax):
"""Return a new instance with the given multipole bounds"""
Expand Down Expand Up @@ -126,6 +126,34 @@ def _finalize(self):
from optweight import wlm_utils
self.profiles, self.lmaxs = wlm_utils.get_sd_kernels(self.lamb, self.lmax, lmin=self.lmin)



class CosineNeedlet:

Check warning on line 131 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L131

Added line #L131 was not covered by tests
"""From Coulton et al 2023 arxiv:2307.01258"""
def __init__(self, lpeaks):

Check warning on line 133 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L133

Added line #L133 was not covered by tests
"""
Cosine-shaped needlets. lpeaks is a list of multipoles
where each needlet peaks.
"""
self.lpeaks = lpeaks
self.lmaxs = np.append(self.lpeaks[1:],self.lpeaks[-1])
self.lmin = self.lpeaks[0]
self.lmax = self.lpeaks[-1]
@property
def n(self): return len(self.lpeaks)
def __call__(self, i, l):
lpeaki = self.lpeaks[i]
out = l*0.
if i>0:
lpeakim1 = self.lpeaks[i-1]
sel1 = np.logical_and(l>=lpeakim1,l<lpeaki)
out[sel1] = np.cos(np.pi*(lpeaki-l[sel1])/(lpeaki-lpeakim1)/2.)
if i<(self.n-1):
lpeakip1 = self.lpeaks[i+1]
sel2 = np.logical_and(l>=lpeaki,l<lpeakip1)
out[sel2] = np.cos(np.pi*(l[sel2]-lpeaki)/(lpeakip1-lpeaki)/2.)
return out

Check warning on line 155 in pixell/wavelets.py

View check run for this annotation

Codecov / codecov/patch

pixell/wavelets.py#L138-L155

Added lines #L138 - L155 were not covered by tests

##### Variance wavelet basis generators #####

# These are used to implement the variance wavelet transform, which
Expand Down

0 comments on commit cd2d1a0

Please sign in to comment.