Skip to content

Commit 84bb232

Browse files
committed
Add sanity checks for masked data
1 parent faa15e2 commit 84bb232

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

racs_tools/convolve_uv.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,29 @@ def convolve(
152152
ConvolutionResult: convolved image, scaling factor
153153
"""
154154

155+
### These values aren't used in convolution, but are needed for santiy checks
156+
conbeam, sfactor = get_convolving_beam(
157+
old_beam=old_beam,
158+
new_beam=new_beam,
159+
dx=dx,
160+
dy=dy,
161+
cutoff=cutoff,
162+
)
163+
if np.isnan(sfactor):
164+
logger.warning("Beam larger than cutoff -- blanking")
165+
newim = np.ones_like(image) * np.nan
166+
return ConvolutionResult(newim, sfactor)
167+
if conbeam is None:
168+
conbeam = new_beam.deconvolve(old_beam)
169+
if np.isnan(conbeam):
170+
return ConvolutionResult(image * np.nan, sfactor)
171+
if np.isnan(image).all():
172+
return ConvolutionResult(image, sfactor)
173+
if conbeam == Beam(major=0 * u.deg, minor=0 * u.deg, pa=0 * u.deg) and sfactor == 1:
174+
return ConvolutionResult(image, sfactor)
175+
###
176+
177+
# Now we do the convolution
155178
nanflag = np.isnan(image).any()
156179

157180
if nanflag:

0 commit comments

Comments
 (0)