add_array#
- astropy.nddata.utils.add_array(array_large, array_small, position)[source]#
Add a smaller array at a given position in a larger array.
- Parameters:
- Returns:
- new_array
ndarray
The new array formed from the sum of
array_large
andarray_small
.
- new_array
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.]])