Moffat2D#

class prose.blocks.psf.Moffat2D(**kwargs)#

Fit an elliptical 2D Moffat model to an image effective PSF

To be used after a PSF building block

read Image.psf

write

  • Image.psf_models_params

  • Image.psf_model

  • Image.fwhmx

  • Image.fwhm

  • Image.psf_model_block

PSF model is

\[f(x, y|A, x_0, y_0, \sigma_x, \sigma_y, \theta, \beta, b) = \frac{A}{\left(1 + \frac{x'-x'_0}{\sigma_x^2} + \frac{y'-y'_0}{\sigma_y^2}\right)^\beta} + 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.minimize is used to minimize \(\chi ^2\) from data. Initial parameters are found using the moments of the effective psf.

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])
INFO telescope A not found - using default
INFO telescope A not found - using default

We can now apply the Moffat2D block to the image in order to model its PSF

import matplotlib.pyplot as plt

block = blocks.psf.Moffat2D()
image = block(image)
INFO 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: Moffat2D
fwhmx, fwhmy, theta: 3.65, 3.48, 0.00
../../_images/prose.blocks.psf.Moffat2D_2_1.png