Radial profiles (wcc_etc.radial_data)

Radial profile of a 2-D image.

Adapted from radial_data() by Ian Crossfield (2005-11-04, Jet Propulsion Laboratory), distributed in his public Python astronomy library. Redistributed with attribution; the original carried no explicit license. Local changes are limited to numpy/scipy API updates. See DATA_SOURCES.md.

wcc_etc.radial_data.radial_data(data, annulus_width=1, working_mask=None, x=None, y=None, rmax=None)[source]

r = radial_data(data,annulus_width,working_mask,x,y)

A function to reduce an image to a radial cross-section.

INPUT:
data - whatever data you are radially averaging. Data is

binned into a series of annuli of width ‘annulus_width’ pixels.

annulus_width - width of each annulus. Default is 1.

working_mask - array of same size as ‘data’, with zeros at

whichever ‘data’ points you don’t want included in the radial data computations.

x,y - coordinate system in which the data exists (used to set

the center of the data). By default, these are set to integer meshgrids

rmax – maximum radial value over which to compute statistics

OUTPUT:
r - a data structure containing the following

statistics, computed across each annulus:

.r - the radial coordinate used (outer edge of annulus)

.mean - mean of the data in the annulus

.sum - the sum of all enclosed values at the given radius

.std - standard deviation of the data in the annulus

.median - median value in the annulus

.max - maximum value in the annulus

.min - minimum value in the annulus

.numel - number of elements in the annulus

EXAMPLE:
import numpy as np
import pylab as py
import radial_data as rad

# Create coordinate grid
npix = 50.
x = np.arange(npix) - npix/2.
xx, yy = np.meshgrid(x, x)
r = np.sqrt(xx**2 + yy**2)
fake_psf = np.exp(-(r/5.)**2)
noise = 0.1 * np.random.normal(0, 1, r.size).reshape(r.shape)
simulation = fake_psf + noise

rad_stats = rad.radial_data(simulation, x=xx, y=yy)

py.figure()
py.plot(rad_stats.r, rad_stats.mean / rad_stats.std)
py.xlabel('Radial coordinate')
py.ylabel('Signal to Noise')
wcc_etc.radial_data.calc_ee(df_data_r, hwhm, K, verbose=True, endpoint=3.0)[source]

Calculate the encircled energy for a dataframe:

INPUT:
  • df_data_r with columns: [“r”,”mean”]

  • hwhm - in pixels

  • K - factor of hwhm to calculate EE

OUTPUT:
  • EE