不同望远镜观测的分辨率会有比较大的区别,如果需要平滑到同一个分辨率可以参考一下代码
from astropy.convolution import convolve, Gaussian2DKernel
#平滑自定义函数
def smooth(data_in, hpbw_o, hpbw_n, grid):
"""
smoothing, all angles are in arcmin
"""
if hpbw_n < hpbw_o:
print("New beam less than the old one, no smoothing!")
sys.exit()
else:
hpbw=np.sqrt(hpbw_n*hpbw_n-hpbw_o*hpbw_o) # in arcmin
g = Gaussian2DKernel(hpbw/(2.*np.sqrt(2.*np.log(2.)))/grid)
data_out = convolve(data_in, g, boundary='extend')
return data_out
#代码正文
hdr = pf.getheader('1.fits')
data = pf.getdata('1.fits')
grid = abs(hdr['CDELT1'])*60. #把间隔从度变成角分,统一单位
hpbw_o = 3 #初始分辨率3角分
hpbw_n = 4 #平滑的目标分辨率4角分(注意只能从高分辨率平滑到低分辨率)
print(grid_I, hpbw_n, hpbw_o) #检查一下
data_I_sm = smooth(data_I, hpbw_o, hpbw_n, grid)
hdr_I['HBPW'] = hpbw_n / 60. #头文件的分辨率记录一下
pf.writeto('2.fits', data_I_sm, hdr_I, overwrite=True)