Skip to content

Commit

Permalink
Fix monopole subtraction when plotting wcs maps
Browse files Browse the repository at this point in the history
  • Loading branch information
tskisner committed Nov 1, 2024
1 parent b98d623 commit 1188aa1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/toast/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ def flag_unhit(hitmask, mdata):
for mindx in range(mdata.shape[0]):
mdata[mindx, hitmask] = np.nan

def sub_mono(hitmask, mdata):
if hitmask is None:
goodpix = mdata != 0
else:
goodpix = np.logical_and(hitmask, (mdata != 0))
def sub_mono(mdata):
goodpix = np.logical_and(
np.logical_not(np.isnan(mdata)),
mdata != 0,
)
mono = np.mean(mdata[goodpix])
print(f"Monopole = {mono}")
mdata[goodpix] -= mono
Expand Down Expand Up @@ -244,7 +244,7 @@ def sub_mono(hitmask, mdata):

flag_unhit(hitmask, mapdata)

sub_mono(hitmask, mapdata[0])
sub_mono(mapdata[0])
mmin, mmax = sym_range(mapdata[0, :, :])
if range_I is not None:
mmin, mmax = range_I
Expand All @@ -255,6 +255,7 @@ def sub_mono(hitmask, mdata):
plot_single(wcs, mapdata, 0, tmin, tmax, f"{mapfile}_resid_I.{format}")

if mapdata.shape[0] > 1:
sub_mono(mapdata[1])
mmin, mmax = sym_range(mapdata[1, :, :])
if range_Q is not None:
mmin, mmax = range_Q
Expand All @@ -264,6 +265,7 @@ def sub_mono(hitmask, mdata):
mapdata[1, :, :] -= thdu.data[1, :, :]
plot_single(wcs, mapdata, 1, tmin, tmax, f"{mapfile}_resid_Q.{format}")

sub_mono(mapdata[2])
mmin, mmax = sym_range(mapdata[2, :, :])
if range_U is not None:
mmin, mmax = range_U
Expand Down

0 comments on commit 1188aa1

Please sign in to comment.