Skip to content

Commit 5f16f6b

Browse files
committed
move phasecentre coordinate parsing to within WSclean wrapper
1 parent f50a736 commit 5f16f6b

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

dstools/cli/create_model.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
"--config",
4040
type=click.Choice(CONFIGS),
4141
default="6km",
42-
help="Array configuration, used to calculate image and pixel sizes if unspecified. ASKAP is equivalent to 6km.",
42+
help=(
43+
"Array configuration, used to calculate image and pixel sizes if unspecified. "
44+
"ASKAP is equivalent to 6km."
45+
),
4346
)
4447
@click.option(
4548
"-N",
@@ -163,7 +166,10 @@
163166
type=str,
164167
nargs=2,
165168
default=None,
166-
help="Coordinates of imaging phasecentre (provide as separate values, e.g. -p <RA> <DEC>).",
169+
help=(
170+
"Coordinates of imaging phasecentre. "
171+
"Provide as separate values (e.g. -p <RA> <DEC>) in decimal degrees or sexagesimal."
172+
),
167173
)
168174
@click.option(
169175
"--name",

dstools/cli/extract_ds.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@
3333
type=str,
3434
nargs=2,
3535
default=None,
36-
help="Coordinates of phasecentre at which to extract DS (provide as separate values, e.g. -p <RA> <DEC>).",
36+
help=(
37+
"Coordinates of phasecentre at which to extract DS "
38+
"(provide as separate values, e.g. -p <RA> <DEC>)."
39+
),
3740
)
3841
@click.option(
3942
"-P",
4043
"--primary-beam",
4144
type=Path,
4245
default=None,
43-
help="Path to primary beam image with which to correct flux scale. Must also provide phasecentre.",
46+
help=(
47+
"Path to primary beam image with which to correct flux scale. "
48+
" Must also provide phasecentre. Provide non-existent path to compute PB separately."
49+
),
4450
)
4551
@click.option(
4652
"-F",

dstools/imaging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from dstools.logger import parse_stdout_stderr
1818
from dstools.mask import beam_shape_erode, minimum_absolute_clip
1919
from dstools.ms import MeasurementSet
20+
from dstools.utils import parse_coordinates
2021

2122
logger = logging.getLogger(__name__)
2223

@@ -253,7 +254,8 @@ def _phasecentre_args(self):
253254
if self.phasecentre is None:
254255
return ""
255256

256-
ra, dec = self.phasecentre
257+
ra, dec = parse_coordinates(self.phasecentre).to_string("hmsdms").split()
258+
257259
return f"-shift {ra} {dec}"
258260

259261
@property

tests/test_imaging.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,30 @@ def test_wsclean_run_command_args(mocker, ms_path):
118118
assert "-parallel-deconvolution 100" in cmd
119119

120120

121+
@pytest.mark.parametrize(
122+
"phasecentre",
123+
[
124+
(281.2719, -63.9632),
125+
("281.2719", "-63.9632"),
126+
("18:45:05.256", "-63:57:47.520"),
127+
("18h45m05.256s", "-63d57m47.520s"),
128+
],
129+
)
130+
def test_wsclean_coordinate_parsing(phasecentre, mocker, ms_path):
121131
mocker.patch("subprocess.Popen")
122132
mocker.patch("dstools.imaging.parse_stdout_stderr")
123133

124134
wsclean = WSClean(
125135
imsize=500,
126136
cellsize="0.66asec",
137+
phasecentre=phasecentre,
127138
)
128139

129140
# Abstract version of MS object, only needs access to path attribute
130141
mock_ms = mocker.Mock(path=ms_path)
131142
cmd = wsclean.run(mock_ms, name="test")
132143

144+
assert "-shift 18h45m05.256s -63d57m47.52s" in cmd
133145

134146

135147
def test_wsclean_run_command_multiscale(mocker, ms_path):

0 commit comments

Comments
 (0)