nmrglue.analysis.analysisbase.ndwindow_inside

class nmrglue.analysis.analysisbase.ndwindow_inside(shape, wsize)[source]

An N-dimentional iterator to slice arrays into uniform size windows.

Given the shape of an array and a window size, an ‘ndwindow_inside’ instance iterators over tuples of slices which slice an the array into uniform size wsize windows/sub-arrays. At each iteration, the index of the top left of the sub-array is incremented by one along the last dimension utill the resulting windows would extend past the array border. All sub-arrays are equal sized (wsize).

Parameters :

size : tuple of ints

Size of array to generate tuples of slices from.

wsize : tuple of ints

Size of the area to select from array (widow size).

See also

ndwindow
Iterator over non-uniform windows.
ndwindow_inside_index
Iterator of a ndwindow_inside and the index of the window’s top left point.

Examples

>>> a = np.arange(9).reshape(3,3)
>>> for s in ndwindow_inside(a.shape,(2,2)):
...     print a[s]
[[0 1]
 [3 4]]
[[1 2]
 [4 5]]
[[3 4]
 [6 7]]
[[4 5]
 [7 8]]
__init__(shape, wsize)[source]

Set up the object

Methods

__init__(shape, wsize) Set up the object
next(() -> the next value, ...)

Previous topic

nmrglue.analysis.analysisbase.ndwindow_index

Next topic

nmrglue.analysis.analysisbase.ndwindow_inside_index

This Page