¡@

Home 

python Programming Glossary: np.diff

These spectrum bands used to be judged by eye, how to do it programmatically?

http://stackoverflow.com/questions/10764569/these-spectrum-bands-used-to-be-judged-by-eye-how-to-do-it-programmatically

# From http stackoverflow.com a 9667121 188535 maxes np.diff np.sign np.diff xs 0 .nonzero 0 1 # Find which of these peaks.. stackoverflow.com a 9667121 188535 maxes np.diff np.sign np.diff xs 0 .nonzero 0 1 # Find which of these peaks is closest to.. change in first diff technique as above hm_left_indices np.diff np.sign np.diff np.abs xs index_of_peak half_max 0 .nonzero..

Matplotlib: How to colorize a large number of line segments as independent gradients, efficiently

http://stackoverflow.com/questions/13622909/matplotlib-how-to-colorize-a-large-number-of-line-segments-as-independent-gradi

into individual segments. x y data.T dist np.hypot np.diff x x.min np.diff y y.min .cumsum t np.r_ 0 dist dist.max ti np.linspace.. segments. x y data.T dist np.hypot np.diff x x.min np.diff y y.min .cumsum t np.r_ 0 dist dist.max ti np.linspace 0 1 num.. into individual segments. x y data.T dist np.hypot np.diff x x.min np.diff y y.min .cumsum t np.r_ 0 dist dist.max ti np.linspace..

Python finite difference functions?

http://stackoverflow.com/questions/18991408/python-finite-difference-functions

.02 np.random.rand 100 .5 #Normalization dx x 1 x 0 # use np.diff x if x is not uniform dxdx dx 2 #First derivatives df np.diff.. x if x is not uniform dxdx dx 2 #First derivatives df np.diff f dx cf np.convolve f 1 1 dx gf ndimage.gaussian_filter1d f.. f sigma 1 order 1 mode 'wrap' dx #Second derivatives ddf np.diff f 2 dxdx ccf np.convolve f 1 2 1 dxdx ggf ndimage.gaussian_filter1d..

How to sort my paws?

http://stackoverflow.com/questions/4502656/how-to-sort-my-paws

# Make a vector between each sucessive impact... dx dy np.diff paw_coords axis 0 .T # Group paws paw_code 0 'LF' 1 'RH'..

Numpy grouping using itertools.groupby performance

http://stackoverflow.com/questions/4651683/numpy-grouping-using-itertools-groupby-performance

size 35000000 dtype 'u4' values.sort diff np.concatenate 1 np.diff values idx np.concatenate np.where diff 0 len values index np.empty.. len idx 1 dtype 'u4 u2' index 'f0' values idx 1 index 'f1' np.diff idx if __name__ '__main__' from timeit import Timer timings.. values.sort dif np.ones values.shape values.dtype dif 1 np.diff values idx np.where dif 0 vals values idx count np.diff idx..

Matplotlib - label each bin

http://stackoverflow.com/questions/6352740/matplotlib-label-each-bin

and the percentages below the x axis... bin_centers 0.5 np.diff bins bins 1 for count x in zip counts bin_centers # Label the..

Removing duplicate columns and rows from a NumPy 2D array

http://stackoverflow.com/questions/8560440/removing-duplicate-columns-and-rows-from-a-numpy-2d-array

a 1d array import numpy as np def unique a a np.sort a b np.diff a b np.r_ 1 b return a b 0 Now to extend it to 2d you need to.. as np def unique a order np.lexsort a.T a a order diff np.diff a axis 0 ui np.ones len a 'bool' ui 1 diff 0 .any axis 1 return..

Matplotlib overlapping annotations

http://stackoverflow.com/questions/8850142/matplotlib-overlapping-annotations

if abs sorted_ltp 0 0 y txt_height #True collision differ np.diff sorted_ltp axis 0 a index sorted_ltp 1 0 txt_height a index..