[AstroPy] Problem with compound models using AiryDisk2D

Yee, Jennifer jyee at cfa.harvard.edu
Tue Mar 22 11:04:30 EDT 2016


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/ac7ef7f9/attachment.html>


More information about the AstroPy mailing list