agpy 0.1 documentation

Image Tools

drizzle Module

AG_image_tools.drizzle.drizzle(tstomap, ts, mapshape, weights=1, weightmap=None)[source]

Drizzle a timestream onto a map. Returns the map of the weighted average per pixel of the input timestream. (note that this works for any 1D array with a same-size mapping to an image; I’ve written it with timestreams in mind though)

tstomap - mapping from timestream -> map. len(tstomap) = len(ts)
Both tstomap and ts should be one-dimensional, but they’ll be raveled if you don’t do it yourself
weights - needs to have the same dimensions as ts or be scalar
(default=1)
mapshape - [nx,ny] simple 2D map specification. Make sure your map
includes all points mapped to

You can specify a weightmap to increase efficiency instead of computing it

AG_image_tools.drizzle.masktozero(arr)[source]

Convert all NANs or masked elements of an array to zero, and return a numpy array (NOT a masked array).

radialprofile Module

AG_image_tools.radialprofile.azimuthalAverage(image, center=None, stddev=False, returnradii=False, return_nr=False, binsize=0.5, weights=None, steps=False, interpnan=False, left=None, right=None, mask=None)[source]

Calculate the azimuthally averaged radial profile.

image - The 2D image center - The [x,y] pixel coordinates used as the center. The default is

None, which then uses the center of the image (including fractional pixels).

stddev - if specified, return the azimuthal standard deviation instead of the average returnradii - if specified, return (radii_array,radial_profile) return_nr - if specified, return number of pixels per radius and radius binsize - size of the averaging bin. Can lead to strange results if

non-binsize factors are used to specify the center and the binsize is too large
weights - can do a weighted average instead of a simple average if this keyword parameter
is set. weights.shape must = image.shape. weighted stddev is undefined, so don’t set weights and stddev.
steps - if specified, will return a double-length bin array and radial
profile so you can plot a step-form radial profile (which more accurately represents what’s going on)
interpnan - Interpolate over NAN values, i.e. bins where there is no data?
left,right - passed to interpnan; they set the extrapolated values
mask - can supply a mask (boolean array same size as image with True for OK and False for not)
to average over only select data.

If a bin contains NO DATA, it will have a NAN value because of the divide-by-sum-of-weights component. I think this is a useful way to denote lack of data, but users let me know if an alternative is prefered...

AG_image_tools.radialprofile.azimuthalAverageBins(image, azbins, symmetric=None, center=None, **kwargs)[source]

Compute the azimuthal average over a limited range of angles kwargs are passed to azimuthalAverage

AG_image_tools.radialprofile.radialAverage(image, center=None, stddev=False, returnAz=False, return_naz=False, binsize=1.0, weights=None, steps=False, interpnan=False, left=None, right=None, mask=None, symmetric=None)[source]

Calculate the radially averaged azimuthal profile. (this code has not been optimized; it could be speed boosted by ~20x)

image - The 2D image center - The [x,y] pixel coordinates used as the center. The default is

None, which then uses the center of the image (including fractional pixels).

stddev - if specified, return the radial standard deviation instead of the average returnAz - if specified, return (azimuthArray,azimuthal_profile) return_naz - if specified, return number of pixels per azimuth and azimuth binsize - size of the averaging bin. Can lead to strange results if

non-binsize factors are used to specify the center and the binsize is too large
weights - can do a weighted average instead of a simple average if this keyword parameter
is set. weights.shape must = image.shape. weighted stddev is undefined, so don’t set weights and stddev.
steps - if specified, will return a double-length bin array and azimuthal
profile so you can plot a step-form azimuthal profile (which more accurately represents what’s going on)
interpnan - Interpolate over NAN values, i.e. bins where there is no data?
left,right - passed to interpnan; they set the extrapolated values
mask - can supply a mask (boolean array same size as image with True for OK and False for not)
to average over only select data.

If a bin contains NO DATA, it will have a NAN value because of the divide-by-sum-of-weights component. I think this is a useful way to denote lack of data, but users let me know if an alternative is prefered...

AG_image_tools.radialprofile.radialAverageBins(image, radbins, corners=True, center=None, **kwargs)[source]

Compute the radial average over a limited range of radii