Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to flag on off diagonal correlations and propagate to all #6

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions surfvis/flagchi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def create_parser():
help='Flag column (default = FLAG)')
parser.add_option('--flag-above', default=3, type=float,
help='flag data with chisq above this value (default = 3)')
parser.add_option('--unflag-below', default=1.15, type=float,
help='unflag data with chisq below this value (default = 1.15)')
parser.add_option('--nthreads', default=4, type=int,
help='Number of dask threads to use')
parser.add_option('--nrows', default=250000, type=int,
Expand Down Expand Up @@ -98,7 +96,6 @@ def main():
uflag = flagchisq(resid, weight, flag, ant1, ant2,
use_corrs=tuple(use_corrs),
flag_above=options.flag_above,
unflag_below=options.unflag_below,
respect_ants=tuple(rants))

out_ds = ds.assign(**{options.fcol: (("row", "chan", "corr"), uflag)})
Expand Down
9 changes: 3 additions & 6 deletions surfvis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _surfchisq(resid, weight, flag, ant1, ant2,


def flagchisq(resid, weight, flag, ant1, ant2,
use_corrs=(), flag_above=5, unflag_below=1,
use_corrs=(), flag_above=5,
respect_ants=()):

# import pdb; pdb.set_trace()
Expand All @@ -109,15 +109,14 @@ def flagchisq(resid, weight, flag, ant1, ant2,
ant2, 'r',
use_corrs, None,
flag_above, None,
unflag_below, None,
respect_ants, None,
dtype=bool)
return res


@njit(fastmath=True, nogil=True)
def _flagchisq(resid, weight, flag, ant1, ant2,
use_corrs, flag_above, unflag_below, respect_ants):
use_corrs, flag_above, respect_ants):
nrow, nchan, ncorr = resid.shape
for r in range(nrow):
if ant1[r] in respect_ants or ant2[r] in respect_ants:
Expand All @@ -128,7 +127,5 @@ def _flagchisq(resid, weight, flag, ant1, ant2,
w = weight[r, f, c]
chi2 = (np.conj(res) * w * res).real
if chi2 > flag_above or chi2 == 0:
flag[r, f, c] = True
elif chi2 <= unflag_below :
flag[r, f, c] = False
flag[r, f, :] = True
return flag
Loading