astropy:docs

rebin

ccdproc.rebin(ccd, newshape)[source]

Rebin an array to have a new shape.

Parameters:

data : CCDData or ndarray

Data to rebin

newshape : tuple

Tuple containing the new shape for the array

Returns:

output : CCDData or ndarray

An array with the new shape. It will have the same type as the input object.

Raises:

TypeError

A type error is raised if data is not an numpy.ndarray or CCDData

ValueError

A value error is raised if the dimenisions of new shape is not equal to data

Notes

This is based on the scipy cookbook for rebinning: http://wiki.scipy.org/Cookbook/Rebinning

If rebinning a CCDData object to a smaller shape, the masking and uncertainty are not handled correctly.

Examples

Given an array that is 100x100,

>>> import numpy as np
>>> from astropy import units as u
>>> arr1 = CCDData(np.ones([10, 10]), unit=u.adu)

the syntax for rebinning an array to a shape of (20,20) is

>>> rebinned = rebin(arr1, (20,20))

Page Contents