radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
95 stars 61 forks source link

nan values issue a warning #847

Closed sndik16 closed 1 year ago

sndik16 commented 1 year ago

I got the following line of code, as in the documentation

m1 = cube.moment(order=1)

It raised the following warning.

/Users/mariastone/opt/anaconda3/lib/python3.8/site-packages/spectral_cube/_moments.py:168: RuntimeWarning: invalid value encountered in true_divide return (np.nansum(data * pix_cen, axis=axis) /

My cube is masked, so that the masked pixels have the value of NAN.

Just letting you know about this. Best regards, Maria

e-koch commented 1 year ago

Thanks for the note! You'll get this warning when a spectrum is fully masked and the divide encounters a NaN/NaN.