Skip to content

Commit

Permalink
more consistent use of xds_from_url
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Sep 18, 2024
1 parent 87aca03 commit f4b3b70
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pfb/workers/fluxmop.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fluxmop(**kw):

basename = opts.output_filename
fits_oname = f'{opts.fits_output_folder}/{oname}'
dds_store = DaskMSStore(f'{basename}_{opts.suffix}.dds')
dds_name =f'{basename}_{opts.suffix}.dds'

with ExitStack() as stack:
from distributed import wait
Expand All @@ -76,7 +76,7 @@ def fluxmop(**kw):
ti = time.time()
_fluxmop(**opts)

dds_list = dds_store.fs.glob(f'{dds_store.url}/*.zarr')
_, dds_list = xds_from_url(dds_name)

# convert to fits files
if opts.fits_mfs or opts.fits_cubes:
Expand Down
10 changes: 3 additions & 7 deletions pfb/workers/klean.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def klean(**kw):

basename = f'{basedir}/{oname}'
fits_oname = f'{opts.fits_output_folder}/{oname}'
dds_store = DaskMSStore(f'{basename}_{opts.suffix}.dds')
dds_name = f'{basename}_{opts.suffix}.dds'

with ExitStack() as stack:
ti = time.time()
_klean(**opts)

dds, dds_list = xds_from_url(dds_store.url)
dds, dds_list = xds_from_url(dds_name)

from pfb.utils.fits import dds2fits

Expand Down Expand Up @@ -108,11 +108,7 @@ def _klean(**kw):
fits_oname = basename

dds_name = f'{basename}_{opts.suffix}.dds'
dds_store = DaskMSStore(dds_name)
dds_list = dds_store.fs.glob(f'{dds_store.url}/*.zarr')
drop_vars = ['UVW','WEIGHT','MASK']
dds = xds_from_list(dds_list, nthreads=opts.nthreads,
drop_vars=drop_vars)
dds, dds_list = xds_from_url(dds_name)

nx, ny = dds[0].x.size, dds[0].y.size
nx_psf, ny_psf = dds[0].x_psf.size, dds[0].y_psf.size
Expand Down
3 changes: 1 addition & 2 deletions pfb/workers/model2comps.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def _model2comps(**kw):
fits_oname = basename

dds_name = f'{basename}_{opts.suffix}.dds'
dds_store = DaskMSStore(dds_name)
dds, dds_list = xds_from_url(dds_store.url)
dds, dds_list = xds_from_url(dds_name)

if opts.model_out is not None:
coeff_name = opts.model_out
Expand Down
3 changes: 1 addition & 2 deletions pfb/workers/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def _restore(**kw):
fits_oname = basename

dds_name = f'{basename}_{opts.suffix}.dds'
dds_store = DaskMSStore(dds_name)
dds, dds_list = xds_from_url(dds_store.url)
dds, dds_list = xds_from_url(dds_name)

if opts.drop_bands is not None:
ddso = []
Expand Down
16 changes: 4 additions & 12 deletions pfb/workers/sara.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def sara(**kw):

basename = opts.output_filename
fits_oname = f'{opts.fits_output_folder}/{oname}'
dds_store = DaskMSStore(f'{basename}_{opts.suffix}.dds')
dds_name = f'{basename}_{opts.suffix}.dds'

with ExitStack() as stack:
ti = time.time()
_sara(**opts)

dds, dds_list = xds_from_url(dds_store.url)
dds, dds_list = xds_from_url(dds_name)

if opts.fits_mfs or opts.fits:
from pfb.utils.fits import dds2fits
Expand Down Expand Up @@ -138,11 +138,7 @@ def _sara(**kw):
fits_oname = basename

dds_name = f'{basename}_{opts.suffix}.dds'
dds_store = DaskMSStore(dds_name)
dds_list = dds_store.fs.glob(f'{dds_store.url}/*.zarr')
dds = xds_from_list(dds_list,
drop_vars=['UVW', 'WEIGHT', 'MASK'],
nthreads=opts.nthreads)
dds, dds_list = xds_from_url(dds_name)

nx, ny = dds[0].x.size, dds[0].y.size
nx_psf, ny_psf = dds[0].x_psf.size, dds[0].y_psf.size
Expand All @@ -159,11 +155,7 @@ def _sara(**kw):

nband = freq_out.size

# only need this to get ny_psf
dds = [ds.drop_vars('PSF') for ds in dds]

# stitch dirty/psf in apparent scale
# drop_vars to avoid duplicates in memory
# drop_vars after access to avoid duplicates in memory
# and avoid unintentional side effects?
output_type = dds[0].DIRTY.dtype
if 'RESIDUAL' in dds[0]:
Expand Down
4 changes: 2 additions & 2 deletions pfb/workers/spotless.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def spotless(**kw):
xds_store = DaskMSStore(xds_name)
opts.xds = xds_name
fits_oname = f'{opts.fits_output_folder}/{oname}'
dds_store = DaskMSStore(f'{basename}_{opts.suffix}.dds')
dds_name = f'{basename}_{opts.suffix}.dds'

OmegaConf.set_struct(opts, True)

Expand Down Expand Up @@ -81,7 +81,7 @@ def spotless(**kw):
ti = time.time()
_spotless(**opts)

dds_list = dds_store.fs.glob(f'{dds_store.url}/*.zarr')
dds, dds_list = xds_from_url(dds_name)

# convert to fits files
futures = []
Expand Down

0 comments on commit f4b3b70

Please sign in to comment.