|  | 
| 20 | 20 | from racs_tools import au2 | 
| 21 | 21 | from racs_tools.logging import logger | 
| 22 | 22 | 
 | 
|  | 23 | +ZERO_BEAM = Beam(0 * u.deg) | 
|  | 24 | +NAN_BEAM = Beam(np.nan * u.deg) | 
|  | 25 | + | 
| 23 | 26 | 
 | 
| 24 | 27 | class ConvolutionResult(NamedTuple): | 
| 25 | 28 |     """Result of convolution""" | 
| @@ -170,7 +173,7 @@ def convolve( | 
| 170 | 173 |         return ConvolutionResult(image * np.nan, sfactor) | 
| 171 | 174 |     if np.isnan(image).all(): | 
| 172 | 175 |         return ConvolutionResult(image, sfactor) | 
| 173 |  | -    if conbeam == Beam(major=0 * u.deg, minor=0 * u.deg, pa=0 * u.deg) and sfactor == 1: | 
|  | 176 | +    if conbeam == ZERO_BEAM and sfactor == 1: | 
| 174 | 177 |         return ConvolutionResult(image, sfactor) | 
| 175 | 178 |     ### | 
| 176 | 179 | 
 | 
| @@ -278,7 +281,7 @@ def convolve_scipy( | 
| 278 | 281 |         return ConvolutionResult(image * np.nan, sfactor) | 
| 279 | 282 |     if np.isnan(image).all(): | 
| 280 | 283 |         return ConvolutionResult(image, sfactor) | 
| 281 |  | -    if conbeam == Beam(major=0 * u.deg, minor=0 * u.deg, pa=0 * u.deg) and sfactor == 1: | 
|  | 284 | +    if conbeam == ZERO_BEAM and sfactor == 1: | 
| 282 | 285 |         return ConvolutionResult(image, sfactor) | 
| 283 | 286 | 
 | 
| 284 | 287 |     gauss_kern = conbeam.as_kernel(dy) | 
| @@ -326,7 +329,7 @@ def convolve_astropy( | 
| 326 | 329 |         return ConvolutionResult(image * np.nan, sfactor) | 
| 327 | 330 |     if np.isnan(image).all(): | 
| 328 | 331 |         return ConvolutionResult(image, sfactor) | 
| 329 |  | -    if conbeam == Beam(major=0 * u.deg, minor=0 * u.deg, pa=0 * u.deg) and sfactor == 1: | 
|  | 332 | +    if conbeam == ZERO_BEAM and sfactor == 1: | 
| 330 | 333 |         return ConvolutionResult(image, sfactor) | 
| 331 | 334 |     gauss_kern = conbeam.as_kernel(dy) | 
| 332 | 335 |     conbm1 = gauss_kern.array / gauss_kern.array.max() | 
| @@ -377,7 +380,7 @@ def convolve_astropy_fft( | 
| 377 | 380 |         return ConvolutionResult(image * np.nan, sfactor) | 
| 378 | 381 |     if np.isnan(image).all(): | 
| 379 | 382 |         return ConvolutionResult(image, sfactor) | 
| 380 |  | -    if conbeam == Beam(major=0 * u.deg, minor=0 * u.deg, pa=0 * u.deg) and sfactor == 1: | 
|  | 383 | +    if conbeam == ZERO_BEAM and sfactor == 1: | 
| 381 | 384 |         return ConvolutionResult(image, sfactor) | 
| 382 | 385 |     gauss_kern = conbeam.as_kernel(dy) | 
| 383 | 386 |     conbm1 = gauss_kern.array / gauss_kern.array.max() | 
| @@ -453,20 +456,12 @@ def get_convolving_beam( | 
| 453 | 456 | 
 | 
| 454 | 457 |     if cutoff is not None and old_beam.major.to(u.arcsec) > cutoff * u.arcsec: | 
| 455 | 458 |         return ( | 
| 456 |  | -            Beam( | 
| 457 |  | -                major=np.nan * u.deg, | 
| 458 |  | -                minor=np.nan * u.deg, | 
| 459 |  | -                pa=np.nan * u.deg, | 
| 460 |  | -            ), | 
|  | 459 | +            NAN_BEAM, | 
| 461 | 460 |             np.nan, | 
| 462 | 461 |         ) | 
| 463 | 462 | 
 | 
| 464 | 463 |     if new_beam == old_beam: | 
| 465 |  | -        conbm = Beam( | 
| 466 |  | -            major=0 * u.deg, | 
| 467 |  | -            minor=0 * u.deg, | 
| 468 |  | -            pa=0 * u.deg, | 
| 469 |  | -        ) | 
|  | 464 | +        conbm = ZERO_BEAM | 
| 470 | 465 |         fac = 1.0 | 
| 471 | 466 |         logger.warning( | 
| 472 | 467 |             f"New beam {new_beam!r} and old beam {old_beam!r} are the same. Won't attempt convolution." | 
|  | 
0 commit comments