Utility functions

pycasso.util

Created on Oct 25, 2012

@author: andre

pycasso.util.arrayAsRowMatrix(a, n)

TODO: Deprecated arrayAsRowMatrix(). Use pystarlight.util.StarlightUtils.arrayAsRowMatrix

pycasso.util.gen_rebin(a, e, bin_e, mean=True)

Rebinning function. Given the value array a, with generic positions e such that e.shape == a.shape, return the sum or the mean values of a inside the bins defined by bin_e.

Parameters :

a : array like

The array values to be rebinned.

e : array like

Generic positions of the values in a.

bin_e : array like

Bins of e to be used in the rebinning.

mean : boolean

Divide the sum by the number of points inside the bin. Defaults to True.

Returns :

a_e : array

An array of length len(bin_e)-1, containing the sum or mean values of a inside each bin.

Examples

TODO: Add examples for gen_rebin.

pycasso.util.getGenHalfRadius(X, r, r_max=None)

Evaluate radius where the cumulative value of X reaches half of its value.

Parameters :

X : array like

The property whose half radius will be evaluated.

r : array like

Radius associated to each value of X. Must be the same shape as X.

r_max : int

Integrate up to r_max. Defaults to np.max(r).

Returns :

HXR : float

The “half X radius.”

Examples

Find the radius containing half of the volume of a gaussian.

>>> import numpy as np
>>> xx, yy = np.indices((100, 100))
>>> x0, y0, A, a = 50.0, 50.0, 1.0, 20.0
>>> z = A * np.exp(-((xx-x0)**2 + (yy-y0)**2)/a**2)
>>> r = np.sqrt((xx - 50)**2 + (yy-50)**2)
>>> getGenHalfRadius(z, r)
16.786338066912215
pycasso.util.getAverageFilledImage(X, to_fill, r__yx, X__r, bin_r)

TODO: getAverageFilledImage documentation.

Table Of Contents

Previous topic

Full data access API

Next topic

Legacy API

This Page