[AstroPy] Problem with the latest version of astropy and numpy

LAMBERT-HUYGHE Antigone antigone.lambert-huyghe at cea.fr
Fri Aug 23 08:10:17 EDT 2019


Hi everyone,

I post here because I don't really know where to advise of that problem.

I use a convolution function from astropy.convolution package. I call it with

result = [astropy.convolution.]convolve(inhdu[0].data, kernel, boundary = 'fill', fill_value = float('NaN'), preserve_nan=True)

where inhdu[0].data is a numpy array, type float32, and a size of ~24000x25000 pixels, and where kernel is a gaussian kernel created with [astropy.convolution.]Gaussian2DKernel.

I previously had version 3.1.X of astropy, and 1.16.X of numpy, and the convolution was working fine. But the packages went to versions 3.2 on mid-june and 1.17 at the end of july respectively, and I have now an error with the upgraded packages:



~/Bureau/Codes/python_lib/mylib/fits.py in fits_convolve(infits, fromfwhm, tofwhm, GaussianTrim, WriteTo, pixkey, pixkey_unit, returnHDU, verbose)
    640             result[i, :, :] = convolve(plane, kernel, boundary = 'fill', fill_value = float('NaN'), preserve_nan=True)
    641     else:
--> 642         result = convolve(inhdu[0].data, kernel, boundary = 'fill', fill_value = float('NaN'), preserve_nan=True)
    643         #result = convolve_fft(inhdu[0].data, kernel)
    644

~/.local/lib/python3.6/site-packages/astropy/nddata/decorators.py in wrapper(data, *args, **kwargs)
    244                                   AstropyUserWarning)
    245
--> 246             result = func(data, *args, **kwargs)
    247
    248             if unpack and repack:

~/.local/lib/python3.6/site-packages/astropy/convolution/convolve.py in convolve(array, kernel, boundary, fill_value, nan_treatment, normalize_kernel, mask, preserve_nan, normalization_zero_tol)
    336     if normalize_kernel:
    337         if not nan_interpolate:
--> 338             result /= kernel_sum
    339     else:
    340         if nan_interpolate:

~/.local/lib/python3.6/site-packages/astropy/units/quantity.py in __array_ufunc__(self, function, method, *inputs, **kwargs)
    473             return result
    474
--> 475         return self._result_as_quantity(result, unit, out)
    476
    477     def _result_as_quantity(self, result, unit, out):

~/.local/lib/python3.6/site-packages/astropy/units/quantity.py in _result_as_quantity(self, result, unit, out)
    512         # the output is of the correct Quantity subclass, as it was passed
    513         # through check_output.
--> 514         out._set_unit(unit)
    515         return out
    516

AttributeError: 'numpy.ndarray' object has no attribute '_set_unit'


I tried to understand the problem, but I'm stuck and I really need that function to work. For the moment I will just reinstall previous versions for both packages, because it was working before the upgrade, but I wanted to let it know if it is a bug due to latest versions. It may be not in astropy package but in numpy package, but I was not able to understand that too.

I hope this message is not too long, but I wanted to make it as clear as possible.

Best regards

Antigone Lambert-Huyghe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20190823/2e7c2465/attachment.html>


More information about the AstroPy mailing list