Skip to content

Commit 19c379b

Browse files
authored
Js plot scatter recon limits (#513)
* Write a test for simulating meerkat observation with noise, missing asserts * Load golden file and use temporary directories * Add asserts * plot_scatter_recon with appropriate cutting * Adjust input parameters of all plot_scatter_recon functions
1 parent 083ee11 commit 19c379b

3 files changed

Lines changed: 11 additions & 20 deletions

File tree

karabo/examples/HIIM_Img_Recovery.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@
308308
" outpath / \"test_line_emission.pdf\",\n",
309309
" header_dirty,\n",
310310
" f_min=3 * 10**-26,\n",
311-
" cut=3.0,\n",
312311
")"
313312
]
314313
},
@@ -355,7 +354,6 @@
355354
" beam_corrected,\n",
356355
" outpath / \"test_line_emission_beamcorrected.pdf\",\n",
357356
" header_dirty,\n",
358-
" cut=3.0,\n",
359357
")"
360358
]
361359
},

karabo/simulation/line_emission.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from karabo.simulation.visibility import Visibility
2828
from karabo.util._types import DirPathType, FilePathType, IntFloat, NPFloatLikeStrict
2929
from karabo.util.dask import DaskHandler
30+
from karabo.util.plotting_util import get_slices
3031

3132

3233
def polar_corrdinates_grid(
@@ -175,7 +176,6 @@ def plot_scatter_recon(
175176
vmin: IntFloat = 0,
176177
vmax: Optional[IntFloat] = None,
177178
f_min: Optional[IntFloat] = None,
178-
cut: Optional[IntFloat] = None,
179179
) -> None:
180180
"""
181181
Plotting the sky as a scatter plot and its reconstruction and saving it as a pdf.
@@ -187,18 +187,10 @@ def plot_scatter_recon(
187187
:param vmin: Minimum value of the colorbar.
188188
:param vmax: Maximum value of the colorbar.
189189
:param f_min: Minimal flux of the sources to be plotted in the scatter plot
190-
:param cut: Smaller FOV
191190
"""
192191

193192
wcs = WCS(header)
194-
slices = []
195-
for i in range(wcs.pixel_n_dim):
196-
if i == 0:
197-
slices.append("x")
198-
elif i == 1:
199-
slices.append("y")
200-
else:
201-
slices.append(0) # type: ignore [arg-type]
193+
slices = get_slices(wcs)
202194

203195
# Do only plot sources with a flux above f_min if f_min is not None
204196
if f_min is not None:
@@ -212,11 +204,14 @@ def plot_scatter_recon(
212204
scatter = ax1.scatter(sky[:, 0], sky[:, 1], c=sky[:, 2], vmin=0, s=10, cmap="jet")
213205
ax1.set_aspect("equal")
214206
plt.colorbar(scatter, ax=ax1, label="Flux [Jy]")
215-
if cut is not None:
216-
ra_deg = header["CRVAL1"]
217-
dec_deg = header["CRVAL2"]
218-
ax1.set_xlim((ra_deg - cut / 2, ra_deg + cut / 2))
219-
ax1.set_ylim((dec_deg - cut / 2, dec_deg + cut / 2))
207+
ra_deg = header["CRVAL1"]
208+
dec_deg = header["CRVAL2"]
209+
img_size_ra = header["NAXIS1"]
210+
img_size_dec = header["NAXIS2"]
211+
cut_ra = -header["CDELT1"] * float(img_size_ra)
212+
cut_dec = header["CDELT2"] * float(img_size_dec)
213+
ax1.set_xlim((ra_deg - cut_ra / 2, ra_deg + cut_ra / 2))
214+
ax1.set_ylim((dec_deg - cut_dec / 2, dec_deg + cut_dec / 2))
220215
ax1.set_xlabel("RA [deg]")
221216
ax1.set_ylabel("DEC [deg]")
222217
ax1.invert_xaxis()
@@ -449,7 +444,7 @@ def karabo_reconstruction(
449444
"Creation of a pdf with scatter plot and reconstructed image to ",
450445
str(outfile),
451446
)
452-
plot_scatter_recon(sky, dirty_image, f"{outfile}.pdf", header, cut=cut)
447+
plot_scatter_recon(sky, dirty_image, f"{outfile}.pdf", header)
453448

454449
if mosaic_pntg_file is not None:
455450
if verbose:

karabo/test/test_line_emission.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def test_line_emission_run(
226226
dirty_im,
227227
outpath / "test_line_emission.pdf",
228228
header_dirty,
229-
cut=cut,
230229
)
231230

232231
# Generate Gaussian primary beam for correction,
@@ -271,7 +270,6 @@ def test_line_emission_run(
271270
beam_corrected,
272271
outpath / "test_line_emission_beamcorrected.pdf",
273272
header_dirty,
274-
cut=cut,
275273
)
276274

277275
print("Finished")

0 commit comments

Comments
 (0)