Skip to content

Commit

Permalink
make beam computational optional in grid worker
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Oct 11, 2024
1 parent cee6165 commit 98da2e1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
14 changes: 8 additions & 6 deletions pfb/operators/gridder.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def image_data_products(dsl,
do_psf=True,
do_residual=True,
do_weight=True,
do_noise=False):
do_noise=False,
do_beam=False):
'''
Function to compute image space data products in one go
Expand Down Expand Up @@ -415,7 +416,7 @@ def image_data_products(dsl,
flip_v=flip_v,
flip_w=flip_w,
nthreads=nthreads,
divide_by_n=False, # incorporte in smooth beam
divide_by_n=False, # incorporate in smooth beam
sigma_min=1.1, sigma_max=3.0)

residual_vis *= -1 # negate model
Expand Down Expand Up @@ -656,10 +657,11 @@ def image_data_products(dsl,

dso['NOISE'] = (('x','y'), noise)

if beam is not None:
dso['BEAM'] = (('x', 'y'), beam)
else:
dso['BEAM'] = (('x', 'y'), np.ones((nx, ny), dtype=wgt.dtype))
if do_beam:
if beam is not None:
dso['BEAM'] = (('x', 'y'), beam)
else:
dso['BEAM'] = (('x', 'y'), np.ones((nx, ny), dtype=wgt.dtype))

# save
dso = dso.assign_attrs(wsum=wsum, x0=x0, y0=y0, l0=l0, m0=m0,
Expand Down
5 changes: 5 additions & 0 deletions pfb/parser/grid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ inputs:
default: true
info:
Compute noise map by sampling from weights
beam:
dtype: bool
default: true
info:
Interpolate average beam pattern
psf-oversize:
dtype: float
default: 1.0
Expand Down
2 changes: 1 addition & 1 deletion pfb/parser/sara.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ inputs:
How to apply positivity constraint
0 -> no positivity,
1 -> normal positivity constraint
and 2 -> strong positivity i.e. all pixels in a band > 0
2 -> strong positivity i.e. all pixels in a band > 0
niter:
dtype: int
default: 10
Expand Down
8 changes: 6 additions & 2 deletions pfb/workers/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ def _grid(**kw):
dsl = ds_dct['dsl']
time_out = ds_dct['time_out']
freq_out = ds_dct['freq_out']

iter0 = 0
if from_cache:
out_ds_name = f'{dds_store.url}/time{timeid}_band{bandid}.zarr'
out_ds = xr.open_zarr(out_ds_name,
chunks=None)
if 'niters' in out_ds:
iter0 = niters
else:
out_ds_name = None

Expand Down Expand Up @@ -415,7 +417,8 @@ def _grid(**kw):
'robustness': opts.robustness,
'super_resolution_factor': opts.super_resolution_factor,
'field_of_view': opts.field_of_view,
'product': opts.product
'product': opts.product,
'niters': iter0
}

# get the model
Expand Down Expand Up @@ -470,6 +473,7 @@ def _grid(**kw):
do_weight=opts.weight,
do_residual=opts.residual,
do_noise=opts.noise,
do_beam=opts.beam,
workers=wname)
futures.append(fut)

Expand Down

0 comments on commit 98da2e1

Please sign in to comment.