add_array¶
-
astropy.nddata.
add_array
(array_large, array_small, position)[source] [edit on github]¶ Add a smaller array at a given position in a larger array.
Parameters: array_large :
ndarray
Large array.
array_small :
ndarray
Small array to add.
position : tuple
Position of the small array’s center, with respect to the large array. Coordinates should be in the same order as the array shape.
Returns: new_array :
ndarray
The new array formed from the sum of
array_large
andarray_small
.Notes
The addition is done in-place.
Examples
We consider a large array of zeros with the shape 5x5 and a small array of ones with a shape of 3x3:
>>> import numpy as np >>> from astropy.nddata.utils import add_array >>> large_array = np.zeros((5, 5)) >>> small_array = np.ones((3, 3)) >>> add_array(large_array, small_array, (1, 2)) array([[ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.], [ 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0.]])