你说“从中提取PSF”是什么意思?你想找到它的位置吗?你想在它周围切一个盒子吗?你到底想用它做什么?在
假设您有一个图像image.fits,那么您可以使用astropy.modeling来拟合PSF,在计算出它在所提供图像中的中心位置之后,就可以使用astropy.modeling来拟合PSF。在import numpy as np
import matplotlib.pyplot as plt
from astropy.modeling import models, fitting
from astropy.io import fits
# Load the data and find center of PSF
image = fits.getdata('path/image.fits')
cents = np.where(image == np.max(image))
xc = int(cents[1])
yc = int(cents[0])
# Cut out smaller box around PSF
bb = 30
box = image[yc-bb:yc+bb,xc-bb:xc+bb]
yp, xp = box.shape
# Generate grid of same size like box to put the fit on
y, x, = np.mgrid[:yp, :xp]
# Declare what function you want to fit to your data
f_init = models.Gaussian2D()