block_replicate¶
- astropy.nddata.block_replicate(data, block_size, conserve_sum=True)[source]¶
Upsample a data array by block replication.
- Parameters:
- datanumpy:array_like
The data to be block replicated.
- block_size
python:int
or numpy:array_like (python:int
) The integer block size along each axis. If
block_size
is a scalar anddata
has more than one dimension, thenblock_size
will be used for for every axis.- conserve_sumbool, optional
If
True
(the default) then the sum of the output block-replicated data will equal the sum of the inputdata
.
- Returns:
- outputnumpy:array_like
The block-replicated data. Note that when
conserve_sum
isTrue
, the dtype of the output array will be float.
Examples
>>> import numpy as np >>> from astropy.nddata import block_replicate >>> data = np.array([[0., 1.], [2., 3.]]) >>> block_replicate(data, 2) array([[0. , 0. , 0.25, 0.25], [0. , 0. , 0.25, 0.25], [0.5 , 0.5 , 0.75, 0.75], [0.5 , 0.5 , 0.75, 0.75]])
>>> block_replicate(data, 2, conserve_sum=False) array([[0., 0., 1., 1.], [0., 0., 1., 1.], [2., 2., 3., 3.], [2., 2., 3., 3.]])