Skip to content

Commit

Permalink
fix multiple logo printing, rename klean -> kclean
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester committed Nov 12, 2024
1 parent ca12cb4 commit a0b8086
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
File renamed without changes.
6 changes: 3 additions & 3 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.klean:
command: pfb.workers.klean.klean
pfb.kclean:
command: pfb.workers.kclean.kclean
flavour: python
policies:
pass_missing_as_none: true

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

pfb.restore:
command: pfb.workers.restore.restore
Expand Down
14 changes: 7 additions & 7 deletions pfb/workers/klean.py → pfb/workers/kclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from omegaconf import OmegaConf
import pyscilog
pyscilog.init('pfb')
log = pyscilog.get_logger('KLEAN')
log = pyscilog.get_logger('kclean')

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


@cli.command(context_settings={'show_default': True})
@clickify_parameters(schema.klean)
def klean(**kw):
@clickify_parameters(schema.kclean)
def kclean(**kw):
'''
Modified single-scale clean.
'''
Expand All @@ -40,7 +40,7 @@ def klean(**kw):

import time
timestamp = time.strftime("%Y%m%d-%H%M%S")
logname = f'{str(opts.log_directory)}/klean_{timestamp}.log'
logname = f'{str(opts.log_directory)}/kclean_{timestamp}.log'
pyscilog.log_to_file(logname)
print(f'Logs will be written to {logname}', file=log)

Expand All @@ -59,7 +59,7 @@ def klean(**kw):

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

dds, dds_list = xds_from_url(dds_name)

Expand All @@ -84,7 +84,7 @@ def klean(**kw):
print(f"All done after {time.time() - ti}s", file=log)


def _klean(**kw):
def _kclean(**kw):
opts = OmegaConf.create(kw)
OmegaConf.set_struct(opts, True)

Expand Down Expand Up @@ -113,7 +113,7 @@ def _klean(**kw):
nx, ny = dds[0].x.size, dds[0].y.size
nx_psf, ny_psf = dds[0].x_psf.size, dds[0].y_psf.size
if nx_psf//2 < nx or ny_psf//2 < ny:
raise ValueError("klean currently assumes a double sized PSF")
raise ValueError("kclean currently assumes a double sized PSF")
lastsize = ny_psf
freq_out = []
time_out = []
Expand Down
4 changes: 2 additions & 2 deletions pfb/workers/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# flake8: noqa
import click
from pfb import logo
logo()

@click.group()
def cli():
logo()
pass


from pfb.workers import (init, grid, degrid, klean,
from pfb.workers import (init, grid, degrid, kclean,
restore, model2comps,
fluxtractor, hci, smoovie, sara)

Expand Down
40 changes: 20 additions & 20 deletions tests/test_klean.py → tests/test_kclean.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_klean(do_gains, ms_name):
def test_kclean(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 @@ -227,26 +227,26 @@ def test_klean(do_gains, ms_name):
from pfb.workers.grid import _grid
_grid(**grid_args)

# 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["dirosion"] = 0
klean_args["do_residual"] = False
klean_args["niter"] = 100
# run kclean
kclean_args = {}
for key in schema.kclean["inputs"].keys():
kclean_args[key.replace("-", "_")] = schema.kclean["inputs"][key]["default"]
kclean_args["output_filename"] = outname
kclean_args["dirosion"] = 0
kclean_args["do_residual"] = False
kclean_args["niter"] = 100
threshold = 1e-1
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"] = 1
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(**klean_args)
kclean_args["threshold"] = threshold
kclean_args["gamma"] = 0.1
kclean_args["peak_factor"] = 0.75
kclean_args["sub_peak_factor"] = 0.75
kclean_args["nthreads"] = 1
kclean_args["do_wgridding"] = True
kclean_args["epsilon"] = epsilon
kclean_args["mop_flux"] = True
kclean_args["fits_mfs"] = False
from pfb.workers.kclean import _kclean
_kclean(**kclean_args)

# get inferred model
dds, _ = xds_from_url(dds_name)
Expand Down

0 comments on commit a0b8086

Please sign in to comment.