Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescaling FluxPerAngle Profile Fails with Attribute Error #11

Open
Snyder005 opened this issue Nov 3, 2021 · 0 comments
Open

Rescaling FluxPerAngle Profile Fails with Attribute Error #11

Snyder005 opened this issue Nov 3, 2021 · 0 comments

Comments

@Snyder005
Copy link

Snyder005 commented Nov 3, 2021

I have encountered the following issue while attempting to rescale a FluxPerAngle profile using the FluxPerAngle.rescale() method if it was previously initialized with a scale.

The code to recreate the issue is

defocus_profile = FluxPerAngle(550., LSST, LSSTSEEING, scale=old_scale)
defocus_profile.rescale(new_scale)

AttributeError                            Traceback (most recent call last)
<ipython-input-103-f51bc1bc45e7> in <module>
----> 1 defocus_profile.rescale(scale)

~/anaconda3/lib/python3.8/site-packages/lfd/analysis/profiles/convolutionobj.py in rescale(self, x, y, step)
    129         # must be called before update so that scaleleft and scaleright
    130         # remain unchanged from the original
--> 131         self.obj = self.f(newscale)
    132         self.scale = newscale
    133         self.update()

~/anaconda3/lib/python3.8/site-packages/lfd/analysis/profiles/defocusing.py in f(self, r, h, instrument, units)
     77 
     78         if not all([h, Ro, Ri]):
---> 79             h = self.h
     80             Ro = self.Ro
     81             Ri = self.Ri

AttributeError: 'FluxPerAngle' object has no attribute 'h'

This is due to the fact that the assignment of h (as well as Ro and Ri) only occurs if scale=None during the object creation. See the following:

def __init__(self, h, instrument, scale=None, units="arcsec", res=0.001,
                 **kwargs):
        if scale is None:
            self.h = h
            self.Ro, self.Ri = instrument
            thetao = self.Ro / (h * 1000000.)
            radscale = np.arange(-2*thetao, 2*thetao, thetao*res)
            scale = np.multiply(radscale, RAD2ARCSEC)
        obj = self.f(scale, h, instrument, units=units)

        ConvolutionObject.__init__(self, obj, scale)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant