@@ -76,6 +76,55 @@ def make_2d_image(tmpdir) -> TestImage:
7676    outf .unlink ()
7777
7878
79+ @pytest .fixture  
80+ def  make_2d_image_smaller (tmpdir ) ->  TestImage :
81+     """Make a fake 2D image from with a Gaussian beam. 
82+ 
83+     Args: 
84+         beam (Beam): Gaussian beam. 
85+ 
86+     Returns: 
87+         str: Name of the output FITS file. 
88+     """ 
89+     pix_scale  =  2.5  *  u .arcsec 
90+ 
91+     beam  =  Beam (10  *  u .arcsec , 10  *  u .arcsec , 10  *  u .deg )
92+ 
93+     data  =  beam .as_kernel (pixscale = pix_scale , x_size = 100 , y_size = 100 ).array 
94+     data  /=  data .max ()
95+ 
96+     hdu  =  fits .PrimaryHDU (data = data )
97+ 
98+     hdu .header  =  beam .attach_to_header (hdu .header )
99+     hdu .header ["BUNIT" ] =  "Jy/beam" 
100+     hdu .header ["CDELT1" ] =  - pix_scale .to (u .deg ).value 
101+     hdu .header ["CDELT2" ] =  pix_scale .to (u .deg ).value 
102+     hdu .header ["CRPIX1" ] =  50 
103+     hdu .header ["CRPIX2" ] =  50 
104+     hdu .header ["CRVAL1" ] =  0 
105+     hdu .header ["CRVAL2" ] =  0 
106+     hdu .header ["CTYPE1" ] =  "RA---SIN" 
107+     hdu .header ["CTYPE2" ] =  "DEC--SIN" 
108+     hdu .header ["CUNIT1" ] =  "deg" 
109+     hdu .header ["CUNIT2" ] =  "deg" 
110+     hdu .header ["EQUINOX" ] =  2000.0 
111+     hdu .header ["RADESYS" ] =  "FK5" 
112+     hdu .header ["LONPOLE" ] =  180.0 
113+     hdu .header ["LATPOLE" ] =  0.0 
114+ 
115+     outf  =  Path (tmpdir ) /  "2d_smaller.fits" 
116+     hdu .writeto (outf , overwrite = True )
117+ 
118+     yield  TestImage (
119+         path = outf ,
120+         beam = beam ,
121+         data = data ,
122+         pix_scale = pix_scale ,
123+     )
124+ 
125+     outf .unlink ()
126+ 
127+ 
79128@pytest .fixture  
80129def  mirsmooth (make_2d_image : TestImage ) ->  TestImage :
81130    """Smooth a FITS image to a target beam using MIRIAD. 
@@ -219,3 +268,14 @@ def test_smooth(make_2d_image: TestImage, mirsmooth: TestImage):
219268        assert  np .allclose (
220269            smooth_data , mirsmooth .data , atol = 1e-5 
221270        ), f"Smooth with { conv_mode }  
271+ 
272+ 
273+ def  test_get_common_beam (make_2d_image , make_2d_image_smaller ):
274+     common_beam  =  beamcon_2D .smooth_fits_files (
275+         infile_list = [make_2d_image .path , make_2d_image_smaller .path ],
276+         cutoff = 10 ,
277+     )
278+     assert  (
279+         common_beam .major .to (u .arcsec ).value 
280+         ==  make_2d_image_smaller .beam .major .to (u .arcsec ).value 
281+     )
0 commit comments