Extract a smaller array of the given shape and position from a larger array.
Parameters: | array_large : ndarray
shape : tuple or int
position : tuple of numbers or number
mode : {‘partial’, ‘trim’, ‘strict’}, optional
fill_value : number, optional
return_position : boolean, optional
|
---|---|
Returns: | array_small : ndarray
new_position : tuple
|
Examples
We consider a large array with the shape 11x10, from which we extract a small array of shape 3x5:
>>> import numpy as np
>>> from astropy.nddata.utils import extract_array
>>> large_array = np.arange(110).reshape((11, 10))
>>> extract_array(large_array, (3, 5), (7, 7))
array([[65, 66, 67, 68, 69],
[75, 76, 77, 78, 79],
[85, 86, 87, 88, 89]])