block_replicate#

astropy.nddata.block_replicate(data, block_size, conserve_sum=True)[source]#

Upsample a data array by block replication.

Parameters:
dataarray_like

The data to be block replicated.

block_sizeint 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_sumbool, optional

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

Returns:
outputarray_like

The block-replicated data. Note that when conserve_sum is True, 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.]])