[AstroPy] Problem with compound models using AiryDisk2D

Nadia Dencheva dencheva at stsci.edu
Tue Mar 22 14:27:10 EDT 2016


Hi Jennifer,

Could you file an issue on github.
AiryDisk2D defines one of the class attributes inside the __init__ function.
This was done to work around a problem with older versions of scipy and python3.
Perhaps drop support for those older versions.

Meanwhile if you don't have to inherit from the model classes you can do something like

model = Const2D() + AiryDisk2D()

and evaluate and fit this model.

Cheers,
Nadia

________________________________
From: AstroPy [astropy-bounces at scipy.org] on behalf of Yee, Jennifer [jyee at cfa.harvard.edu]
Sent: Tuesday, March 22, 2016 11:04 AM
To: astropy at scipy.org
Subject: [AstroPy] Problem with compound models using AiryDisk2D

Hi,

I am trying to fit a PSF with an Airy function. If I use AiryDisk2D alone, it works fine, but if I try to create a compound model, for example a constant+AiryDisk2D, the compound model cannot be evaluated because it has "no attribute _rz". Is this a bug? Does anyone know how to fix it? (Note I have no problems creating compound models with Gaussian2D).

Example code and full error message below.

python version: 2.7.5
numpy version:  1.10.4
astropy version:  1.1.2

Thanks,

Jennifer

EXAMPLE CODE:

from astropy.modeling import models

class Airy_with_Background(models.Const2D+models.AiryDisk2D):
    pass

x,y = np.mgrid[:200,:200]
airy_init = Airy_with_Background()
airy_init(x,y)

ERROR MESSAGE:

Traceback (most recent call last):
  File "test_airy.py", line 20, in <module>
    airy_init(x,y)

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 407, \
in __call__
    __call__, args, [('model_set_axis', None)])

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 403, \
in __call__
    return super(cls, self).__call__(*inputs, **kwargs)

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 708, \
in __call__
    outputs = self.evaluate(*chain(inputs, parameters))

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 2514,\
 in evaluate
    return self.__class__.evaluate(*args)

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 1997,\
 in evaluate
    result = cls._evaluate(inputs, params)

  File "/Path/lib/python2.7/site-packages/astropy/modeling/utils.py", line 448,\
 in <lambda>
    g(inputs, params)))

  File "/Path/lib/python2.7/site-packages/astropy/modeling/core.py", line 2438,\
 in <lambda>
    (evaluate(*chain(inputs, islice(params, n_params))),)

  File "/Path/lib/python2.7/site-packages/astropy/modeling/functional_models.py\
", line 1622, in evaluate
    r = np.sqrt((x - x_0) ** 2 + (y - y_0) ** 2) / (radius / cls._rz)

AttributeError: type object 'AiryDisk2D' has no attribute '_rz'
--------------------------------------------------------------
Dr. Jennifer C. Yee

Office: P-344
Harvard-Smithsonian Center for Astrophysics
60 Garden St, MS-15
Cambridge, MA 02138
--------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20160322/e973a67f/attachment.html>


More information about the AstroPy mailing list