mpdaf icon indicating copy to clipboard operation
mpdaf copied to clipboard

Spectrum's iterator with null values

Open jortiz12 opened this issue 3 years ago • 2 comments

Dear MPDAF community,

I´m having problems when using the various "iterators" describe in the Interface for spectra, images and cubes section.

Making use of a datacube (edge-on galaxy IC 1533, already reduced by S. Comeron), whose white-image is shown below imagen

, the loops using the spectrum's iterator (for instance) fails because some of the spaxels have no flux, as shown in figure above (I think). This is code from the Cube_object section (apologies but can´t insert in code format), imagen

And this is the error I get,

imagen

Any quick workaround to get around this issue? I face this issue in other parts of the tutorial where iterators are used too.

Needless to say, many thanks in advance.

Kind Regards, Jose

jortiz12 avatar Jul 13 '22 09:07 jortiz12

You could skip the spectra that are entirely masked (e.g. with sp.mask.all()).

saimn avatar Jul 13 '22 12:07 saimn

Thanks Simon. I'd appreciate if could show mw how to modify this piece of code taking into account your suggestion.

cont1 = obj1.clone(data_init=np.empty, var_init=np.zeros) for sp, co in zip(iter_spe(obj1), iter_spe(cont1)): co[:] = sp.poly_spec(5)

jortiz12 avatar Jul 13 '22 13:07 jortiz12