Skip to content

Commit

Permalink
make it possible to ignore dual in dds2cubes even when dual exists
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Apr 21, 2024
1 parent 24f0dcb commit 830099c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pfb/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def init_mask(mask, model, output_type, log):
return mask


def dds2cubes(dds, nband, apparent=False):
def dds2cubes(dds, nband, apparent=False, dual=True):
real_type = dds[0].DIRTY.dtype
complex_type = np.result_type(real_type, np.complex64)
nx, ny = dds[0].DIRTY.shape
Expand All @@ -687,7 +687,7 @@ def dds2cubes(dds, nband, apparent=False):
psfhat = None
mean_beam = [da.zeros((nx, ny), chunks=(-1, -1),
dtype=real_type) for _ in range(nband)]
if 'DUAL' in dds[0]:
if dual and 'DUAL' in dds[0]:
nbasis, nymax, nxmax = dds[0].DUAL.shape
dual = [da.zeros((nbasis, nymax, nxmax), chunks=(-1, -1, -1),
dtype=real_type) for _ in range(nband)]
Expand All @@ -708,7 +708,7 @@ def dds2cubes(dds, nband, apparent=False):
psfhat[b] += ds.PSFHAT.data
if 'MODEL' in ds:
model[b] = ds.MODEL.data
if 'DUAL' in ds:
if dual and 'DUAL' in ds:
dual[b] = ds.DUAL.data
mean_beam[b] += ds.BEAM.data * ds.WSUM.data[0]
wsums[b] += ds.WSUM.data[0]
Expand All @@ -721,7 +721,7 @@ def dds2cubes(dds, nband, apparent=False):
if 'PSF' in ds:
psf = da.stack(psf)/wsum
psfhat = da.stack(psfhat)/wsum
if 'DUAL' in ds:
if dual and 'DUAL' in ds:
dual = da.stack(dual)
for b in range(nband):
if wsums[b]:
Expand Down
3 changes: 2 additions & 1 deletion pfb/workers/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def _restore(**kw):
# stack cubes
dirty, model, residual, psf, _, _, wsums, _ = dds2cubes(dds,
nband,
apparent=True)
apparent=True,
dual=False)
wsum = np.sum(wsums)
output_type = dirty.dtype
fmask = wsums > 0
Expand Down

0 comments on commit 830099c

Please sign in to comment.