Skip to content

Commit

Permalink
allow empty string for transfer_model_from parameter, allow l2reweigh…
Browse files Browse the repository at this point in the history
…t_dof=0
  • Loading branch information
landmanbester committed Jan 30, 2024
1 parent 7533ebc commit d5dfc43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
18 changes: 3 additions & 15 deletions pfb/operators/gridder.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,10 @@ def image_data_products(uvw,
ressq = (residual_vis*residual_vis.conj()).real
wcount = mask.sum()
if wcount:
ovar = ressq.sum()/wcount
l2wgt = (l2reweight_dof + 1)/(l2reweight_dof + ressq/ovar)/ovar
ovar = ressq.sum()/wcount # use 67% quantile?
wgt = (l2reweight_dof + 1)/(l2reweight_dof + ressq/ovar)/ovar
else:
l2wgt = None
else:
l2wgt = None
wgt = None


# we usually want to re-evaluate this since the robustness may change
Expand All @@ -628,16 +626,7 @@ def image_data_products(uvw,
nx, ny,
cellx, celly,
robustness)

# this is necessitated by the way the weighting is done i.e.
# wgt applied to vis@init so only imwgt*l2wgt needs to be applied
if l2wgt is not None:
imwgt *= l2wgt

# wgt*imwgt*l2wgt required for PSF
wgt *= imwgt
else:
imwgt = None

if do_weight:
out_dict['WEIGHT'] = wgt
Expand All @@ -650,7 +639,6 @@ def image_data_products(uvw,
freq=freq,
vis=vis,
wgt=wgt,
# wgt=imwgt, # data already naturally weighted
mask=mask,
npix_x=nx, npix_y=ny,
pixsize_x=cellx, pixsize_y=celly,
Expand Down
4 changes: 2 additions & 2 deletions pfb/workers/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def _grid(xdsi=None, **kw):
print(f'Image space data products will be stored in {dds_name}.', file=log)

# check if model exists
if opts.transfer_model_from is not None:
if opts.transfer_model_from:
try:
mds = xds_from_zarr(opts.transfer_model_from,
chunks={'params':-1, 'comps':-1})[0]
Expand Down Expand Up @@ -399,7 +399,7 @@ def _grid(xdsi=None, **kw):
out_ds = out_ds.assign(**{'BEAM': (('x', 'y'), bvals)})

# get the model
if opts.transfer_model_from is not None:
if opts.transfer_model_from:
from pfb.utils.misc import eval_coeffs_to_slice
model = eval_coeffs_to_slice(
ds.time_out,
Expand Down

0 comments on commit d5dfc43

Please sign in to comment.