block_replicate

astropy.nddata.utils.block_replicate(data, block_size, conserve_sum=True)[source] [edit on github]

Upsample a data array by block replication.

Parameters:
data : array_like

The data to be block replicated.

block_size : int or array_like (int)

The integer block size along each axis. If block_size is a scalar and data has more than one dimension, then block_size will be used for for every axis.

conserve_sum : bool, optional

If True (the default) then the sum of the output block-replicated data will equal the sum of the input data.

Returns:
output : array_like

The block-replicated data.

Examples

>>> import numpy as np
>>> from astropy.nddata.utils 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.]])