[AstroPy] Problem with the latest version of astropy and numpy
antigone.lambert-huyghe at cea.fr
Mon Aug 26 03:24:08 EDT 2019
I re-installed previous versions, more precisely 3.0.4 for astropy and 1.16.4 for numpy. The things are going well, with no error, and the convolution is well done, for any size of map. So I'm sure it is due to new versions of astropy (or numpy).
I don't understant why it should be a quantity, because I'm not using directly _result_as_quantity(), but astropy.convolution.convolve(), for which the doc is the following:
convolve(array, kernel, boundary='fill', fill_value=0.0, nan_treatment='interpolate', normalize_kernel=True, mask=None, preserve_nan=False, normalization_zero_tol=1e-08)
array NDData<https://docs.astropy.org/en/stable/api/astropy.nddata.NDData.html#astropy.nddata.NDData> or numpy.ndarray<https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray> or array-like
The array to convolve. This should be a 1, 2, or 3-dimensional array or a list or a set of nested lists representing a 1, 2, or 3-dimensional array. If an NDData<https://docs.astropy.org/en/stable/api/astropy.nddata.NDData.html#astropy.nddata.NDData>, the mask of the NDData<https://docs.astropy.org/en/stable/api/astropy.nddata.NDData.html#astropy.nddata.NDData> will be used as the mask argument.
kernel numpy.ndarray<https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray> or Kernel<https://docs.astropy.org/en/stable/api/astropy.convolution.Kernel.html#astropy.convolution.Kernel>
The convolution kernel. The number of dimensions should match those for the array, and the dimensions should be odd in all directions. If a masked array, the masked values will be replaced by fill_value.
An array with the same dimensions and as the input array, convolved with kernel. The data type depends on the input array type. If array is a floating point type, then the return array keeps the same data type, otherwise the type is numpy.float.
I don't understand why this function is now using _result_as_quantity(), from what I checked in the source code it is indirect use. But from the doc I can use numpy arrays as input for the map to convolve.
De : AstroPy [astropy-bounces+antigone.lambert-huyghe=cea.fr at python.org] de la part de Kenneth Anderson [kanderso at gemini.edu]
Envoyé : vendredi 23 août 2019 17:04
À : Astronomical Python mailing list
Objet : Re: [AstroPy] Problem with the latest version of astropy and numpy
I cannot be sure how this problem arises for you, but what can be said is that an AttributeError thrown from the numpy object is way off base for that function. According the docstr on the _result_as_quantity(), the return object, i.e. the 'out' object, should be an astropy.units.Quantity object, not a numpy object.
It is unclear where things got confused in the call stack: perhaps an incorrect object type was passed initially? You may want to absolutely ensure that this did work under the previous versions. And if so, then it would seem something is amiss in that astropy call stack.
>From the docstr:
_result_as_quantity(self, result, unit, out):
[ ... ]
result : `~numpy.ndarray` or tuple of `~numpy.ndarray`
Array(s) which need to be turned into quantity.
unit : `~astropy.units.Unit` or None
Unit for the quantities to be returned (or `None` if the result
should not be a quantity). Should be tuple if result is a tuple.
out : `~astropy.units.Quantity` or None
Possible output quantity. Should be `None` or a tuple if result
is a tuple.
out : `~astropy.units.Quantity`
With units set.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the AstroPy