Skip to content

Commit

Permalink
change clean -> klean and fluxmop -> fluxmop
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Apr 23, 2024
1 parent 68f283a commit fbee30d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions pfb/parser/uncabbedcabs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ pfb.degrid:
_include:
- (.)degrid.yaml

pfb.clean:
command: pfb.workers.clean.clean
pfb.klean:
command: pfb.workers.klean.klean
flavour: python
policies:
pass_missing_as_none: true

_include:
- (.)clean.yaml
- (.)klean.yaml

pfb.restore:
command: pfb.workers.restore.restore
Expand All @@ -52,14 +52,14 @@ pfb.fwdbwd:
_include:
- (.)fwdbwd.yaml

pfb.forward:
command: pfb.workers.forward.forward
pfb.fluxmop:
command: pfb.workers.fluxmop.fluxmop
flavour: python
policies:
pass_missing_as_none: true

_include:
- (.)forward.yaml
- (.)fluxmop.yaml

pfb.spotless:
command: pfb.workers.spotless.spotless
Expand Down
16 changes: 8 additions & 8 deletions pfb/workers/forward.py → pfb/workers/fluxmop.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
from omegaconf import OmegaConf
import pyscilog
pyscilog.init('pfb')
log = pyscilog.get_logger('FORWARD')
log = pyscilog.get_logger('FLUXMOP')

from scabha.schema_utils import clickify_parameters
from pfb.parser.schemas import schema

# create default parameters from schema
defaults = {}
for key in schema.forward["inputs"].keys():
defaults[key.replace("-", "_")] = schema.forward["inputs"][key]["default"]
for key in schema.fluxmop["inputs"].keys():
defaults[key.replace("-", "_")] = schema.fluxmop["inputs"][key]["default"]

@cli.command(context_settings={'show_default': True})
@clickify_parameters(schema.forward)
def forward(**kw):
@clickify_parameters(schema.fluxmop)
def fluxmop(**kw):
'''
Forward step aka flux mop.
Expand Down Expand Up @@ -59,7 +59,7 @@ def forward(**kw):
opts = OmegaConf.create(defaults)
import time
timestamp = time.strftime("%Y%m%d-%H%M%S")
pyscilog.log_to_file(f'forward_{timestamp}.log')
pyscilog.log_to_file(f'fluxmop_{timestamp}.log')

if opts.nworkers is None:
if opts.scheduler=='distributed':
Expand All @@ -78,9 +78,9 @@ def forward(**kw):
for key in opts.keys():
print(' %25s = %s' % (key, opts[key]), file=log)

return _forward(**opts)
return _fluxmop(**opts)

def _forward(**kw):
def _fluxmop(**kw):
opts = OmegaConf.create(kw)
OmegaConf.set_struct(opts, True)

Expand Down
16 changes: 8 additions & 8 deletions pfb/workers/clean.py → pfb/workers/klean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
from omegaconf import OmegaConf
import pyscilog
pyscilog.init('pfb')
log = pyscilog.get_logger('CLEAN')
log = pyscilog.get_logger('KLEAN')

from scabha.schema_utils import clickify_parameters
from pfb.parser.schemas import schema

# create default parameters from schema
defaults = {}
for key in schema.clean["inputs"].keys():
defaults[key.replace("-", "_")] = schema.clean["inputs"][key]["default"]
for key in schema.klean["inputs"].keys():
defaults[key.replace("-", "_")] = schema.klean["inputs"][key]["default"]

@cli.command(context_settings={'show_default': True})
@clickify_parameters(schema.clean)
def clean(**kw):
@clickify_parameters(schema.klean)
def klean(**kw):
'''
Modified single-scale clean.
'''
defaults.update(kw)
opts = OmegaConf.create(defaults)
import time
timestamp = time.strftime("%Y%m%d-%H%M%S")
pyscilog.log_to_file(f'clean_{timestamp}.log')
pyscilog.log_to_file(f'klean_{timestamp}.log')

if opts.nworkers is None:
if opts.scheduler=='distributed':
Expand All @@ -46,10 +46,10 @@ def clean(**kw):
for key in opts.keys():
print(' %25s = %s' % (key, opts[key]), file=log)

return _clean(**opts)
return _klean(**opts)


def _clean(ddsi=None, **kw):
def _klean(ddsi=None, **kw):
opts = OmegaConf.create(kw)
# always combine over ds during cleaning
opts['mean_ds'] = True
Expand Down
4 changes: 2 additions & 2 deletions pfb/workers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def cli():


from pfb.workers import (init, grid, degrid,
clean, restore, fwdbwd,
klean, restore, fwdbwd,
spotless, model2comps,
forward, fastim, smoovie)
fluxmop, fastim, smoovie)
48 changes: 24 additions & 24 deletions tests/test_clean.py → tests/test_klean.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pmp = pytest.mark.parametrize

@pmp('do_gains', (True, False))
def test_clean(do_gains, ms_name):
def test_klean(do_gains, ms_name):
'''
Here we test that clean correctly infers the fluxes of point sources
placed at the centers of pixels in the presence of the wterm and DI gain
Expand Down Expand Up @@ -215,30 +215,30 @@ def test_clean(do_gains, ms_name):
from pfb.workers.grid import _grid
dds = _grid(xdsi=xds, **grid_args)

# run clean
clean_args = {}
for key in schema.clean["inputs"].keys():
clean_args[key.replace("-", "_")] = schema.clean["inputs"][key]["default"]
clean_args["output_filename"] = outname
clean_args["postfix"] = postfix
clean_args["nband"] = nchan
clean_args["dirosion"] = 0
clean_args["do_residual"] = False
clean_args["nmiter"] = 100
# run klean
klean_args = {}
for key in schema.klean["inputs"].keys():
klean_args[key.replace("-", "_")] = schema.klean["inputs"][key]["default"]
klean_args["output_filename"] = outname
klean_args["postfix"] = postfix
klean_args["nband"] = nchan
klean_args["dirosion"] = 0
klean_args["do_residual"] = False
klean_args["nmiter"] = 100
threshold = 1e-5
clean_args["threshold"] = threshold
clean_args["gamma"] = 0.1
clean_args["peak_factor"] = 0.75
clean_args["sub_peak_factor"] = 0.75
clean_args["nthreads"] = 8
clean_args["nvthreads"] = 8
clean_args["scheduler"] = 'sync'
clean_args["do_wgridding"] = True
clean_args["epsilon"] = epsilon
clean_args["mop_flux"] = True
clean_args["fits_mfs"] = False
from pfb.workers.clean import _clean
_clean(ddsi=dds, **clean_args)
klean_args["threshold"] = threshold
klean_args["gamma"] = 0.1
klean_args["peak_factor"] = 0.75
klean_args["sub_peak_factor"] = 0.75
klean_args["nthreads"] = 8
klean_args["nvthreads"] = 8
klean_args["scheduler"] = 'sync'
klean_args["do_wgridding"] = True
klean_args["epsilon"] = epsilon
klean_args["mop_flux"] = True
klean_args["fits_mfs"] = False
from pfb.workers.klean import _klean
_klean(ddsi=dds, **klean_args)

# get inferred model
basename = f'{outname}_I'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_spotless.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_spotless(ms_name):
writes = xds_to_zarr(dds, dds_name, columns='ALL')
dask.compute(writes)

# run clean
# run spotless
spotless_args = {}
for key in schema.spotless["inputs"].keys():
spotless_args[key.replace("-", "_")] = schema.spotless["inputs"][key]["default"]
Expand Down

0 comments on commit fbee30d

Please sign in to comment.