musevlt / mpdaf

MUSE Python Data Analysis Framework
BSD 3-Clause "New" or "Revised" License
15 stars 4 forks source link

How to retrieve the data in a numpy array #16

Closed HeloiseS closed 2 years ago

HeloiseS commented 3 years ago

Hi,

I was wondering how to get the data cubes and subcubes in a numpy format? I've tried something like this:

arr_cube=np.zeros((subcube.shape[1], subcube.shape[2]))

for i in range(subcube.shape[0]):
    arr_cube+=subcube[i,:,:].get_data_hdu('DATA').data

but it left me with loads of nan values and holes in my image.

Cheers, Heloise

saimn commented 3 years ago

The Cube (Image and Spectrum as well) objects have a .data attribute which is a Numpy masked array (and .var for the variance).