Skip to content

Commit

Permalink
include write_map in filter_func for m_cut, tested, flaked
Browse files Browse the repository at this point in the history
  • Loading branch information
susannaaz committed Nov 30, 2023
1 parent 2ff0bdd commit 5b3f813
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 2 additions & 12 deletions pipeline/filterer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import argparse
import healpy as hp
from soopercool import utils
import numpy as np
from soopercool import BBmeta


Expand Down Expand Up @@ -46,13 +45,7 @@ def filter(args):
pure_type=case)
map = hp.read_map(map_file, field=[0, 1, 2])
if meta.filtering_type == 'm_filterer':
filtered_map = filter_func(map, mask, **kwargs)
hp.write_map(
map_file.replace(".fits", "_filtered.fits"),
filtered_map,
overwrite=True,
dtype=np.float32,
)
filter_func(map, map_file, mask, **kwargs)
elif meta.filtering_type == 'toast':
filter_func(map_file, **kwargs)

Expand All @@ -68,10 +61,7 @@ def filter(args):
)
map = hp.read_map(map_file, field=[0, 1, 2])
if meta.filtering_type == 'm_filterer':
filtered_map = filter_func(map, mask, **kwargs)
hp.write_map(map_file.replace(".fits", "_filtered.fits"),
filtered_map, overwrite=True,
dtype=np.float32)
filter_func(map, map_file, mask, **kwargs)
elif meta.filtering_type == 'toast':
filter_func(map_file, **kwargs)
else:
Expand Down
10 changes: 8 additions & 2 deletions soopercool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def power_law_cl(ell, amp, delta_ell, power_law_index):
return pl_ps


def m_filter_map(map, mask, m_cut):
def m_filter_map(map, map_file, mask, m_cut):
"""
"""

Expand All @@ -229,7 +229,13 @@ def m_filter_map(map, mask, m_cut):
n_modes_to_filter = (m_cut + 1) * (lmax + 1) - ((m_cut + 1) * m_cut) // 2
alms[:, :n_modes_to_filter] = 0.

return hp.alm2map(alms, nside=nside, lmax=lmax)
filtered_map = hp.alm2map(alms, nside=nside, lmax=lmax)

hp.write_map(map_file.replace(".fits", "_filtered.fits"),
filtered_map, overwrite=True,
dtype=np.float32)

return


def toast_filter_map(map, schedule, thinfp, instrument, band, nside):
Expand Down

0 comments on commit 5b3f813

Please sign in to comment.