mpdaf.obj.iter_ima(cube, index=False)[source]

An iterator over the images of successive spectral pixels in a Cube

Each call to the iterator returns the image of the next spectral pixel of the cube. The first image to be returned, is the image of spectral pixel 0, followed, on the next call, by the image of spectral pixel 1 etc.

The return value of iter_ima() is a python generator that can be used in loops, such as in the following example:

from mpdaf.obj import iter_ima
for im,channel in iter_ima(mycube, index=True):
    print("Total flux in channel %d = %g" % (channel,

The cube that contains the images to be returned.


If False, return just an image at each iteration. If True, return both an image and the index of that image along the wavelength axis of the cube.