Skip to main content

Various utilities for computing things with information contained in Numpy arrays.

You can find code and dowloads at the Launchpad page or the PyPI page

http://launchpad.net/gsn-numpy-util

http://pypi.python.org/pypi/gsn_numpy_util

Installation

Any of the standard incantations works:

  • pip gsn_numpy_util

  • easy_install gsn_numpy_util

  • python setup.py install

Dependencies:

Recommended:

Optional:

Usage

The 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 nu

numpy_util.py

All 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.py

Calculate 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 momentum

  • shape of particle distributions calculated by diagonalizing moment of inertia tensor

  • shape of particle distributions by minimizing dipole and quadrupole moments of distribution

  • Calculation of higher order (octupole, etc) Fourier coefficients

  • mass profile, density profile, velocity dispersion profile

  • find center of particle dist by various algorithms

  • implementations of friend-of-friends (transitive closure) algorithms

  • find particle groups via bound-density-maximum algorithm from Anatoly Klypin

  • Coordinate transformations spherical, cylindrical,

  • binning particles into grids in N dimensions

graph.py

Simple implementation of graphs and functions to compute a few properties.

Accessible via

>>> import gsn_numpy_util as nu
>>> nu.graph.dfs(graph)

Contents:

  • Graph class

  • Equivalence class class

  • Several implementations of transitive closure

  • breadth first search, depth first search

Tests

To run the tests:

python -m unittest gsn_numpy_util.test.test_numpy_util

python -m unittest gsn_numpy_util.test.test_particles

python -m unittest gsn_numpy_util.test.test_graph

License

The 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 at greg.novak@gmail.com

Metadata

Release files for gsn_numpy_util 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gsn_numpy_util 0.1.0
File Size Uploaded Provenance
gsn_numpy_util-0.1.0.tar.gz 56.2 kB Without provenance Details

Release files / gsn_numpy_util-0.1.0.tar.gz

Download URL gsn_numpy_util-0.1.0.tar.gz
Size 56.2 kB
Tags Source
SHA-256 checksum
How to use checksums
379738b7943547211851758de7db1c09594cdd97274b9717e05a27c2b7faf39d
BLAKE2b-256 checksum
How to use checksums
271d5bf5efe1b045b502a07343c263d071f7187f7253618472c63c34fad38da0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for gsn_numpy_util 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page