Package: gsn_numpy_util
Various utilities for computing things with information contained in
Numpy arrays.You can find code and dowloads at the Launchpad page or the PyPI pagehttp://launchpad.net/gsn-numpy-utilhttp://pypi.python.org/pypi/gsn_numpy_utilInstallationAny of the standard incantations works:pip gsn_numpy_utileasy_install gsn_numpy_utilpython setup.py installDependencies:numpy (http://www.numpy.org)gsn_util (http://pypi.python.org/pypi/gsn_util)Recommended:scipy (http://www.scipy.org)Optional:sersic (http://pypi.python.org/pypi/sersic)PyX (http://pyx.sourceforge.net/)UsageThe module name is rather verbose to avoid name clashes since many
people out there will have personal modules called numpy_util or
something similar.  When I use the package I always import it as:import gsn_numpy_util as nunumpy_util.pyAll of the symbols defined in numpy_util are imported into the
gsn_numpy_util module, so these symbols are accessible via:>>> import gsn_numpy_util as nu
>>> nu.y(2,1,pi/2, 3*pi/2)Contents:real and complex spherical harmonics (y, ry)functions to remove inf and nan from arrays (all_good, good_data,
clipOdd)fortran unformatted i/o (write_fortran, read_fortran,
read_fortran_inplace, skip_fortran)Making coordinate grids (grid_nd, make_grid)Binning particle positions in N dimensions (image, flattenMap,
unflattenMap, histo, histo2d, partition)Elaborations of Fourier transforms–sin transform, cosine transform,
etc. (power_spectrum, sine_transform, cosine_transform, fst, ifst,
fct, ifct transform_n, fstn, ifstn, fctn, ifctn, trig_freq, rdct,
irdct, rdst, irdst, dct, idct, dst, idst rdstfreq, rdctfreq)Poisson solver using various FFT-based methods (poisson,
poisson_fft, poisson_fst, poisson_fct, big_poisson, big_poisson_fft,
big_poisson_fst, big_poisson_fct)An implementation of large, disk-based arrays (BigArray) along with
transformations on those arrays (e.g. big_fftn)Properties of time-series information crossing a threshold
(seq_transitions, seq_transitions_idx, seq_length, seq_length_above,
seq_length_below)Averaging and rebinning arrays (rebin, ave, lave)vector calculus, (div, grad, curl, laplacian)bit and boolean arrays (boolmat, bitmat, boolarr, bitarr)Random deviates (randp, randlog)coordinate systems and transformations (cartesian, spherical,
graham_schmidt)Weighted mean, standard deviation, geometric mean, etc
(weighted_mean, weighted_std, geometric_mean, rms)Getting unique values and determining set membership with arrays.
Note that numpy has a setmember1d function, but years ago it got
confused with when there were duplicate elements in the array.
(unique1d, setmember1d)particles.pyCalculate properties of particle distributions.Accessible via>>> import gsn_numpy_util as nu
>>> nu.particles.ellipticity(rs, ms)Contents:basic transformations: rotations, affine transforms, etc.basic vector operations: magnitude, inner product, etc.properties of particle distributions: center of mass, angular
momentumshape of particle distributions calculated by diagonalizing moment
of inertia tensorshape of particle distributions by minimizing dipole and quadrupole
moments of distributionCalculation of higher order (octupole, etc) Fourier coefficientsmass profile, density profile, velocity dispersion profilefind center of particle dist by various algorithmsimplementations of friend-of-friends (transitive closure) algorithmsfind particle groups via bound-density-maximum algorithm from Anatoly KlypinCoordinate transformations spherical, cylindrical,binning particles into grids in N dimensionsgraph.pySimple implementation of graphs and functions to compute a few
properties.Accessible via>>> import gsn_numpy_util as nu
>>> nu.graph.dfs(graph)Contents:Graph classEquivalence class classSeveral implementations of transitive closurebreadth first search, depth first searchTestsTo run the tests:python -m unittest gsn_numpy_util.test.test_numpy_utilpython -m unittest gsn_numpy_util.test.test_particlespython -m unittest gsn_numpy_util.test.test_graphLicenseThe code is released under the MIT license, so you should be able to
do whatever you want with it.If you incorporate this code into a larger project, I would appreciate
it if you send me a note atgreg.novak@gmail.com