Gaussian2D#
- class prose.blocks.psf.Gaussian2D(**kwargs)#
Fit an elliptical 2D Gaussian model to an image effective PSF
To be used after a PSF building block
read
Image.psfwrite
Image.psf_models_paramsImage.psf_modelImage.fwhmxImage.fwhmImage.psf_model_block
PSF model is
\[f(x, y|A, x_0, y_0, \sigma_x, \sigma_y, \theta, b) = - A \exp\left(\frac{(x'-x'_0)^2}{2\sigma_x^2} \frac{(y'-y'_0)^2}{2\sigma_y^2}\right) + b\]\[\begin{split}\text{with}\quad \begin{gather*} x' = xcos(\theta) + ysin(\theta) \\ y' = -xsin(\theta) + ycos(\theta) \end{gather*}\end{split}\]is fitted from an effective psf.
scipy.optimize.minimizeis used to minimize \(\chi ^2\) from data. Initial parameters are found using the moments of the effective psf. This method is 4 times faster thanphotutils.centroids.fit_2dgaussianand lead to similar results.Example
We start by loading an example image and buidling its median psf
from prose import blocks, Sequence from prose.tutorials import example_image # our example image image = example_image() # Sequence to build image PSF sequence = Sequence([ blocks.SegmentedPeaks(), # stars detection blocks.Cutouts(), blocks.MedianPSF(), # building PSF ]) sequence.run([image])
[38;5;12mINFO[0m telescope A not found - using default
[38;5;12mINFO[0m telescope A not found - using default
We can now apply the Gaussian2D block to the image in order to model its PSF
import matplotlib.pyplot as plt block = blocks.psf.Gaussian2D() image = block(image)
[38;5;12mINFO[0m telescope A not found - using default
and vizualise the result
from prose import viz print(f"model: {image.psf_model_block}") print("fwhmx, fwhmy, theta: " + ", ".join([f"{p:.2f}" for p in block.fwhm(image.psf_models_params)])) plt.figure(figsize=(12, 5)) plt.subplot(131) plt.imshow(image.psf) plt.title("PSF") plt.subplot(132) plt.imshow(image.psf_model) plt.title(f"PSF model ({image.psf_model_block})") plt.subplot(133) residuals = image.psf - image.psf_model ax = plt.imshow(residuals) plt.title("residuals") viz.add_colorbar(ax) plt.tight_layout()
model: Gaussian2D fwhmx, fwhmy, theta: 3.78, 3.61, -1.02