Skip to content

Commit 8dc2b29

Browse files
committed
Add mask
1 parent 84bb232 commit 8dc2b29

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

racs_tools/beamcon_3D.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def smooth_plane(
221221
dx: u.Quantity,
222222
dy: u.Quantity,
223223
conv_mode: Literal["robust", "scipy", "astropy", "astropy_fft"] = "robust",
224+
mask: bool = False,
224225
) -> np.ndarray:
225226
"""Smooth a single plane of a cube.
226227
@@ -232,6 +233,7 @@ def smooth_plane(
232233
dx (u.Quantity): Pixel size in x direction.
233234
dy (u.Quantity): Pixel size in y direction.
234235
conv_mode (Literal["robust", "scipy", "astropy", "astropy_fft"], optional): Convolution mode. Defaults to "robust".
236+
mask (bool, optional): Mask the channel. Defaults to False.
235237
236238
Returns:
237239
np.ndarray: Convolved plane.
@@ -248,14 +250,19 @@ def smooth_plane(
248250

249251
plane = cube.unmasked_data[slicer].value.astype(np.float32)
250252
logger.debug(f"Size of plane is {(plane.nbytes*u.byte).to(u.MB)}")
251-
newim = smooth(
252-
image=plane,
253-
old_beam=old_beam,
254-
new_beam=new_beam,
255-
dx=dx,
256-
dy=dy,
257-
conv_mode=conv_mode,
258-
)
253+
254+
if mask:
255+
logger.info(f"Masking channel {idx}")
256+
newim = plane * np.nan
257+
else:
258+
newim = smooth(
259+
image=plane,
260+
old_beam=old_beam,
261+
new_beam=new_beam,
262+
dx=dx,
263+
dy=dy,
264+
conv_mode=conv_mode,
265+
)
259266
del plane
260267
return newim
261268

@@ -887,6 +894,7 @@ def smooth_and_write_plane(
887894
dx=cube_data.dx,
888895
dy=cube_data.dy,
889896
conv_mode=conv_mode,
897+
mask=cube_data.mask[chan],
890898
)
891899

892900
with fits.open(outfile, mode="update", memmap=True) as outfh:

0 commit comments

Comments
 (0)