exosim.utils.aperture#

Attributes#

Functions#

find_rectangular_aperture(ima, desired_ene[, center, ...])

Estimates the smallest rectangular aperture to collect the desired Encircled Energy from a PSF.

find_elliptical_aperture(ima, desired_ene[, center])

Estimates the smallest elliptical aperture to collect the desired Encircled Energy from a PSF.

find_bin_aperture(ima, desired_ene, spatial_with[, center])

Estimates the smallest rectangular aperture for spectral bin of already fixed spatial size

Module Contents#

logger[source]#
find_rectangular_aperture(ima, desired_ene, center=None, start_h=None, start_w=None)[source]#

Estimates the smallest rectangular aperture to collect the desired Encircled Energy from a PSF. It uses photutils.aperture.aperture_photometry.

Parameters:
  • ima (ndarray) – two-dimensional array.

  • desired_ene (float) – desired Encircled Energy

  • center ((float, float)) – spectral and spatial coordinates of the aperture center in pixels. If None the center of the array is used. Default is None

  • start_h (int) – starting aperture height

  • start_w (int) – starting aperture width

Returns:

  • (float, float) – sizes of the rectangular aperture (h,w)

  • float – number of pixels in the aperture

  • float – encircled energy collected by the aperture

Example

In this example we find the optimal aperture containing the 85% of the energy of a PSF.

>>> import matplotlib.pyplot as plt
>>> import astropy.units as u
>>> import photutils
>>> from exosim.utils.aperture import find_rectangular_aperture
>>> from exosim.utils.psf import create_psf
>>>
>>> img = create_psf(1*u.um, (60,40), 6*u.um)
>>> size, area, ene = find_rectangular_aperture(img, 0.85)
>>> positions = [(img.shape[1]//2,img.shape[0]//2)]
>>> aperture = photutils.aperture.RectangularAperture(positions, size[0], size[1])
>>>
>>> plt.imshow(img)
>>> aperture.plot(color='r', lw=2,)
>>> plt.show()
../../../../_images/find_rectangular_aperture.png
find_elliptical_aperture(ima, desired_ene, center=None)[source]#

Estimates the smallest elliptical aperture to collect the desired Encircled Energy from a PSF. It uses photutils.aperture.aperture_photometry.

Parameters:
  • ima (ndarray) – two-dimensional array.

  • desired_ene (float) – desired Encircled Energy

  • center ((float, float)) – spectral and spatial coordinates of the aperture center in pixels. If None the center of the array is used. Default is None

Returns:

  • (float, float) – sizes of the elliptical aperture (h,w)

  • float – number of pixels in the aperture

  • float – encircled energy collected by the aperture

Example

In this example we find the optimal aperture containing the 85% of the energy of a PSF.

>>> import matplotlib.pyplot as plt
>>> import astropy.units as u
>>> import photutils
>>> from exosim.utils.psf import find_elliptical_aperture
>>> from exosim.utils.psf import create_psf
>>>
>>> img = create_psf(1*u.um, (60,40), 6*u.um)
>>> size, area, ene = find_elliptical_aperture(img, 0.85)
>>> positions = [(img.shape[1]//2,img.shape[0]//2)]
>>> aperture = photutils.aperture.EllipticalAperture(positions, size[0], size[1])
>>>
>>> plt.imshow(img)
>>> aperture.plot(color='r', lw=2,)
>>> plt.show()
../../../../_images/find_elliptical_aperture.png
find_bin_aperture(ima, desired_ene, spatial_with, center=None)[source]#

Estimates the smallest rectangular aperture for spectral bin of already fixed spatial size to collect the desired Encircled Energy from a PSF. It uses photutils.aperture.aperture_photometry.

Parameters:
  • ima (ndarray) – two-dimensional array.

  • spatial_with (float) – fixed bin spatial size

  • desired_ene (float) – desired Encircled Energy

  • center ((float, float)) – spectral and spatial coordinates of the aperture center in pixels. If None the center of the array is used. Default is None

Returns:

  • float – spectral size of the rectangular aperture

  • float – number of pixels in the aperture

  • float – encircled energy collected by the aperture